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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
StatefulLens.fst | StatefulLens.hlens_ref | val hlens_ref (#a: Type) : hlens (ref a) a | val hlens_ref (#a: Type) : hlens (ref a) a | let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
} | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 88,
"start_col": 0,
"start_line": 85
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | StatefulLens.hlens (FStar.ST.ref a) a | Prims.Tot | [
"total"
] | [] | [
"StatefulLens.Mkhlens",
"FStar.ST.ref",
"FStar.Pervasives.Native.tuple2",
"FStar.Monotonic.Heap.heap",
"FStar.Ref.sel",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Ref.upd",
"StatefulLens.hlens"
] | [] | false | false | false | true | false | let hlens_ref (#a: Type) : hlens (ref a) a =
| { get = (fun (h, x) -> sel h x); put = (fun y (h, x) -> (upd h x y, x)) } | false |
SealedModel.fst | SealedModel.seal | val seal (#a : Type u#aa) (x:a) : Tot (sealed a) | val seal (#a : Type u#aa) (x:a) : Tot (sealed a) | let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x) | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 43,
"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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> SealedModel.sealed a | Prims.Tot | [
"total"
] | [] | [
"SealedModel.Seal",
"Prims.unit",
"SealedModel.sealed"
] | [] | false | false | false | true | false | let seal (#a: Type u#aa) (x: a) : Tot (sealed a) =
| Seal (fun () -> x) | false |
SealedModel.fst | SealedModel.sealed_singl | val sealed_singl (#a:Type) (x y : sealed a)
: Lemma (x == y) | val sealed_singl (#a:Type) (x y : sealed a)
: Lemma (x == y) | let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 40,
"start_col": 0,
"start_line": 37
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: SealedModel.sealed a -> y: SealedModel.sealed a -> FStar.Pervasives.Lemma (ensures x == y) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"SealedModel.sealed",
"Prims.unit",
"SealedModel.unobs_axiom",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let sealed_singl (#a: Type) (x y: sealed a) : Lemma (x == y) =
| let Seal f = x in
let Seal g = y in
unobs_axiom f g | false |
SealedModel.fst | SealedModel.prec_no_x | val prec_no_x: x: t -> squash (x << seal x) -> Lemma (x == Y) | val prec_no_x: x: t -> squash (x << seal x) -> Lemma (x == Y) | let prec_no_x (x : t) (_ : squash (x << seal x)) : Lemma (x == Y) =
if X? x then (
let X s = x in
assert (s << x);
sealed_singl s (seal x);
(* At this point we have s << x << seal x, but s == seal x, so s << s *)
assert False
) | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 3,
"end_line": 89,
"start_col": 0,
"start_line": 82
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g
let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x)
let unseal (#a : Type u#aa) (s : sealed a) : TacS a =
let Seal f = s in
f ()
(* NOTE: there is nothing saying the value of type `a`
that the function receives precedes s, or anything
similar. See below for what goes wrong if so. *)
let map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b)
=
Seal (fun () -> f (unseal s))
let bind_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS (sealed b))
: Tot (sealed b)
=
Seal (fun () -> unseal (f (unseal s)))
(* Q: Does `x` precede `seal x`?
We cannot really assume that, as it interacts badly
with the fact that all seals are equal whenever an
inductive contains sealed values of itself. For instance:
*)
noeq
type t =
| X of sealed t
| Y
(* If for a value `x : t` we have `x << seal x`, then we
can prove that `x` must be `Y`, which is definitely unexpected. *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: SealedModel.t -> _: Prims.squash (x << SealedModel.seal x)
-> FStar.Pervasives.Lemma (ensures x == SealedModel.Y) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"SealedModel.t",
"Prims.squash",
"Prims.precedes",
"SealedModel.sealed",
"SealedModel.seal",
"SealedModel.uu___is_X",
"Prims._assert",
"Prims.l_False",
"Prims.unit",
"SealedModel.sealed_singl",
"Prims.bool",
"Prims.l_True",
"Prims.eq2",
"SealedModel.Y",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let prec_no_x (x: t) (_: squash (x << seal x)) : Lemma (x == Y) =
| if X? x
then
(let X s = x in
assert (s << x);
sealed_singl s (seal x);
assert False) | false |
SealedModel.fst | SealedModel.unseal | val unseal (#a : Type u#aa) (s : sealed a) : TacS a | val unseal (#a : Type u#aa) (s : sealed a) : TacS a | let unseal (#a : Type u#aa) (s : sealed a) : TacS a =
let Seal f = s in
f () | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 6,
"end_line": 47,
"start_col": 0,
"start_line": 45
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g
let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": 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: SealedModel.sealed a -> FStar.Tactics.Effect.TacS a | FStar.Tactics.Effect.TacS | [] | [] | [
"SealedModel.sealed",
"Prims.unit"
] | [] | false | true | false | false | false | let unseal (#a: Type u#aa) (s: sealed a) : TacS a =
| let Seal f = s in
f () | false |
SealedModel.fst | SealedModel.contra_map_seal_precedes | val contra_map_seal_precedes
(map_seal:
(#a: Type0 -> #b: Type0 -> s: sealed a -> (f: (x: a{x << s}) -> TacS b) -> Tot (sealed b))
)
: sealed int | val contra_map_seal_precedes
(map_seal:
(#a: Type0 -> #b: Type0 -> s: sealed a -> (f: (x: a{x << s}) -> TacS b) -> Tot (sealed b))
)
: sealed int | let contra_map_seal_precedes
(map_seal : (
(#a : Type0) -> (#b : Type0) ->
(s : sealed a) ->
(f : (x:a{x << s}) -> TacS b) ->
Tot (sealed b)))
: sealed int =
let s : sealed t = seal (X (seal Y)) in
let f (x:t{x << s}) : TacS int =
match x with
| X s' ->
sealed_singl s (seal x);
prec_no_x x ();
false_elim ()
| Y ->
123
in
(* This call must crash *)
map_seal s f | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 124,
"start_col": 0,
"start_line": 106
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g
let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x)
let unseal (#a : Type u#aa) (s : sealed a) : TacS a =
let Seal f = s in
f ()
(* NOTE: there is nothing saying the value of type `a`
that the function receives precedes s, or anything
similar. See below for what goes wrong if so. *)
let map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b)
=
Seal (fun () -> f (unseal s))
let bind_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS (sealed b))
: Tot (sealed b)
=
Seal (fun () -> unseal (f (unseal s)))
(* Q: Does `x` precede `seal x`?
We cannot really assume that, as it interacts badly
with the fact that all seals are equal whenever an
inductive contains sealed values of itself. For instance:
*)
noeq
type t =
| X of sealed t
| Y
(* If for a value `x : t` we have `x << seal x`, then we
can prove that `x` must be `Y`, which is definitely unexpected. *)
let prec_no_x (x : t) (_ : squash (x << seal x)) : Lemma (x == Y) =
if X? x then (
let X s = x in
assert (s << x);
sealed_singl s (seal x);
(* At this point we have s << x << seal x, but s == seal x, so s << s *)
assert False
)
(* If the map function above had the type:
let map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(*see:*) (f : (x:a{x << s}) -> TacS b)
: Tot (sealed b)
=
Seal (fun () -> f (unseal s))
then `f` could assume that it will never receive
an `X`, but that's just false. *)
type tx = x:t{X? x} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": 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 |
map_seal:
(s: SealedModel.sealed a -> _: (f: x: a{x << s} -> FStar.Tactics.Effect.TacS b)
-> SealedModel.sealed b)
-> SealedModel.sealed Prims.int | Prims.Tot | [
"total"
] | [] | [
"SealedModel.sealed",
"Prims.precedes",
"SealedModel.t",
"Prims.int",
"FStar.Pervasives.false_elim",
"Prims.unit",
"SealedModel.prec_no_x",
"SealedModel.sealed_singl",
"SealedModel.seal",
"SealedModel.X",
"SealedModel.Y"
] | [] | false | false | false | false | false | let contra_map_seal_precedes
(map_seal:
(#a: Type0 -> #b: Type0 -> s: sealed a -> (f: (x: a{x << s}) -> TacS b) -> Tot (sealed b))
)
: sealed int =
| let s:sealed t = seal (X (seal Y)) in
let f (x: t{x << s}) : TacS int =
match x with
| X s' ->
sealed_singl s (seal x);
prec_no_x x ();
false_elim ()
| Y -> 123
in
map_seal s f | false |
Huffman.fst | Huffman.cancelation_one | val cancelation_one (t' t: trie) (s: symbol)
: Lemma (requires (b2t (Node? t')))
(ensures
(Node? t' ==>
(match encode_one t s with
| Some e ->
(match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True)))
(decreases t) | val cancelation_one (t' t: trie) (s: symbol)
: Lemma (requires (b2t (Node? t')))
(ensures
(Node? t' ==>
(match encode_one t s with
| Some e ->
(match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True)))
(decreases t) | let rec cancelation_one (t':trie) (t:trie) (s:symbol) : Lemma
(requires (b2t (Node? t')))
(ensures (Node? t' ==>
(match encode_one t s with
| Some e -> (match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True))) (decreases t) =
match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s) | {
"file_name": "examples/algorithms/Huffman.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 184,
"start_col": 0,
"start_line": 171
} | (*
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 Huffman
open FStar.Char
open FStar.List.Tot
type symbol = char
// could consider moving weights away from the nodes,
// only need one weight per each trie in the forest
type trie =
| Leaf : w:pos -> s:symbol -> trie
| Node : w:pos -> l:trie -> r:trie -> trie
let weight (t:trie) : Tot pos =
match t with
| Leaf w _ -> w
| Node w _ _ -> w
let leq_trie (t1:trie) (t2:trie) : Tot bool =
weight t1 <= weight t2
(* Copied and adapted some part about sorted int lists,
this should really be generic in the library *)
let rec sorted (ts:list trie) : Tot bool =
match ts with
| [] | [_] -> true
| t1::t2::ts' -> leq_trie t1 t2 && sorted (t2::ts')
type permutation (l1:list trie) (l2:list trie) =
length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
val sorted_smaller: x:trie
-> y:trie
-> l:list trie
-> Lemma (requires (sorted (x::l) /\ mem y l))
(ensures (leq_trie x y))
[SMTPat (sorted (x::l)); SMTPat (mem y l)]
let rec sorted_smaller x y l = match l with
| [] -> ()
| z::zs -> if z=y then () else sorted_smaller x y zs
let rec insert_in_sorted (x:trie) (xs:list trie) : Pure (list trie)
(requires (b2t (sorted xs)))
(ensures (fun ys -> sorted ys /\ permutation (x::xs) ys)) =
match xs with
| [] -> [x]
| x'::xs' -> if leq_trie x x' then x :: xs
else (let i_tl = insert_in_sorted x xs' in
let (z::_) = i_tl in (* <-- needed for triggering patterns? *)
x' :: i_tl)
let rec insertion_sort (ts : list trie) : Pure (list trie)
(requires (True)) (ensures (fun ts' -> sorted ts' /\ permutation ts ts')) =
match ts with
| [] -> []
| t::ts' -> insert_in_sorted t (insertion_sort ts')
let rec huffman_trie (ts:list trie) : Pure trie
(requires (sorted ts /\ List.Tot.length ts > 0))
(ensures (fun t ->
((List.Tot.length ts > 1 \/ existsb Node? ts) ==> Node? t)))
(decreases (List.Tot.length ts)) =
match ts with
| t1::t2::ts' ->
assert(List.Tot.length ts > 1); (* so it needs to prove Node? t *)
let w = weight t1 + weight t2 in
let t = huffman_trie ((Node w t1 t2) `insert_in_sorted` ts') in
(* by the recursive call we know:
(List.Tot.length (Node w t1 t2 `insert_in_sorted` ts') > 1
\/ existsb Node? (Node w t1 t2 `insert_in_sorted` ts') ==> Node? t) *)
(* Since ts' could be empty, I thought that the only way we can
use this is by proving: existsb Node? (Node w t1 t2
`insert_in_sorted` ts'), which requires induction. But F* was smarter! *)
if Nil? ts' then
assert(existsb Node? (Node w t1 t2 `insert_in_sorted` ts'))
else
assert(length (Node w t1 t2 `insert_in_sorted` ts') > 1);
assert(Node? t);
t
| [t1] -> t1 (* this uses `existsb Node? [t] ==> Node? t` fact *)
let huffman (sws:list (symbol*pos)) : Pure trie
(requires (b2t (List.Tot.length sws > 0)))
(ensures (fun t -> List.Tot.length sws > 1 ==> Node? t)) =
huffman_trie (insertion_sort (List.Tot.map (fun (s,w) -> Leaf w s) sws))
let rec encode_one (t:trie) (s:symbol) : Tot (option (list bool)) =
match t with
| Leaf _ s' -> if s = s' then Some [] else None
| Node _ t1 t2 ->
match encode_one t1 s with
| Some bs -> Some (false :: bs)
| None -> match encode_one t2 s with
| Some bs -> Some (true :: bs)
| None -> None
// Modulo the option this is flatten (map (encode_one t) ss)
let rec encode (t:trie) (ss:list symbol) : Pure (option (list bool))
(requires (True))
(ensures (fun bs -> Node? t /\ Cons? ss /\ Some? bs
==> Cons? (Some?.v bs))) =
match ss with
| [] -> None (* can't encode the empty string *)
| [s] -> encode_one t s
| s::ss' -> match encode_one t s, encode t ss' with
| Some bs, Some bs' -> Some (bs @ bs')
| _, _ -> None
// A more complex decode I originally wrote
let rec decode_one (t:trie) (bs:list bool) : Pure (option (symbol * list bool))
(requires (True))
(ensures (fun r -> Some? r ==>
(List.Tot.length (snd (Some?.v r)) <= List.Tot.length bs /\
(Node? t ==> List.Tot.length (snd (Some?.v r)) < List.Tot.length bs)))) =
match t, bs with
| Node _ t1 t2, b::bs' -> decode_one (if b then t2 else t1) bs'
| Leaf _ s, _ -> Some (s, bs)
| Node _ _ _, [] -> None (* out of symbols *)
let rec decode' (t:trie) (bs:list bool) : Tot (option (list symbol))
(decreases (List.Tot.length bs)) =
match t, bs with
| Leaf _ s, [] -> Some [s] (* degenerate case, case omitted below *)
| Leaf _ _, _::_ -> None (* too many symbols, case omitted below *)
| Node _ _ _, [] -> Some []
| Node _ _ _, _::_ -> match decode_one t bs with
| Some (s, bs') -> (match decode' t bs' with
| Some ss -> Some (s :: ss)
| None -> None)
| _ -> None
// Simplified decode using idea from Bird and Wadler's book
// (it has more complex termination condition though)
let rec decode_aux (t':trie{Node? t'}) (t:trie) (bs:list bool) :
Pure (option (list symbol))
(requires (True))
(ensures (fun ss -> Some? ss ==> List.Tot.length (Some?.v ss) > 0))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0]))
=
match t, bs with
| Leaf _ s, [] -> Some [s]
| Leaf _ s, _::_ -> (match decode_aux t' t' bs with
| Some ss -> Some (s :: ss)
| None -> None)
| Node _ t1 t2, b :: bs' -> decode_aux t' (if b then t2 else t1) bs'
| Node _ _ _, [] -> None
let decode (t:trie) (bs:list bool) : Pure (option (list symbol))
(requires (b2t (Node? t))) (ensures (fun _ -> True)) =
decode_aux t t bs | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "Huffman.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"short_module": null
},
{
"abbrev": 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': Huffman.trie -> t: Huffman.trie -> s: Huffman.symbol
-> FStar.Pervasives.Lemma (requires Node? t')
(ensures
Node? t' ==>
(match Huffman.encode_one t s with
| FStar.Pervasives.Native.Some #_ e ->
(match Huffman.decode_aux t' t e with
| FStar.Pervasives.Native.Some #_ d -> d = [s]
| FStar.Pervasives.Native.None #_ -> Prims.l_False)
<:
Prims.logical
| FStar.Pervasives.Native.None #_ -> Prims.l_True))
(decreases t) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Huffman.trie",
"Huffman.symbol",
"Prims.pos",
"Huffman.encode_one",
"Prims.list",
"Prims.bool",
"Huffman.cancelation_one",
"Prims.unit",
"Prims.b2t",
"Huffman.uu___is_Node",
"Prims.squash",
"Prims.l_imp",
"Huffman.decode_aux",
"Prims.op_Equality",
"Prims.Cons",
"Prims.Nil",
"Prims.l_False",
"Prims.logical",
"Prims.l_True",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec cancelation_one (t' t: trie) (s: symbol)
: Lemma (requires (b2t (Node? t')))
(ensures
(Node? t' ==>
(match encode_one t s with
| Some e ->
(match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True)))
(decreases t) =
| match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s) | false |
Hacl.Spec.K256.MathLemmas.fst | Hacl.Spec.K256.MathLemmas.lemma_as_nat_horner | val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0) | val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0) | let lemma_as_nat_horner r0 r1 r2 r3 r4 =
calc (==) {
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
(==) { lemma_distr_pow r1 ((r4 * pow2 52 + r3) * pow2 52 + r2) 52 52 }
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r2 (r4 * pow2 52 + r3) 52 104 }
(r4 * pow2 52 + r3) * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r3 r4 52 156 }
r4 * pow2 208 + r3 * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
} | {
"file_name": "code/k256/Hacl.Spec.K256.MathLemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 166,
"start_col": 0,
"start_line": 157
} | module Hacl.Spec.K256.MathLemmas
open FStar.Mul
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val lemma_swap_mul3 (a b c:int) : Lemma (a * b * c == a * c * b)
let lemma_swap_mul3 a b c =
calc (==) {
a * b * c;
(==) { Math.Lemmas.paren_mul_right a b c }
a * (b * c);
(==) { Math.Lemmas.swap_mul b c }
a * (c * b);
(==) { Math.Lemmas.paren_mul_right a c b }
a * c * b;
}
val lemma_mod_mul_distr (a b:int) (n:pos) : Lemma (a * b % n = (a % n) * (b % n) % n)
let lemma_mod_mul_distr a b n =
Math.Lemmas.lemma_mod_mul_distr_l a b n;
Math.Lemmas.lemma_mod_mul_distr_r (a % n) b n
val lemma_mod_sub_distr (a b:int) (n:pos) : Lemma ((a - b) % n = (a % n - b % n) % n)
let lemma_mod_sub_distr a b n =
Math.Lemmas.lemma_mod_plus_distr_l a (- b) n;
Math.Lemmas.lemma_mod_sub_distr (a % n) b n
val lemma_ab_le_cd (a b c d:nat) : Lemma
(requires a <= c /\ b <= d)
(ensures a * b <= c * d)
let lemma_ab_le_cd a b c d =
Math.Lemmas.lemma_mult_le_left a b d;
Math.Lemmas.lemma_mult_le_right d a c
val lemma_ab_lt_cd (a b c d:pos) : Lemma
(requires a < c /\ b < d)
(ensures a * b < c * d)
let lemma_ab_lt_cd a b c d =
Math.Lemmas.lemma_mult_lt_left a b d;
Math.Lemmas.lemma_mult_lt_right d a c
val lemma_bound_mul64_wide (ma mb:nat) (mma mmb:nat) (a b:nat) : Lemma
(requires a <= ma * mma /\ b <= mb * mmb)
(ensures a * b <= ma * mb * (mma * mmb))
let lemma_bound_mul64_wide ma mb mma mmb a b =
calc (<=) {
a * b;
(<=) { lemma_ab_le_cd a b (ma * mma) (mb * mmb) }
(ma * mma) * (mb * mmb);
(==) { Math.Lemmas.paren_mul_right ma mma (mb * mmb) }
ma * (mma * (mb * mmb));
(==) {
Math.Lemmas.paren_mul_right mma mb mmb;
Math.Lemmas.swap_mul mma mb;
Math.Lemmas.paren_mul_right mb mma mmb }
ma * (mb * (mma * mmb));
(==) { Math.Lemmas.paren_mul_right ma mb (mma * mmb) }
ma * mb * (mma * mmb);
}
val lemma_distr_pow (a b:int) (c d:nat) : Lemma ((a + b * pow2 c) * pow2 d = a * pow2 d + b * pow2 (c + d))
let lemma_distr_pow a b c d =
calc (==) {
(a + b * pow2 c) * pow2 d;
(==) { Math.Lemmas.distributivity_add_left a (b * pow2 c) (pow2 d) }
a * pow2 d + b * pow2 c * pow2 d;
(==) { Math.Lemmas.paren_mul_right b (pow2 c) (pow2 d); Math.Lemmas.pow2_plus c d }
a * pow2 d + b * pow2 (c + d);
}
val lemma_distr_pow_pow (a:int) (b:nat) (c:int) (d e:nat) :
Lemma ((a * pow2 b + c * pow2 d) * pow2 e = a * pow2 (b + e) + c * pow2 (d + e))
let lemma_distr_pow_pow a b c d e =
calc (==) {
(a * pow2 b + c * pow2 d) * pow2 e;
(==) { lemma_distr_pow (a * pow2 b) c d e }
a * pow2 b * pow2 e + c * pow2 (d + e);
(==) { Math.Lemmas.paren_mul_right a (pow2 b) (pow2 e); Math.Lemmas.pow2_plus b e }
a * pow2 (b + e) + c * pow2 (d + e);
}
val lemma_distr_eucl_mul (r a:int) (b:pos) : Lemma (r * (a % b) + r * (a / b) * b = r * a)
let lemma_distr_eucl_mul r a b =
calc (==) {
r * (a % b) + r * (a / b) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b) b }
r * (a % b) + r * ((a / b) * b);
(==) { Math.Lemmas.distributivity_add_right r (a % b) (a / b * b) }
r * (a % b + a / b * b);
(==) { Math.Lemmas.euclidean_division_definition a b }
r * a;
}
val lemma_distr_eucl_mul_add (r a c:int) (b:pos) : Lemma (r * (a % b) + r * (a / b + c) * b = r * a + r * c * b)
let lemma_distr_eucl_mul_add r a c b =
calc (==) {
r * (a % b) + r * (a / b + c) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b + c) b }
r * (a % b) + r * ((a / b + c) * b);
(==) { Math.Lemmas.distributivity_add_left (a / b) c b }
r * (a % b) + r * ((a / b * b) + c * b);
(==) { Math.Lemmas.distributivity_add_right r (a / b * b) (c * b) }
r * (a % b) + r * (a / b * b) + r * (c * b);
(==) { Math.Lemmas.paren_mul_right r (a / b) b; Math.Lemmas.paren_mul_right r c b }
r * (a % b) + r * (a / b) * b + r * c * b;
(==) { lemma_distr_eucl_mul r a b }
r * a + r * c * b;
}
val lemma_distr_eucl (a b:int) : Lemma ((a / pow2 52 + b) * pow2 52 + a % pow2 52 = a + b * pow2 52)
let lemma_distr_eucl a b = lemma_distr_eucl_mul_add 1 a b (pow2 52)
val lemma_a_plus_b_pow2_mod2 (a b:int) (c:pos) : Lemma ((a + b * pow2 c) % 2 = a % 2)
let lemma_a_plus_b_pow2_mod2 a b c =
assert_norm (pow2 1 = 2);
Math.Lemmas.lemma_mod_plus_distr_r a (b * pow2 c) 2;
Math.Lemmas.pow2_multiplication_modulo_lemma_1 b 1 c
val lemma_as_nat64_horner (r0 r1 r2 r3:int) :
Lemma (r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192 ==
((r3 * pow2 64 + r2) * pow2 64 + r1) * pow2 64 + r0)
let lemma_as_nat64_horner r0 r1 r2 r3 =
calc (==) {
r0 + pow2 64 * (r1 + pow2 64 * (r2 + pow2 64 * r3));
(==) { Math.Lemmas.swap_mul (pow2 64) (r1 + pow2 64 * (r2 + pow2 64 * r3)) }
r0 + (r1 + pow2 64 * (r2 + pow2 64 * r3)) * pow2 64;
(==) { Math.Lemmas.swap_mul (pow2 64) (r2 + pow2 64 * r3) }
r0 + (r1 + (r2 + pow2 64 * r3) * pow2 64) * pow2 64;
(==) { lemma_distr_pow r1 (r2 + pow2 64 * r3) 64 64 }
r0 + r1 * pow2 64 + (r2 + pow2 64 * r3) * pow2 128;
(==) { Math.Lemmas.swap_mul (pow2 64) r3 }
r0 + r1 * pow2 64 + (r2 + r3 * pow2 64) * pow2 128;
(==) { lemma_distr_pow r2 r3 64 128 }
r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192;
}
val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.MathLemmas.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 | r0: Prims.int -> r1: Prims.int -> r2: Prims.int -> r3: Prims.int -> r4: Prims.int
-> FStar.Pervasives.Lemma
(ensures
r0 + r1 * Prims.pow2 52 + r2 * Prims.pow2 104 + r3 * Prims.pow2 156 + r4 * Prims.pow2 208 ==
(((r4 * Prims.pow2 52 + r3) * Prims.pow2 52 + r2) * Prims.pow2 52 + r1) * Prims.pow2 52 + r0) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.MathLemmas.lemma_distr_pow",
"Prims.squash"
] | [] | false | false | true | false | false | let lemma_as_nat_horner r0 r1 r2 r3 r4 =
| calc ( == ) {
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
( == ) { lemma_distr_pow r1 ((r4 * pow2 52 + r3) * pow2 52 + r2) 52 52 }
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 104 + r1 * pow2 52 + r0;
( == ) { lemma_distr_pow r2 (r4 * pow2 52 + r3) 52 104 }
(r4 * pow2 52 + r3) * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
( == ) { lemma_distr_pow r3 r4 52 156 }
r4 * pow2 208 + r3 * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
} | false |
Huffman.fst | Huffman.cancelation_aux | val cancelation_aux (t: trie{Node? t}) (ss: list symbol)
: Lemma (requires (True))
(ensures
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True))
(decreases ss) | val cancelation_aux (t: trie{Node? t}) (ss: list symbol)
: Lemma (requires (True))
(ensures
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True))
(decreases ss) | let rec cancelation_aux (t:trie{Node? t}) (ss:list symbol) : Lemma
(requires (True))
(ensures (match encode t ss with
| Some e -> (match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)) (decreases ss) =
match ss with
| [] -> ()
| [s] -> cancelation_one t t s
| s::ss' ->
cancelation_one t t s;
cancelation_aux t ss';
(match encode_one t s, encode t ss' with
| Some bs, Some bs' -> decode_prefix t bs bs' s
| _, _ -> ()) | {
"file_name": "examples/algorithms/Huffman.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 223,
"start_col": 0,
"start_line": 208
} | (*
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 Huffman
open FStar.Char
open FStar.List.Tot
type symbol = char
// could consider moving weights away from the nodes,
// only need one weight per each trie in the forest
type trie =
| Leaf : w:pos -> s:symbol -> trie
| Node : w:pos -> l:trie -> r:trie -> trie
let weight (t:trie) : Tot pos =
match t with
| Leaf w _ -> w
| Node w _ _ -> w
let leq_trie (t1:trie) (t2:trie) : Tot bool =
weight t1 <= weight t2
(* Copied and adapted some part about sorted int lists,
this should really be generic in the library *)
let rec sorted (ts:list trie) : Tot bool =
match ts with
| [] | [_] -> true
| t1::t2::ts' -> leq_trie t1 t2 && sorted (t2::ts')
type permutation (l1:list trie) (l2:list trie) =
length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
val sorted_smaller: x:trie
-> y:trie
-> l:list trie
-> Lemma (requires (sorted (x::l) /\ mem y l))
(ensures (leq_trie x y))
[SMTPat (sorted (x::l)); SMTPat (mem y l)]
let rec sorted_smaller x y l = match l with
| [] -> ()
| z::zs -> if z=y then () else sorted_smaller x y zs
let rec insert_in_sorted (x:trie) (xs:list trie) : Pure (list trie)
(requires (b2t (sorted xs)))
(ensures (fun ys -> sorted ys /\ permutation (x::xs) ys)) =
match xs with
| [] -> [x]
| x'::xs' -> if leq_trie x x' then x :: xs
else (let i_tl = insert_in_sorted x xs' in
let (z::_) = i_tl in (* <-- needed for triggering patterns? *)
x' :: i_tl)
let rec insertion_sort (ts : list trie) : Pure (list trie)
(requires (True)) (ensures (fun ts' -> sorted ts' /\ permutation ts ts')) =
match ts with
| [] -> []
| t::ts' -> insert_in_sorted t (insertion_sort ts')
let rec huffman_trie (ts:list trie) : Pure trie
(requires (sorted ts /\ List.Tot.length ts > 0))
(ensures (fun t ->
((List.Tot.length ts > 1 \/ existsb Node? ts) ==> Node? t)))
(decreases (List.Tot.length ts)) =
match ts with
| t1::t2::ts' ->
assert(List.Tot.length ts > 1); (* so it needs to prove Node? t *)
let w = weight t1 + weight t2 in
let t = huffman_trie ((Node w t1 t2) `insert_in_sorted` ts') in
(* by the recursive call we know:
(List.Tot.length (Node w t1 t2 `insert_in_sorted` ts') > 1
\/ existsb Node? (Node w t1 t2 `insert_in_sorted` ts') ==> Node? t) *)
(* Since ts' could be empty, I thought that the only way we can
use this is by proving: existsb Node? (Node w t1 t2
`insert_in_sorted` ts'), which requires induction. But F* was smarter! *)
if Nil? ts' then
assert(existsb Node? (Node w t1 t2 `insert_in_sorted` ts'))
else
assert(length (Node w t1 t2 `insert_in_sorted` ts') > 1);
assert(Node? t);
t
| [t1] -> t1 (* this uses `existsb Node? [t] ==> Node? t` fact *)
let huffman (sws:list (symbol*pos)) : Pure trie
(requires (b2t (List.Tot.length sws > 0)))
(ensures (fun t -> List.Tot.length sws > 1 ==> Node? t)) =
huffman_trie (insertion_sort (List.Tot.map (fun (s,w) -> Leaf w s) sws))
let rec encode_one (t:trie) (s:symbol) : Tot (option (list bool)) =
match t with
| Leaf _ s' -> if s = s' then Some [] else None
| Node _ t1 t2 ->
match encode_one t1 s with
| Some bs -> Some (false :: bs)
| None -> match encode_one t2 s with
| Some bs -> Some (true :: bs)
| None -> None
// Modulo the option this is flatten (map (encode_one t) ss)
let rec encode (t:trie) (ss:list symbol) : Pure (option (list bool))
(requires (True))
(ensures (fun bs -> Node? t /\ Cons? ss /\ Some? bs
==> Cons? (Some?.v bs))) =
match ss with
| [] -> None (* can't encode the empty string *)
| [s] -> encode_one t s
| s::ss' -> match encode_one t s, encode t ss' with
| Some bs, Some bs' -> Some (bs @ bs')
| _, _ -> None
// A more complex decode I originally wrote
let rec decode_one (t:trie) (bs:list bool) : Pure (option (symbol * list bool))
(requires (True))
(ensures (fun r -> Some? r ==>
(List.Tot.length (snd (Some?.v r)) <= List.Tot.length bs /\
(Node? t ==> List.Tot.length (snd (Some?.v r)) < List.Tot.length bs)))) =
match t, bs with
| Node _ t1 t2, b::bs' -> decode_one (if b then t2 else t1) bs'
| Leaf _ s, _ -> Some (s, bs)
| Node _ _ _, [] -> None (* out of symbols *)
let rec decode' (t:trie) (bs:list bool) : Tot (option (list symbol))
(decreases (List.Tot.length bs)) =
match t, bs with
| Leaf _ s, [] -> Some [s] (* degenerate case, case omitted below *)
| Leaf _ _, _::_ -> None (* too many symbols, case omitted below *)
| Node _ _ _, [] -> Some []
| Node _ _ _, _::_ -> match decode_one t bs with
| Some (s, bs') -> (match decode' t bs' with
| Some ss -> Some (s :: ss)
| None -> None)
| _ -> None
// Simplified decode using idea from Bird and Wadler's book
// (it has more complex termination condition though)
let rec decode_aux (t':trie{Node? t'}) (t:trie) (bs:list bool) :
Pure (option (list symbol))
(requires (True))
(ensures (fun ss -> Some? ss ==> List.Tot.length (Some?.v ss) > 0))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0]))
=
match t, bs with
| Leaf _ s, [] -> Some [s]
| Leaf _ s, _::_ -> (match decode_aux t' t' bs with
| Some ss -> Some (s :: ss)
| None -> None)
| Node _ t1 t2, b :: bs' -> decode_aux t' (if b then t2 else t1) bs'
| Node _ _ _, [] -> None
let decode (t:trie) (bs:list bool) : Pure (option (list symbol))
(requires (b2t (Node? t))) (ensures (fun _ -> True)) =
decode_aux t t bs
let rec cancelation_one (t':trie) (t:trie) (s:symbol) : Lemma
(requires (b2t (Node? t')))
(ensures (Node? t' ==>
(match encode_one t s with
| Some e -> (match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True))) (decreases t) =
match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s)
let rec decode_prefix_aux (t':trie{Node? t'}) (t:trie)
(bs:list bool) (bs':list bool) (s:symbol) : Lemma
(requires (decode_aux t' t bs = Some [s]))
(ensures (Cons? bs' ==> decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0])) =
match t, bs with
| Leaf _ _, [] -> ()
| Leaf _ _, _::_ -> decode_prefix_aux t' t' bs bs' s
| Node _ t1 t2, b::bs'' ->
decode_prefix_aux t' (if b then t2 else t1) bs'' bs' s
let rec decode_prefix (t:trie{Node? t})
(bs:list bool) (bs':list bool{Cons? bs'}) (s:symbol) : Lemma
(requires (decode t bs = Some [s]))
(ensures (decode t (bs @ bs') = (match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) =
decode_prefix_aux t t bs bs' s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "Huffman.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"short_module": null
},
{
"abbrev": 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: Huffman.trie{Node? t} -> ss: Prims.list Huffman.symbol
-> FStar.Pervasives.Lemma
(ensures
((match Huffman.encode t ss with
| FStar.Pervasives.Native.Some #_ e ->
(match Huffman.decode t e with
| FStar.Pervasives.Native.Some #_ d -> d = ss
| FStar.Pervasives.Native.None #_ -> Prims.l_False)
<:
Type0
| FStar.Pervasives.Native.None #_ -> Prims.l_True)
<:
Type0)) (decreases ss) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Huffman.trie",
"Prims.b2t",
"Huffman.uu___is_Node",
"Prims.list",
"Huffman.symbol",
"Huffman.cancelation_one",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.option",
"Prims.bool",
"Huffman.encode_one",
"Huffman.encode",
"Huffman.decode_prefix",
"Prims.unit",
"Huffman.cancelation_aux",
"Prims.l_True",
"Prims.squash",
"Huffman.decode",
"Prims.op_Equality",
"Prims.l_False",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec cancelation_aux (t: trie{Node? t}) (ss: list symbol)
: Lemma (requires (True))
(ensures
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True))
(decreases ss) =
| match ss with
| [] -> ()
| [s] -> cancelation_one t t s
| s :: ss' ->
cancelation_one t t s;
cancelation_aux t ss';
(match encode_one t s, encode t ss' with
| Some bs, Some bs' -> decode_prefix t bs bs' s
| _, _ -> ()) | false |
StatefulLens.fst | StatefulLens.v | val v : StatefulLens.stlens StatefulLens.hlens_ref | let v #a = stlens_ref #a | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 141,
"start_col": 0,
"start_line": 141
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | StatefulLens.stlens StatefulLens.hlens_ref | Prims.Tot | [
"total"
] | [] | [
"StatefulLens.stlens_ref",
"StatefulLens.stlens",
"FStar.ST.ref",
"StatefulLens.hlens_ref"
] | [] | false | false | false | true | false | let v #a =
| stlens_ref #a | false |
|
Huffman.fst | Huffman.cancelation | val cancelation (sws: list (symbol * pos)) (ss: list symbol)
: Lemma (requires (b2t (List.Tot.length sws > 1)))
(ensures
(List.Tot.length sws > 1 ==>
(let t = huffman sws in
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)))) | val cancelation (sws: list (symbol * pos)) (ss: list symbol)
: Lemma (requires (b2t (List.Tot.length sws > 1)))
(ensures
(List.Tot.length sws > 1 ==>
(let t = huffman sws in
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)))) | let rec cancelation (sws:list (symbol*pos)) (ss:list symbol) : Lemma
(requires (b2t (List.Tot.length sws > 1)))
(ensures (List.Tot.length sws > 1 ==>
(let t = huffman sws in
(match encode t ss with
| Some e -> (match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)))) =
cancelation_aux (huffman sws) ss | {
"file_name": "examples/algorithms/Huffman.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 34,
"end_line": 234,
"start_col": 0,
"start_line": 225
} | (*
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 Huffman
open FStar.Char
open FStar.List.Tot
type symbol = char
// could consider moving weights away from the nodes,
// only need one weight per each trie in the forest
type trie =
| Leaf : w:pos -> s:symbol -> trie
| Node : w:pos -> l:trie -> r:trie -> trie
let weight (t:trie) : Tot pos =
match t with
| Leaf w _ -> w
| Node w _ _ -> w
let leq_trie (t1:trie) (t2:trie) : Tot bool =
weight t1 <= weight t2
(* Copied and adapted some part about sorted int lists,
this should really be generic in the library *)
let rec sorted (ts:list trie) : Tot bool =
match ts with
| [] | [_] -> true
| t1::t2::ts' -> leq_trie t1 t2 && sorted (t2::ts')
type permutation (l1:list trie) (l2:list trie) =
length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
val sorted_smaller: x:trie
-> y:trie
-> l:list trie
-> Lemma (requires (sorted (x::l) /\ mem y l))
(ensures (leq_trie x y))
[SMTPat (sorted (x::l)); SMTPat (mem y l)]
let rec sorted_smaller x y l = match l with
| [] -> ()
| z::zs -> if z=y then () else sorted_smaller x y zs
let rec insert_in_sorted (x:trie) (xs:list trie) : Pure (list trie)
(requires (b2t (sorted xs)))
(ensures (fun ys -> sorted ys /\ permutation (x::xs) ys)) =
match xs with
| [] -> [x]
| x'::xs' -> if leq_trie x x' then x :: xs
else (let i_tl = insert_in_sorted x xs' in
let (z::_) = i_tl in (* <-- needed for triggering patterns? *)
x' :: i_tl)
let rec insertion_sort (ts : list trie) : Pure (list trie)
(requires (True)) (ensures (fun ts' -> sorted ts' /\ permutation ts ts')) =
match ts with
| [] -> []
| t::ts' -> insert_in_sorted t (insertion_sort ts')
let rec huffman_trie (ts:list trie) : Pure trie
(requires (sorted ts /\ List.Tot.length ts > 0))
(ensures (fun t ->
((List.Tot.length ts > 1 \/ existsb Node? ts) ==> Node? t)))
(decreases (List.Tot.length ts)) =
match ts with
| t1::t2::ts' ->
assert(List.Tot.length ts > 1); (* so it needs to prove Node? t *)
let w = weight t1 + weight t2 in
let t = huffman_trie ((Node w t1 t2) `insert_in_sorted` ts') in
(* by the recursive call we know:
(List.Tot.length (Node w t1 t2 `insert_in_sorted` ts') > 1
\/ existsb Node? (Node w t1 t2 `insert_in_sorted` ts') ==> Node? t) *)
(* Since ts' could be empty, I thought that the only way we can
use this is by proving: existsb Node? (Node w t1 t2
`insert_in_sorted` ts'), which requires induction. But F* was smarter! *)
if Nil? ts' then
assert(existsb Node? (Node w t1 t2 `insert_in_sorted` ts'))
else
assert(length (Node w t1 t2 `insert_in_sorted` ts') > 1);
assert(Node? t);
t
| [t1] -> t1 (* this uses `existsb Node? [t] ==> Node? t` fact *)
let huffman (sws:list (symbol*pos)) : Pure trie
(requires (b2t (List.Tot.length sws > 0)))
(ensures (fun t -> List.Tot.length sws > 1 ==> Node? t)) =
huffman_trie (insertion_sort (List.Tot.map (fun (s,w) -> Leaf w s) sws))
let rec encode_one (t:trie) (s:symbol) : Tot (option (list bool)) =
match t with
| Leaf _ s' -> if s = s' then Some [] else None
| Node _ t1 t2 ->
match encode_one t1 s with
| Some bs -> Some (false :: bs)
| None -> match encode_one t2 s with
| Some bs -> Some (true :: bs)
| None -> None
// Modulo the option this is flatten (map (encode_one t) ss)
let rec encode (t:trie) (ss:list symbol) : Pure (option (list bool))
(requires (True))
(ensures (fun bs -> Node? t /\ Cons? ss /\ Some? bs
==> Cons? (Some?.v bs))) =
match ss with
| [] -> None (* can't encode the empty string *)
| [s] -> encode_one t s
| s::ss' -> match encode_one t s, encode t ss' with
| Some bs, Some bs' -> Some (bs @ bs')
| _, _ -> None
// A more complex decode I originally wrote
let rec decode_one (t:trie) (bs:list bool) : Pure (option (symbol * list bool))
(requires (True))
(ensures (fun r -> Some? r ==>
(List.Tot.length (snd (Some?.v r)) <= List.Tot.length bs /\
(Node? t ==> List.Tot.length (snd (Some?.v r)) < List.Tot.length bs)))) =
match t, bs with
| Node _ t1 t2, b::bs' -> decode_one (if b then t2 else t1) bs'
| Leaf _ s, _ -> Some (s, bs)
| Node _ _ _, [] -> None (* out of symbols *)
let rec decode' (t:trie) (bs:list bool) : Tot (option (list symbol))
(decreases (List.Tot.length bs)) =
match t, bs with
| Leaf _ s, [] -> Some [s] (* degenerate case, case omitted below *)
| Leaf _ _, _::_ -> None (* too many symbols, case omitted below *)
| Node _ _ _, [] -> Some []
| Node _ _ _, _::_ -> match decode_one t bs with
| Some (s, bs') -> (match decode' t bs' with
| Some ss -> Some (s :: ss)
| None -> None)
| _ -> None
// Simplified decode using idea from Bird and Wadler's book
// (it has more complex termination condition though)
let rec decode_aux (t':trie{Node? t'}) (t:trie) (bs:list bool) :
Pure (option (list symbol))
(requires (True))
(ensures (fun ss -> Some? ss ==> List.Tot.length (Some?.v ss) > 0))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0]))
=
match t, bs with
| Leaf _ s, [] -> Some [s]
| Leaf _ s, _::_ -> (match decode_aux t' t' bs with
| Some ss -> Some (s :: ss)
| None -> None)
| Node _ t1 t2, b :: bs' -> decode_aux t' (if b then t2 else t1) bs'
| Node _ _ _, [] -> None
let decode (t:trie) (bs:list bool) : Pure (option (list symbol))
(requires (b2t (Node? t))) (ensures (fun _ -> True)) =
decode_aux t t bs
let rec cancelation_one (t':trie) (t:trie) (s:symbol) : Lemma
(requires (b2t (Node? t')))
(ensures (Node? t' ==>
(match encode_one t s with
| Some e -> (match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True))) (decreases t) =
match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s)
let rec decode_prefix_aux (t':trie{Node? t'}) (t:trie)
(bs:list bool) (bs':list bool) (s:symbol) : Lemma
(requires (decode_aux t' t bs = Some [s]))
(ensures (Cons? bs' ==> decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0])) =
match t, bs with
| Leaf _ _, [] -> ()
| Leaf _ _, _::_ -> decode_prefix_aux t' t' bs bs' s
| Node _ t1 t2, b::bs'' ->
decode_prefix_aux t' (if b then t2 else t1) bs'' bs' s
let rec decode_prefix (t:trie{Node? t})
(bs:list bool) (bs':list bool{Cons? bs'}) (s:symbol) : Lemma
(requires (decode t bs = Some [s]))
(ensures (decode t (bs @ bs') = (match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) =
decode_prefix_aux t t bs bs' s
let rec cancelation_aux (t:trie{Node? t}) (ss:list symbol) : Lemma
(requires (True))
(ensures (match encode t ss with
| Some e -> (match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)) (decreases ss) =
match ss with
| [] -> ()
| [s] -> cancelation_one t t s
| s::ss' ->
cancelation_one t t s;
cancelation_aux t ss';
(match encode_one t s, encode t ss' with
| Some bs, Some bs' -> decode_prefix t bs bs' s
| _, _ -> ()) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "Huffman.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"short_module": null
},
{
"abbrev": 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 | sws: Prims.list (Huffman.symbol * Prims.pos) -> ss: Prims.list Huffman.symbol
-> FStar.Pervasives.Lemma (requires FStar.List.Tot.Base.length sws > 1)
(ensures
FStar.List.Tot.Base.length sws > 1 ==>
(let t = Huffman.huffman sws in
(match Huffman.encode t ss with
| FStar.Pervasives.Native.Some #_ e ->
(match Huffman.decode t e with
| FStar.Pervasives.Native.Some #_ d -> d = ss
| FStar.Pervasives.Native.None #_ -> Prims.l_False)
<:
Prims.logical
| FStar.Pervasives.Native.None #_ -> Prims.l_True)
<:
Prims.logical)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"FStar.Pervasives.Native.tuple2",
"Huffman.symbol",
"Prims.pos",
"Huffman.cancelation_aux",
"Huffman.huffman",
"Prims.unit",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.List.Tot.Base.length",
"Prims.squash",
"Prims.l_imp",
"Huffman.encode",
"Prims.bool",
"Huffman.decode",
"Prims.op_Equality",
"Prims.l_False",
"Prims.logical",
"Prims.l_True",
"Huffman.trie",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec cancelation (sws: list (symbol * pos)) (ss: list symbol)
: Lemma (requires (b2t (List.Tot.length sws > 1)))
(ensures
(List.Tot.length sws > 1 ==>
(let t = huffman sws in
(match encode t ss with
| Some e ->
(match decode t e with
| Some d -> d = ss
| None -> False)
| None -> True)))) =
| cancelation_aux (huffman sws) ss | false |
Huffman.fst | Huffman.decode_prefix | val decode_prefix (t: trie{Node? t}) (bs: list bool) (bs': list bool {Cons? bs'}) (s: symbol)
: Lemma (requires (decode t bs = Some [s]))
(ensures
(decode t (bs @ bs') =
(match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) | val decode_prefix (t: trie{Node? t}) (bs: list bool) (bs': list bool {Cons? bs'}) (s: symbol)
: Lemma (requires (decode t bs = Some [s]))
(ensures
(decode t (bs @ bs') =
(match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) | let rec decode_prefix (t:trie{Node? t})
(bs:list bool) (bs':list bool{Cons? bs'}) (s:symbol) : Lemma
(requires (decode t bs = Some [s]))
(ensures (decode t (bs @ bs') = (match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) =
decode_prefix_aux t t bs bs' s | {
"file_name": "examples/algorithms/Huffman.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 206,
"start_col": 0,
"start_line": 200
} | (*
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 Huffman
open FStar.Char
open FStar.List.Tot
type symbol = char
// could consider moving weights away from the nodes,
// only need one weight per each trie in the forest
type trie =
| Leaf : w:pos -> s:symbol -> trie
| Node : w:pos -> l:trie -> r:trie -> trie
let weight (t:trie) : Tot pos =
match t with
| Leaf w _ -> w
| Node w _ _ -> w
let leq_trie (t1:trie) (t2:trie) : Tot bool =
weight t1 <= weight t2
(* Copied and adapted some part about sorted int lists,
this should really be generic in the library *)
let rec sorted (ts:list trie) : Tot bool =
match ts with
| [] | [_] -> true
| t1::t2::ts' -> leq_trie t1 t2 && sorted (t2::ts')
type permutation (l1:list trie) (l2:list trie) =
length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
val sorted_smaller: x:trie
-> y:trie
-> l:list trie
-> Lemma (requires (sorted (x::l) /\ mem y l))
(ensures (leq_trie x y))
[SMTPat (sorted (x::l)); SMTPat (mem y l)]
let rec sorted_smaller x y l = match l with
| [] -> ()
| z::zs -> if z=y then () else sorted_smaller x y zs
let rec insert_in_sorted (x:trie) (xs:list trie) : Pure (list trie)
(requires (b2t (sorted xs)))
(ensures (fun ys -> sorted ys /\ permutation (x::xs) ys)) =
match xs with
| [] -> [x]
| x'::xs' -> if leq_trie x x' then x :: xs
else (let i_tl = insert_in_sorted x xs' in
let (z::_) = i_tl in (* <-- needed for triggering patterns? *)
x' :: i_tl)
let rec insertion_sort (ts : list trie) : Pure (list trie)
(requires (True)) (ensures (fun ts' -> sorted ts' /\ permutation ts ts')) =
match ts with
| [] -> []
| t::ts' -> insert_in_sorted t (insertion_sort ts')
let rec huffman_trie (ts:list trie) : Pure trie
(requires (sorted ts /\ List.Tot.length ts > 0))
(ensures (fun t ->
((List.Tot.length ts > 1 \/ existsb Node? ts) ==> Node? t)))
(decreases (List.Tot.length ts)) =
match ts with
| t1::t2::ts' ->
assert(List.Tot.length ts > 1); (* so it needs to prove Node? t *)
let w = weight t1 + weight t2 in
let t = huffman_trie ((Node w t1 t2) `insert_in_sorted` ts') in
(* by the recursive call we know:
(List.Tot.length (Node w t1 t2 `insert_in_sorted` ts') > 1
\/ existsb Node? (Node w t1 t2 `insert_in_sorted` ts') ==> Node? t) *)
(* Since ts' could be empty, I thought that the only way we can
use this is by proving: existsb Node? (Node w t1 t2
`insert_in_sorted` ts'), which requires induction. But F* was smarter! *)
if Nil? ts' then
assert(existsb Node? (Node w t1 t2 `insert_in_sorted` ts'))
else
assert(length (Node w t1 t2 `insert_in_sorted` ts') > 1);
assert(Node? t);
t
| [t1] -> t1 (* this uses `existsb Node? [t] ==> Node? t` fact *)
let huffman (sws:list (symbol*pos)) : Pure trie
(requires (b2t (List.Tot.length sws > 0)))
(ensures (fun t -> List.Tot.length sws > 1 ==> Node? t)) =
huffman_trie (insertion_sort (List.Tot.map (fun (s,w) -> Leaf w s) sws))
let rec encode_one (t:trie) (s:symbol) : Tot (option (list bool)) =
match t with
| Leaf _ s' -> if s = s' then Some [] else None
| Node _ t1 t2 ->
match encode_one t1 s with
| Some bs -> Some (false :: bs)
| None -> match encode_one t2 s with
| Some bs -> Some (true :: bs)
| None -> None
// Modulo the option this is flatten (map (encode_one t) ss)
let rec encode (t:trie) (ss:list symbol) : Pure (option (list bool))
(requires (True))
(ensures (fun bs -> Node? t /\ Cons? ss /\ Some? bs
==> Cons? (Some?.v bs))) =
match ss with
| [] -> None (* can't encode the empty string *)
| [s] -> encode_one t s
| s::ss' -> match encode_one t s, encode t ss' with
| Some bs, Some bs' -> Some (bs @ bs')
| _, _ -> None
// A more complex decode I originally wrote
let rec decode_one (t:trie) (bs:list bool) : Pure (option (symbol * list bool))
(requires (True))
(ensures (fun r -> Some? r ==>
(List.Tot.length (snd (Some?.v r)) <= List.Tot.length bs /\
(Node? t ==> List.Tot.length (snd (Some?.v r)) < List.Tot.length bs)))) =
match t, bs with
| Node _ t1 t2, b::bs' -> decode_one (if b then t2 else t1) bs'
| Leaf _ s, _ -> Some (s, bs)
| Node _ _ _, [] -> None (* out of symbols *)
let rec decode' (t:trie) (bs:list bool) : Tot (option (list symbol))
(decreases (List.Tot.length bs)) =
match t, bs with
| Leaf _ s, [] -> Some [s] (* degenerate case, case omitted below *)
| Leaf _ _, _::_ -> None (* too many symbols, case omitted below *)
| Node _ _ _, [] -> Some []
| Node _ _ _, _::_ -> match decode_one t bs with
| Some (s, bs') -> (match decode' t bs' with
| Some ss -> Some (s :: ss)
| None -> None)
| _ -> None
// Simplified decode using idea from Bird and Wadler's book
// (it has more complex termination condition though)
let rec decode_aux (t':trie{Node? t'}) (t:trie) (bs:list bool) :
Pure (option (list symbol))
(requires (True))
(ensures (fun ss -> Some? ss ==> List.Tot.length (Some?.v ss) > 0))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0]))
=
match t, bs with
| Leaf _ s, [] -> Some [s]
| Leaf _ s, _::_ -> (match decode_aux t' t' bs with
| Some ss -> Some (s :: ss)
| None -> None)
| Node _ t1 t2, b :: bs' -> decode_aux t' (if b then t2 else t1) bs'
| Node _ _ _, [] -> None
let decode (t:trie) (bs:list bool) : Pure (option (list symbol))
(requires (b2t (Node? t))) (ensures (fun _ -> True)) =
decode_aux t t bs
let rec cancelation_one (t':trie) (t:trie) (s:symbol) : Lemma
(requires (b2t (Node? t')))
(ensures (Node? t' ==>
(match encode_one t s with
| Some e -> (match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True))) (decreases t) =
match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s)
let rec decode_prefix_aux (t':trie{Node? t'}) (t:trie)
(bs:list bool) (bs':list bool) (s:symbol) : Lemma
(requires (decode_aux t' t bs = Some [s]))
(ensures (Cons? bs' ==> decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0])) =
match t, bs with
| Leaf _ _, [] -> ()
| Leaf _ _, _::_ -> decode_prefix_aux t' t' bs bs' s
| Node _ t1 t2, b::bs'' ->
decode_prefix_aux t' (if b then t2 else t1) bs'' bs' s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "Huffman.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"short_module": null
},
{
"abbrev": 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: Huffman.trie{Node? t} ->
bs: Prims.list Prims.bool ->
bs': Prims.list Prims.bool {Cons? bs'} ->
s: Huffman.symbol
-> FStar.Pervasives.Lemma (requires Huffman.decode t bs = FStar.Pervasives.Native.Some [s])
(ensures
Huffman.decode t (bs @ bs') =
(match Huffman.decode t bs' with
| FStar.Pervasives.Native.Some #_ ss -> FStar.Pervasives.Native.Some (s :: ss)
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Huffman.trie",
"Prims.b2t",
"Huffman.uu___is_Node",
"Prims.list",
"Prims.bool",
"Prims.uu___is_Cons",
"Huffman.symbol",
"Huffman.decode_prefix_aux",
"Prims.unit",
"Prims.op_Equality",
"FStar.Pervasives.Native.option",
"Huffman.decode",
"FStar.Pervasives.Native.Some",
"Prims.Cons",
"Prims.Nil",
"Prims.squash",
"FStar.List.Tot.Base.op_At",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec decode_prefix (t: trie{Node? t}) (bs: list bool) (bs': list bool {Cons? bs'}) (s: symbol)
: Lemma (requires (decode t bs = Some [s]))
(ensures
(decode t (bs @ bs') =
(match decode t bs' with
| Some ss -> Some (s :: ss)
| None -> None))) =
| decode_prefix_aux t t bs bs' s | false |
StatefulLens.fst | StatefulLens.deref | val deref : StatefulLens.stlens StatefulLens.hlens_ref | let deref = v | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 142,
"start_col": 0,
"start_line": 142
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | StatefulLens.stlens StatefulLens.hlens_ref | Prims.Tot | [
"total"
] | [] | [
"StatefulLens.v",
"StatefulLens.stlens",
"FStar.ST.ref",
"StatefulLens.hlens_ref"
] | [] | false | false | false | true | false | let deref =
| v | false |
|
StatefulLens.fst | StatefulLens.compose_stlens | val compose_stlens (#a #b #c: _) (#l: hlens a b) (#m: hlens b c) (sl: stlens l) (sm: stlens m)
: stlens (compose_hlens l m) | val compose_stlens (#a #b #c: _) (#l: hlens a b) (#m: hlens b c) (sl: stlens l) (sm: stlens m)
: stlens (compose_hlens l m) | let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
} | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 74,
"start_col": 0,
"start_line": 69
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | sl: StatefulLens.stlens l -> sm: StatefulLens.stlens m
-> StatefulLens.stlens (StatefulLens.compose_hlens l m) | Prims.Tot | [
"total"
] | [] | [
"StatefulLens.hlens",
"StatefulLens.stlens",
"StatefulLens.Mkstlens",
"StatefulLens.compose_hlens",
"StatefulLens.__proj__Mkstlens__item__st_get",
"StatefulLens.__proj__Mkstlens__item__st_put"
] | [] | false | false | false | false | false | let compose_stlens #a #b #c (#l: hlens a b) (#m: hlens b c) (sl: stlens l) (sm: stlens m)
: stlens (compose_hlens l m) =
| {
st_get = (fun (x: a) -> sm.st_get (sl.st_get x));
st_put = (fun (z: c) (x: a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
} | false |
SealedModel.fst | SealedModel.map_seal | val map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b) | val map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b) | let map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b)
=
Seal (fun () -> f (unseal s)) | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 58,
"start_col": 0,
"start_line": 52
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g
let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x)
let unseal (#a : Type u#aa) (s : sealed a) : TacS a =
let Seal f = s in
f ()
(* NOTE: there is nothing saying the value of type `a`
that the function receives precedes s, or anything | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": 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: Type -> s: SealedModel.sealed a -> f: (_: a -> FStar.Tactics.Effect.TacS b)
-> SealedModel.sealed b | Prims.Tot | [
"total"
] | [] | [
"SealedModel.sealed",
"SealedModel.Seal",
"Prims.unit",
"SealedModel.unseal"
] | [] | false | false | false | false | false | let map_seal (#a: Type u#aa) (b: Type u#bb) (s: sealed a) (f: (a -> TacS b)) : Tot (sealed b) =
| Seal (fun () -> f (unseal s)) | false |
StatefulLens.fst | StatefulLens.test3 | val test3 : c: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST Prims.int | let test3 (c:ref (ref int)) = c.[v |.. v] | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 145,
"start_col": 0,
"start_line": 145
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST Prims.int | FStar.ST.ST | [] | [] | [
"FStar.ST.ref",
"Prims.int",
"StatefulLens.op_String_Access",
"StatefulLens.compose_hlens",
"StatefulLens.hlens_ref",
"StatefulLens.op_Bar_Dot_Dot",
"StatefulLens.v"
] | [] | false | true | false | false | false | let test3 (c: ref (ref int)) =
| c.[ v |.. v ] | false |
|
Huffman.fst | Huffman.decode_prefix_aux | val decode_prefix_aux (t': trie{Node? t'}) (t: trie) (bs bs': list bool) (s: symbol)
: Lemma (requires (decode_aux t' t bs = Some [s]))
(ensures
(Cons? bs' ==>
decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs;if Leaf? t && Cons? bs then 1 else 0])) | val decode_prefix_aux (t': trie{Node? t'}) (t: trie) (bs bs': list bool) (s: symbol)
: Lemma (requires (decode_aux t' t bs = Some [s]))
(ensures
(Cons? bs' ==>
decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs;if Leaf? t && Cons? bs then 1 else 0])) | let rec decode_prefix_aux (t':trie{Node? t'}) (t:trie)
(bs:list bool) (bs':list bool) (s:symbol) : Lemma
(requires (decode_aux t' t bs = Some [s]))
(ensures (Cons? bs' ==> decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0])) =
match t, bs with
| Leaf _ _, [] -> ()
| Leaf _ _, _::_ -> decode_prefix_aux t' t' bs bs' s
| Node _ t1 t2, b::bs'' ->
decode_prefix_aux t' (if b then t2 else t1) bs'' bs' s | {
"file_name": "examples/algorithms/Huffman.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 60,
"end_line": 198,
"start_col": 0,
"start_line": 186
} | (*
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 Huffman
open FStar.Char
open FStar.List.Tot
type symbol = char
// could consider moving weights away from the nodes,
// only need one weight per each trie in the forest
type trie =
| Leaf : w:pos -> s:symbol -> trie
| Node : w:pos -> l:trie -> r:trie -> trie
let weight (t:trie) : Tot pos =
match t with
| Leaf w _ -> w
| Node w _ _ -> w
let leq_trie (t1:trie) (t2:trie) : Tot bool =
weight t1 <= weight t2
(* Copied and adapted some part about sorted int lists,
this should really be generic in the library *)
let rec sorted (ts:list trie) : Tot bool =
match ts with
| [] | [_] -> true
| t1::t2::ts' -> leq_trie t1 t2 && sorted (t2::ts')
type permutation (l1:list trie) (l2:list trie) =
length l1 = length l2 /\ (forall n. mem n l1 = mem n l2)
val sorted_smaller: x:trie
-> y:trie
-> l:list trie
-> Lemma (requires (sorted (x::l) /\ mem y l))
(ensures (leq_trie x y))
[SMTPat (sorted (x::l)); SMTPat (mem y l)]
let rec sorted_smaller x y l = match l with
| [] -> ()
| z::zs -> if z=y then () else sorted_smaller x y zs
let rec insert_in_sorted (x:trie) (xs:list trie) : Pure (list trie)
(requires (b2t (sorted xs)))
(ensures (fun ys -> sorted ys /\ permutation (x::xs) ys)) =
match xs with
| [] -> [x]
| x'::xs' -> if leq_trie x x' then x :: xs
else (let i_tl = insert_in_sorted x xs' in
let (z::_) = i_tl in (* <-- needed for triggering patterns? *)
x' :: i_tl)
let rec insertion_sort (ts : list trie) : Pure (list trie)
(requires (True)) (ensures (fun ts' -> sorted ts' /\ permutation ts ts')) =
match ts with
| [] -> []
| t::ts' -> insert_in_sorted t (insertion_sort ts')
let rec huffman_trie (ts:list trie) : Pure trie
(requires (sorted ts /\ List.Tot.length ts > 0))
(ensures (fun t ->
((List.Tot.length ts > 1 \/ existsb Node? ts) ==> Node? t)))
(decreases (List.Tot.length ts)) =
match ts with
| t1::t2::ts' ->
assert(List.Tot.length ts > 1); (* so it needs to prove Node? t *)
let w = weight t1 + weight t2 in
let t = huffman_trie ((Node w t1 t2) `insert_in_sorted` ts') in
(* by the recursive call we know:
(List.Tot.length (Node w t1 t2 `insert_in_sorted` ts') > 1
\/ existsb Node? (Node w t1 t2 `insert_in_sorted` ts') ==> Node? t) *)
(* Since ts' could be empty, I thought that the only way we can
use this is by proving: existsb Node? (Node w t1 t2
`insert_in_sorted` ts'), which requires induction. But F* was smarter! *)
if Nil? ts' then
assert(existsb Node? (Node w t1 t2 `insert_in_sorted` ts'))
else
assert(length (Node w t1 t2 `insert_in_sorted` ts') > 1);
assert(Node? t);
t
| [t1] -> t1 (* this uses `existsb Node? [t] ==> Node? t` fact *)
let huffman (sws:list (symbol*pos)) : Pure trie
(requires (b2t (List.Tot.length sws > 0)))
(ensures (fun t -> List.Tot.length sws > 1 ==> Node? t)) =
huffman_trie (insertion_sort (List.Tot.map (fun (s,w) -> Leaf w s) sws))
let rec encode_one (t:trie) (s:symbol) : Tot (option (list bool)) =
match t with
| Leaf _ s' -> if s = s' then Some [] else None
| Node _ t1 t2 ->
match encode_one t1 s with
| Some bs -> Some (false :: bs)
| None -> match encode_one t2 s with
| Some bs -> Some (true :: bs)
| None -> None
// Modulo the option this is flatten (map (encode_one t) ss)
let rec encode (t:trie) (ss:list symbol) : Pure (option (list bool))
(requires (True))
(ensures (fun bs -> Node? t /\ Cons? ss /\ Some? bs
==> Cons? (Some?.v bs))) =
match ss with
| [] -> None (* can't encode the empty string *)
| [s] -> encode_one t s
| s::ss' -> match encode_one t s, encode t ss' with
| Some bs, Some bs' -> Some (bs @ bs')
| _, _ -> None
// A more complex decode I originally wrote
let rec decode_one (t:trie) (bs:list bool) : Pure (option (symbol * list bool))
(requires (True))
(ensures (fun r -> Some? r ==>
(List.Tot.length (snd (Some?.v r)) <= List.Tot.length bs /\
(Node? t ==> List.Tot.length (snd (Some?.v r)) < List.Tot.length bs)))) =
match t, bs with
| Node _ t1 t2, b::bs' -> decode_one (if b then t2 else t1) bs'
| Leaf _ s, _ -> Some (s, bs)
| Node _ _ _, [] -> None (* out of symbols *)
let rec decode' (t:trie) (bs:list bool) : Tot (option (list symbol))
(decreases (List.Tot.length bs)) =
match t, bs with
| Leaf _ s, [] -> Some [s] (* degenerate case, case omitted below *)
| Leaf _ _, _::_ -> None (* too many symbols, case omitted below *)
| Node _ _ _, [] -> Some []
| Node _ _ _, _::_ -> match decode_one t bs with
| Some (s, bs') -> (match decode' t bs' with
| Some ss -> Some (s :: ss)
| None -> None)
| _ -> None
// Simplified decode using idea from Bird and Wadler's book
// (it has more complex termination condition though)
let rec decode_aux (t':trie{Node? t'}) (t:trie) (bs:list bool) :
Pure (option (list symbol))
(requires (True))
(ensures (fun ss -> Some? ss ==> List.Tot.length (Some?.v ss) > 0))
(decreases (%[bs; if Leaf? t && Cons? bs then 1 else 0]))
=
match t, bs with
| Leaf _ s, [] -> Some [s]
| Leaf _ s, _::_ -> (match decode_aux t' t' bs with
| Some ss -> Some (s :: ss)
| None -> None)
| Node _ t1 t2, b :: bs' -> decode_aux t' (if b then t2 else t1) bs'
| Node _ _ _, [] -> None
let decode (t:trie) (bs:list bool) : Pure (option (list symbol))
(requires (b2t (Node? t))) (ensures (fun _ -> True)) =
decode_aux t t bs
let rec cancelation_one (t':trie) (t:trie) (s:symbol) : Lemma
(requires (b2t (Node? t')))
(ensures (Node? t' ==>
(match encode_one t s with
| Some e -> (match decode_aux t' t e with
| Some d -> d = [s]
| None -> False)
| None -> True))) (decreases t) =
match t with
| Leaf _ s' -> ()
| Node _ t1 t2 ->
(match encode_one t1 s with
| Some e -> cancelation_one t' t1 s
| None -> cancelation_one t' t2 s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Char.fsti.checked"
],
"interface_file": false,
"source_file": "Huffman.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Char",
"short_module": null
},
{
"abbrev": 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': Huffman.trie{Node? t'} ->
t: Huffman.trie ->
bs: Prims.list Prims.bool ->
bs': Prims.list Prims.bool ->
s: Huffman.symbol
-> FStar.Pervasives.Lemma (requires Huffman.decode_aux t' t bs = FStar.Pervasives.Native.Some [s])
(ensures
Cons? bs' ==>
Huffman.decode_aux t' t (bs @ bs') =
(match Huffman.decode_aux t' t' bs' with
| FStar.Pervasives.Native.Some #_ ss -> FStar.Pervasives.Native.Some (s :: ss)
| FStar.Pervasives.Native.None #_ -> FStar.Pervasives.Native.None))
(decreases
%[bs;(match Leaf? t && Cons? bs with
| true -> 1
| _ -> 0)
<:
Prims.int]) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"Huffman.trie",
"Prims.b2t",
"Huffman.uu___is_Node",
"Prims.list",
"Prims.bool",
"Huffman.symbol",
"FStar.Pervasives.Native.Mktuple2",
"Prims.pos",
"Huffman.decode_prefix_aux",
"Prims.unit",
"Prims.op_Equality",
"FStar.Pervasives.Native.option",
"Huffman.decode_aux",
"FStar.Pervasives.Native.Some",
"Prims.Cons",
"Prims.Nil",
"Prims.squash",
"Prims.l_imp",
"Prims.uu___is_Cons",
"FStar.List.Tot.Base.op_At",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.pattern"
] | [
"recursion"
] | false | false | true | false | false | let rec decode_prefix_aux (t': trie{Node? t'}) (t: trie) (bs bs': list bool) (s: symbol)
: Lemma (requires (decode_aux t' t bs = Some [s]))
(ensures
(Cons? bs' ==>
decode_aux t' t (bs @ bs') =
(match decode_aux t' t' bs' with
| Some ss -> Some (s :: ss)
| None -> None)))
(decreases (%[bs;if Leaf? t && Cons? bs then 1 else 0])) =
| match t, bs with
| Leaf _ _, [] -> ()
| Leaf _ _, _ :: _ -> decode_prefix_aux t' t' bs bs' s
| Node _ t1 t2, b :: bs'' -> decode_prefix_aux t' (if b then t2 else t1) bs'' bs' s | false |
StatefulLens.fst | StatefulLens.as_stlens | val as_stlens (l: lens 'a 'b) : stlens (as_hlens l) | val as_stlens (l: lens 'a 'b) : stlens (as_hlens l) | let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
} | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 82,
"start_col": 0,
"start_line": 79
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: Lens.lens 'a 'b -> StatefulLens.stlens (StatefulLens.as_hlens l) | Prims.Tot | [
"total"
] | [] | [
"Lens.lens",
"StatefulLens.Mkstlens",
"StatefulLens.as_hlens",
"Lens.op_String_Access",
"Lens.op_String_Assignment",
"StatefulLens.stlens"
] | [] | false | false | false | false | false | let as_stlens (l: lens 'a 'b) : stlens (as_hlens l) =
| { st_get = (fun (x: 'a) -> x.[ l ]); st_put = (fun (y: 'b) (x: 'a) -> x.[ l ] <- y) } | false |
StatefulLens.fst | StatefulLens.center | val center:lens circle (ref point) | val center:lens circle (ref point) | let center : lens circle (ref point) = {
Lens.get = (fun c -> c.center);
Lens.put = (fun p c -> {c with center = p})
} | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 176,
"start_col": 0,
"start_line": 173
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v]
/// test4: and here's test2 written more compactly
let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v]
/// test5: Finally, here's a deeply nested collection of references and objects
/// It's easy to reach in with a long lens and update one of the innermost fields
let test5 (c:ref (colored (ref (colored (ref circle))))) =
c.[v |... payload |.. v |... payload |.. v |... center |... x] <- 17
////////////////////////////////////////////////////////////////////////////////
// A simple 2d point defined as a pair of integers
noeq
type point = {
x:ref int;
y:ref int;
}
// A circle is a point and a radius
noeq
type circle = {
center: ref point;
radius: ref nat | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | Lens.lens StatefulLens.circle (FStar.ST.ref StatefulLens.point) | Prims.Tot | [
"total"
] | [] | [
"Lens.Mklens",
"StatefulLens.circle",
"FStar.ST.ref",
"StatefulLens.point",
"StatefulLens.__proj__Mkcircle__item__center",
"StatefulLens.Mkcircle",
"StatefulLens.__proj__Mkcircle__item__radius"
] | [] | false | false | false | true | false | let center:lens circle (ref point) =
| { Lens.get = (fun c -> c.center); Lens.put = (fun p c -> { c with center = p }) } | false |
StatefulLens.fst | StatefulLens.x | val x:lens point (ref int) | val x:lens point (ref int) | let x : lens point (ref int) = {
Lens.get = (fun p -> p.x);
Lens.put = (fun x p -> {p with x = x})
} | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 1,
"end_line": 180,
"start_col": 0,
"start_line": 177
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v]
/// test4: and here's test2 written more compactly
let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v]
/// test5: Finally, here's a deeply nested collection of references and objects
/// It's easy to reach in with a long lens and update one of the innermost fields
let test5 (c:ref (colored (ref (colored (ref circle))))) =
c.[v |... payload |.. v |... payload |.. v |... center |... x] <- 17
////////////////////////////////////////////////////////////////////////////////
// A simple 2d point defined as a pair of integers
noeq
type point = {
x:ref int;
y:ref int;
}
// A circle is a point and a radius
noeq
type circle = {
center: ref point;
radius: ref nat
}
let center : lens circle (ref point) = {
Lens.get = (fun c -> c.center);
Lens.put = (fun p c -> {c with center = p}) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | Lens.lens StatefulLens.point (FStar.ST.ref Prims.int) | Prims.Tot | [
"total"
] | [] | [
"Lens.Mklens",
"StatefulLens.point",
"FStar.ST.ref",
"Prims.int",
"StatefulLens.__proj__Mkpoint__item__x",
"StatefulLens.Mkpoint",
"StatefulLens.__proj__Mkpoint__item__y"
] | [] | false | false | false | true | false | let x:lens point (ref int) =
| { Lens.get = (fun p -> p.x); Lens.put = (fun x p -> { p with x = x }) } | false |
SealedModel.fst | SealedModel.bind_seal | val bind_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS (sealed b))
: Tot (sealed b) | val bind_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS (sealed b))
: Tot (sealed b) | let bind_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS (sealed b))
: Tot (sealed b)
=
Seal (fun () -> unseal (f (unseal s))) | {
"file_name": "examples/tactics/SealedModel.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 66,
"start_col": 0,
"start_line": 60
} | (*
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.
Authors: G. Martinez, N. Swamy
*)
module SealedModel
open FStar.Tactics.Effect
noeq
type sealed (a : Type u#aa) =
| Seal of (unit -> TacS a)
(* Note: using TacS which implies the program
never raises an exception. For a real model of
`sealed` it should also not loop, but we can't
specify that here. *)
(* The main axiom in this module: assuming any two functions
at type `unit -> Tac a` are equal. This should be unobservable
in a pure context. *)
assume
val unobs_axiom (#a:Type u#aa) (f g : unit -> Tac a) : Lemma (f == g)
let sealed_singl (#a:Type) (x y : sealed a) : Lemma (x == y) =
let Seal f = x in
let Seal g = y in
unobs_axiom f g
let seal (#a : Type u#aa) (x:a) : Tot (sealed a) =
Seal (fun () -> x)
let unseal (#a : Type u#aa) (s : sealed a) : TacS a =
let Seal f = s in
f ()
(* NOTE: there is nothing saying the value of type `a`
that the function receives precedes s, or anything
similar. See below for what goes wrong if so. *)
let map_seal
(#a : Type u#aa) (b : Type u#bb)
(s : sealed a)
(f : a -> TacS b)
: Tot (sealed b)
=
Seal (fun () -> f (unseal s)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "SealedModel.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.Effect",
"short_module": null
},
{
"abbrev": 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: Type -> s: SealedModel.sealed a -> f: (_: a -> FStar.Tactics.Effect.TacS (SealedModel.sealed b))
-> SealedModel.sealed b | Prims.Tot | [
"total"
] | [] | [
"SealedModel.sealed",
"SealedModel.Seal",
"Prims.unit",
"SealedModel.unseal"
] | [] | false | false | false | false | false | let bind_seal (#a: Type u#aa) (b: Type u#bb) (s: sealed a) (f: (a -> TacS (sealed b)))
: Tot (sealed b) =
| Seal (fun () -> unseal (f (unseal s))) | false |
StatefulLens.fst | StatefulLens.test5 | val test5 : c: FStar.ST.ref (Lens.colored (FStar.ST.ref (Lens.colored (FStar.ST.ref Lens.circle))))
-> FStar.ST.STATE Prims.unit | let test5 (c:ref (colored (ref (colored (ref circle))))) =
c.[v |... payload |.. v |... payload |.. v |... center |... x] <- 17 | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 72,
"end_line": 156,
"start_col": 0,
"start_line": 155
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v]
/// test4: and here's test2 written more compactly
let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v]
/// test5: Finally, here's a deeply nested collection of references and objects | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (Lens.colored (FStar.ST.ref (Lens.colored (FStar.ST.ref Lens.circle))))
-> FStar.ST.STATE Prims.unit | FStar.ST.STATE | [
"trivial_postcondition"
] | [] | [
"FStar.ST.ref",
"Lens.colored",
"Lens.circle",
"StatefulLens.op_String_Assignment",
"Prims.int",
"StatefulLens.compose_hlens",
"Lens.point",
"StatefulLens.hlens_ref",
"StatefulLens.as_hlens",
"Lens.payload",
"Lens.center",
"Lens.x",
"StatefulLens.op_Bar_Dot_Dot_Dot",
"StatefulLens.op_Bar_Dot_Dot",
"StatefulLens.v",
"Prims.unit"
] | [] | false | true | false | false | false | let test5 (c: ref (colored (ref (colored (ref circle))))) =
| c.[ v |... payload |.. v |... payload |.. v |... center |... x ] <- 17 | false |
|
StatefulLens.fst | StatefulLens.test0 | val test0 (c: ref (ref int))
: ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c))) | val test0 (c: ref (ref int))
: ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c))) | let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 105,
"start_col": 0,
"start_line": 102
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference, | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST Prims.int | FStar.ST.ST | [] | [] | [
"FStar.ST.ref",
"Prims.int",
"StatefulLens.__proj__Mkstlens__item__st_get",
"StatefulLens.compose_hlens",
"StatefulLens.hlens_ref",
"StatefulLens.compose_stlens",
"StatefulLens.stlens_ref",
"FStar.Monotonic.Heap.heap",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"FStar.Ref.sel"
] | [] | false | true | false | false | false | let test0 (c: ref (ref int))
: ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c))) =
| (compose_stlens stlens_ref stlens_ref).st_get c | false |
Hacl.Spec.K256.MathLemmas.fst | Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52_mul_pow | val lemma_distr5_pow52_mul_pow (a b0 b1 b2 b3 b4: int) (p:nat) : Lemma
(a * pow2 p * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) +
a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p)) | val lemma_distr5_pow52_mul_pow (a b0 b1 b2 b3 b4: int) (p:nat) : Lemma
(a * pow2 p * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) +
a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p)) | let lemma_distr5_pow52_mul_pow a b0 b1 b2 b3 b4 p =
let b_sum = b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208 in
calc (==) {
a * pow2 p * b_sum;
(==) { lemma_swap_mul3 a (pow2 p) b_sum }
a * b_sum * pow2 p;
(==) { lemma_distr5_pow52 a b0 b1 b2 b3 b4 }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208) * pow2 p;
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156) (a * b4) 208 p }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156) * pow2 p + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104) (a * b3) 156 p }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104) * pow2 p + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52) (a * b2) 104 p }
(a * b0 + a * b1 * pow2 52) * pow2 p + a * b2 * pow2 (104 + p) + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0) (a * b1) 52 p }
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
} | {
"file_name": "code/k256/Hacl.Spec.K256.MathLemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 223,
"start_col": 0,
"start_line": 207
} | module Hacl.Spec.K256.MathLemmas
open FStar.Mul
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val lemma_swap_mul3 (a b c:int) : Lemma (a * b * c == a * c * b)
let lemma_swap_mul3 a b c =
calc (==) {
a * b * c;
(==) { Math.Lemmas.paren_mul_right a b c }
a * (b * c);
(==) { Math.Lemmas.swap_mul b c }
a * (c * b);
(==) { Math.Lemmas.paren_mul_right a c b }
a * c * b;
}
val lemma_mod_mul_distr (a b:int) (n:pos) : Lemma (a * b % n = (a % n) * (b % n) % n)
let lemma_mod_mul_distr a b n =
Math.Lemmas.lemma_mod_mul_distr_l a b n;
Math.Lemmas.lemma_mod_mul_distr_r (a % n) b n
val lemma_mod_sub_distr (a b:int) (n:pos) : Lemma ((a - b) % n = (a % n - b % n) % n)
let lemma_mod_sub_distr a b n =
Math.Lemmas.lemma_mod_plus_distr_l a (- b) n;
Math.Lemmas.lemma_mod_sub_distr (a % n) b n
val lemma_ab_le_cd (a b c d:nat) : Lemma
(requires a <= c /\ b <= d)
(ensures a * b <= c * d)
let lemma_ab_le_cd a b c d =
Math.Lemmas.lemma_mult_le_left a b d;
Math.Lemmas.lemma_mult_le_right d a c
val lemma_ab_lt_cd (a b c d:pos) : Lemma
(requires a < c /\ b < d)
(ensures a * b < c * d)
let lemma_ab_lt_cd a b c d =
Math.Lemmas.lemma_mult_lt_left a b d;
Math.Lemmas.lemma_mult_lt_right d a c
val lemma_bound_mul64_wide (ma mb:nat) (mma mmb:nat) (a b:nat) : Lemma
(requires a <= ma * mma /\ b <= mb * mmb)
(ensures a * b <= ma * mb * (mma * mmb))
let lemma_bound_mul64_wide ma mb mma mmb a b =
calc (<=) {
a * b;
(<=) { lemma_ab_le_cd a b (ma * mma) (mb * mmb) }
(ma * mma) * (mb * mmb);
(==) { Math.Lemmas.paren_mul_right ma mma (mb * mmb) }
ma * (mma * (mb * mmb));
(==) {
Math.Lemmas.paren_mul_right mma mb mmb;
Math.Lemmas.swap_mul mma mb;
Math.Lemmas.paren_mul_right mb mma mmb }
ma * (mb * (mma * mmb));
(==) { Math.Lemmas.paren_mul_right ma mb (mma * mmb) }
ma * mb * (mma * mmb);
}
val lemma_distr_pow (a b:int) (c d:nat) : Lemma ((a + b * pow2 c) * pow2 d = a * pow2 d + b * pow2 (c + d))
let lemma_distr_pow a b c d =
calc (==) {
(a + b * pow2 c) * pow2 d;
(==) { Math.Lemmas.distributivity_add_left a (b * pow2 c) (pow2 d) }
a * pow2 d + b * pow2 c * pow2 d;
(==) { Math.Lemmas.paren_mul_right b (pow2 c) (pow2 d); Math.Lemmas.pow2_plus c d }
a * pow2 d + b * pow2 (c + d);
}
val lemma_distr_pow_pow (a:int) (b:nat) (c:int) (d e:nat) :
Lemma ((a * pow2 b + c * pow2 d) * pow2 e = a * pow2 (b + e) + c * pow2 (d + e))
let lemma_distr_pow_pow a b c d e =
calc (==) {
(a * pow2 b + c * pow2 d) * pow2 e;
(==) { lemma_distr_pow (a * pow2 b) c d e }
a * pow2 b * pow2 e + c * pow2 (d + e);
(==) { Math.Lemmas.paren_mul_right a (pow2 b) (pow2 e); Math.Lemmas.pow2_plus b e }
a * pow2 (b + e) + c * pow2 (d + e);
}
val lemma_distr_eucl_mul (r a:int) (b:pos) : Lemma (r * (a % b) + r * (a / b) * b = r * a)
let lemma_distr_eucl_mul r a b =
calc (==) {
r * (a % b) + r * (a / b) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b) b }
r * (a % b) + r * ((a / b) * b);
(==) { Math.Lemmas.distributivity_add_right r (a % b) (a / b * b) }
r * (a % b + a / b * b);
(==) { Math.Lemmas.euclidean_division_definition a b }
r * a;
}
val lemma_distr_eucl_mul_add (r a c:int) (b:pos) : Lemma (r * (a % b) + r * (a / b + c) * b = r * a + r * c * b)
let lemma_distr_eucl_mul_add r a c b =
calc (==) {
r * (a % b) + r * (a / b + c) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b + c) b }
r * (a % b) + r * ((a / b + c) * b);
(==) { Math.Lemmas.distributivity_add_left (a / b) c b }
r * (a % b) + r * ((a / b * b) + c * b);
(==) { Math.Lemmas.distributivity_add_right r (a / b * b) (c * b) }
r * (a % b) + r * (a / b * b) + r * (c * b);
(==) { Math.Lemmas.paren_mul_right r (a / b) b; Math.Lemmas.paren_mul_right r c b }
r * (a % b) + r * (a / b) * b + r * c * b;
(==) { lemma_distr_eucl_mul r a b }
r * a + r * c * b;
}
val lemma_distr_eucl (a b:int) : Lemma ((a / pow2 52 + b) * pow2 52 + a % pow2 52 = a + b * pow2 52)
let lemma_distr_eucl a b = lemma_distr_eucl_mul_add 1 a b (pow2 52)
val lemma_a_plus_b_pow2_mod2 (a b:int) (c:pos) : Lemma ((a + b * pow2 c) % 2 = a % 2)
let lemma_a_plus_b_pow2_mod2 a b c =
assert_norm (pow2 1 = 2);
Math.Lemmas.lemma_mod_plus_distr_r a (b * pow2 c) 2;
Math.Lemmas.pow2_multiplication_modulo_lemma_1 b 1 c
val lemma_as_nat64_horner (r0 r1 r2 r3:int) :
Lemma (r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192 ==
((r3 * pow2 64 + r2) * pow2 64 + r1) * pow2 64 + r0)
let lemma_as_nat64_horner r0 r1 r2 r3 =
calc (==) {
r0 + pow2 64 * (r1 + pow2 64 * (r2 + pow2 64 * r3));
(==) { Math.Lemmas.swap_mul (pow2 64) (r1 + pow2 64 * (r2 + pow2 64 * r3)) }
r0 + (r1 + pow2 64 * (r2 + pow2 64 * r3)) * pow2 64;
(==) { Math.Lemmas.swap_mul (pow2 64) (r2 + pow2 64 * r3) }
r0 + (r1 + (r2 + pow2 64 * r3) * pow2 64) * pow2 64;
(==) { lemma_distr_pow r1 (r2 + pow2 64 * r3) 64 64 }
r0 + r1 * pow2 64 + (r2 + pow2 64 * r3) * pow2 128;
(==) { Math.Lemmas.swap_mul (pow2 64) r3 }
r0 + r1 * pow2 64 + (r2 + r3 * pow2 64) * pow2 128;
(==) { lemma_distr_pow r2 r3 64 128 }
r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192;
}
val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0)
let lemma_as_nat_horner r0 r1 r2 r3 r4 =
calc (==) {
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
(==) { lemma_distr_pow r1 ((r4 * pow2 52 + r3) * pow2 52 + r2) 52 52 }
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r2 (r4 * pow2 52 + r3) 52 104 }
(r4 * pow2 52 + r3) * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r3 r4 52 156 }
r4 * pow2 208 + r3 * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
}
val lemma_distr5 (a0 a1 a2 a3 a4 b:int) : Lemma
((a0 + a1 + a2 + a3 + a4) * b = a0 * b + a1 * b + a2 * b + a3 * b + a4 * b)
let lemma_distr5 a0 a1 a2 a3 a4 b =
calc (==) {
(a0 + a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a0 (a1 + a2 + a3 + a4) b }
a0 * b + (a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a1 (a2 + a3 + a4) b }
a0 * b + a1 * b + (a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a2 (a3 + a4) b }
a0 * b + a1 * b + a2 * b + (a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a3 a4 b }
a0 * b + a1 * b + a2 * b + a3 * b + a4 * b;
}
val lemma_distr5_pow52 (a b0 b1 b2 b3 b4:int) : Lemma
(a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208)
let lemma_distr5_pow52 a b0 b1 b2 b3 b4 =
calc (==) {
a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208);
(==) { lemma_distr5 b0 (b1 * pow2 52) (b2 * pow2 104) (b3 * pow2 156) (b4 * pow2 208) a }
b0 * a + b1 * pow2 52 * a + b2 * pow2 104 * a + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b1 (pow2 52) a; lemma_swap_mul3 b2 (pow2 104) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b3 (pow2 156) a; lemma_swap_mul3 b4 (pow2 208) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * a * pow2 156 + b4 * a * pow2 208;
}
val lemma_distr5_pow52_mul_pow (a b0 b1 b2 b3 b4: int) (p:nat) : Lemma
(a * pow2 p * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) +
a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.MathLemmas.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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: Prims.int ->
b0: Prims.int ->
b1: Prims.int ->
b2: Prims.int ->
b3: Prims.int ->
b4: Prims.int ->
p: Prims.nat
-> FStar.Pervasives.Lemma
(ensures
(a * Prims.pow2 p) *
(b0 + b1 * Prims.pow2 52 + b2 * Prims.pow2 104 + b3 * Prims.pow2 156 + b4 * Prims.pow2 208) =
(a * b0) * Prims.pow2 p + (a * b1) * Prims.pow2 (52 + p) + (a * b2) * Prims.pow2 (104 + p) +
(a * b3) * Prims.pow2 (156 + p) +
(a * b4) * Prims.pow2 (208 + p)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"Prims.nat",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.op_Addition",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.MathLemmas.lemma_swap_mul3",
"Prims.squash",
"Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52",
"Hacl.Spec.K256.MathLemmas.lemma_distr_pow"
] | [] | false | false | true | false | false | let lemma_distr5_pow52_mul_pow a b0 b1 b2 b3 b4 p =
| let b_sum = b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208 in
calc ( == ) {
(a * pow2 p) * b_sum;
( == ) { lemma_swap_mul3 a (pow2 p) b_sum }
(a * b_sum) * pow2 p;
( == ) { lemma_distr5_pow52 a b0 b1 b2 b3 b4 }
(a * b0 + (a * b1) * pow2 52 + (a * b2) * pow2 104 + (a * b3) * pow2 156 + (a * b4) * pow2 208) *
pow2 p;
( == ) { lemma_distr_pow (a * b0 + (a * b1) * pow2 52 + (a * b2) * pow2 104 + (a * b3) * pow2 156)
(a * b4)
208
p }
(a * b0 + (a * b1) * pow2 52 + (a * b2) * pow2 104 + (a * b3) * pow2 156) * pow2 p +
(a * b4) * pow2 (208 + p);
( == ) { lemma_distr_pow (a * b0 + (a * b1) * pow2 52 + (a * b2) * pow2 104) (a * b3) 156 p }
(a * b0 + (a * b1) * pow2 52 + (a * b2) * pow2 104) * pow2 p + (a * b3) * pow2 (156 + p) +
(a * b4) * pow2 (208 + p);
( == ) { lemma_distr_pow (a * b0 + (a * b1) * pow2 52) (a * b2) 104 p }
(a * b0 + (a * b1) * pow2 52) * pow2 p + (a * b2) * pow2 (104 + p) + (a * b3) * pow2 (156 + p) +
(a * b4) * pow2 (208 + p);
( == ) { lemma_distr_pow (a * b0) (a * b1) 52 p }
(a * b0) * pow2 p + (a * b1) * pow2 (52 + p) + (a * b2) * pow2 (104 + p) +
(a * b3) * pow2 (156 + p) +
(a * b4) * pow2 (208 + p);
} | false |
StatefulLens.fst | StatefulLens.test1 | val test1 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures
(fun h0 d h1 ->
c == d /\ (h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\ sel h0 c == sel h1 c /\
sel h1 (sel h1 c) = 0)) | val test1 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures
(fun h0 d h1 ->
c == d /\ (h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\ sel h0 c == sel h1 c /\
sel h1 (sel h1 c) = 0)) | let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 116,
"start_col": 0,
"start_line": 109
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST (FStar.ST.ref (FStar.ST.ref Prims.int)) | FStar.ST.ST | [] | [] | [
"FStar.ST.ref",
"Prims.int",
"StatefulLens.__proj__Mkstlens__item__st_put",
"StatefulLens.compose_hlens",
"StatefulLens.hlens_ref",
"StatefulLens.compose_stlens",
"StatefulLens.stlens_ref",
"FStar.Monotonic.Heap.heap",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.nat",
"FStar.Ref.addr_of",
"FStar.Ref.sel",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"StatefulLens.__proj__Mkhlens__item__put",
"FStar.Ref.upd",
"Prims.op_Equality"
] | [] | false | true | false | false | false | let test1 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures
(fun h0 d h1 ->
c == d /\ (h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\ sel h0 c == sel h1 c /\
sel h1 (sel h1 c) = 0)) =
| (compose_stlens stlens_ref stlens_ref).st_put 0 c | false |
StatefulLens.fst | StatefulLens.test4 | val test4 (c: ref (ref int))
: ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) | val test4 (c: ref (ref int))
: ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) | let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v] | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 151,
"start_col": 0,
"start_line": 148
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST Prims.unit | FStar.ST.ST | [] | [] | [
"FStar.ST.ref",
"Prims.int",
"StatefulLens.op_String_Assignment",
"StatefulLens.compose_hlens",
"StatefulLens.hlens_ref",
"StatefulLens.op_Bar_Dot_Dot",
"StatefulLens.v",
"Prims.unit",
"StatefulLens.op_String_Access",
"FStar.Monotonic.Heap.heap",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.nat",
"FStar.Ref.addr_of",
"FStar.Ref.sel",
"Prims.op_Equality"
] | [] | false | true | false | false | false | let test4 (c: ref (ref int))
: ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
| c.[ v |.. v ] <- c.[ v |.. v ] | false |
StatefulLens.fst | StatefulLens.test2 | val test2 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) | val test2 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) | let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 124,
"start_col": 0,
"start_line": 120
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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: FStar.ST.ref (FStar.ST.ref Prims.int) -> FStar.ST.ST (FStar.ST.ref (FStar.ST.ref Prims.int)) | FStar.ST.ST | [] | [] | [
"FStar.ST.ref",
"Prims.int",
"StatefulLens.__proj__Mkstlens__item__st_put",
"StatefulLens.compose_hlens",
"StatefulLens.hlens_ref",
"StatefulLens.compose_stlens",
"StatefulLens.stlens_ref",
"StatefulLens.__proj__Mkstlens__item__st_get",
"FStar.Monotonic.Heap.heap",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.nat",
"FStar.Ref.addr_of",
"FStar.Ref.sel",
"Prims.l_and",
"Prims.eq2",
"Prims.op_Equality"
] | [] | false | true | false | false | false | let test2 (c: ref (ref int))
: ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
| let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c | false |
StatefulLens.fst | StatefulLens.move_x2 | val move_x2 (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h' ->
let rp = c.center in
let p = sel h0 rp in
let rx = p.x in
let h1 = upd h0 rx (sel h0 rx + delta) in
let p = sel h1 rp in
let h2 = upd h1 rp ({ p with x = rx }) in
h' == h2)) | val move_x2 (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h' ->
let rp = c.center in
let p = sel h0 rp in
let rx = p.x in
let h1 = upd h0 rx (sel h0 rx + delta) in
let p = sel h1 rp in
let h2 = upd h1 rp ({ p with x = rx }) in
h' == h2)) | let move_x2 (delta:int) (c:circle) : ST unit
(requires (fun _ -> True))
(ensures (fun h0 _ h' ->
let rp = c.center in
let p = sel h0 rp in
let rx = p.x in
let h1 = upd h0 rx (sel h0 rx + delta) in
let p = sel h1 rp in
let h2 = upd h1 rp ({p with x = rx}) in
h' == h2))
= c.[center |^. v |.^ x |.. v] <- (c.[center |^. v |.^ x |.. v] + delta) | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 75,
"end_line": 208,
"start_col": 0,
"start_line": 198
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v]
/// test4: and here's test2 written more compactly
let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v]
/// test5: Finally, here's a deeply nested collection of references and objects
/// It's easy to reach in with a long lens and update one of the innermost fields
let test5 (c:ref (colored (ref (colored (ref circle))))) =
c.[v |... payload |.. v |... payload |.. v |... center |... x] <- 17
////////////////////////////////////////////////////////////////////////////////
// A simple 2d point defined as a pair of integers
noeq
type point = {
x:ref int;
y:ref int;
}
// A circle is a point and a radius
noeq
type circle = {
center: ref point;
radius: ref nat
}
let center : lens circle (ref point) = {
Lens.get = (fun c -> c.center);
Lens.put = (fun p c -> {c with center = p})
}
let x : lens point (ref int) = {
Lens.get = (fun p -> p.x);
Lens.put = (fun x p -> {p with x = x})
}
/// `s |^. t`: composes a stateful lens with a pure one on the right
let ( |^. ) #a #b #c (#l:hlens b c) (m:lens a b) (sl:stlens l) = (~. m) |.. sl
let ( |.^ ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
let ( |. ) #a #b #c (m:lens a b) (n:lens b c) = Lens.(m |.. n)
let ( .() ) #a #b (#l:hlens a b) (x:a) ($hs:(heap * stlens l)) = l.get (fst hs, x)
let ( .()<- ) #a #b (#l:hlens a b) (x:a) ($hs:(heap * stlens l)) (y:b) = l.put y (fst hs, x)
let move_x (delta:int) (c:circle) : ST unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
let l = center |^. v |.^ x |.. v in
(h1, c) == (c.(h0, l) <- c.(h0, l) + delta)))
= c.[center |^. v |.^ x |.. v] <- c.[center |^. v |.^ x |.. v] + delta | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | delta: Prims.int -> c: StatefulLens.circle -> FStar.ST.ST Prims.unit | FStar.ST.ST | [] | [] | [
"Prims.int",
"StatefulLens.circle",
"StatefulLens.op_String_Assignment",
"StatefulLens.compose_hlens",
"FStar.ST.ref",
"StatefulLens.point",
"StatefulLens.as_hlens",
"StatefulLens.center",
"StatefulLens.hlens_ref",
"StatefulLens.x",
"StatefulLens.op_Bar_Dot_Dot",
"StatefulLens.op_Bar_Dot_Hat",
"StatefulLens.op_Bar_Hat_Dot",
"StatefulLens.v",
"Prims.unit",
"Prims.op_Addition",
"StatefulLens.op_String_Access",
"FStar.Monotonic.Heap.heap",
"Prims.l_True",
"Prims.eq2",
"FStar.Ref.upd",
"StatefulLens.Mkpoint",
"StatefulLens.__proj__Mkpoint__item__y",
"FStar.Ref.sel",
"StatefulLens.__proj__Mkpoint__item__x",
"StatefulLens.__proj__Mkcircle__item__center"
] | [] | false | true | false | false | false | let move_x2 (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h' ->
let rp = c.center in
let p = sel h0 rp in
let rx = p.x in
let h1 = upd h0 rx (sel h0 rx + delta) in
let p = sel h1 rp in
let h2 = upd h1 rp ({ p with x = rx }) in
h' == h2)) =
| c.[ center |^. v |.^ x |.. v ] <- (c.[ center |^. v |.^ x |.. v ] + delta) | false |
StatefulLens.fst | StatefulLens.move_x | val move_x (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h1 ->
let l = center |^. v |.^ x |.. v in
(h1, c) == (c.(h0, l) <- c.(h0, l) + delta))) | val move_x (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h1 ->
let l = center |^. v |.^ x |.. v in
(h1, c) == (c.(h0, l) <- c.(h0, l) + delta))) | let move_x (delta:int) (c:circle) : ST unit
(requires (fun _ -> True))
(ensures (fun h0 _ h1 ->
let l = center |^. v |.^ x |.. v in
(h1, c) == (c.(h0, l) <- c.(h0, l) + delta)))
= c.[center |^. v |.^ x |.. v] <- c.[center |^. v |.^ x |.. v] + delta | {
"file_name": "examples/data_structures/StatefulLens.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 73,
"end_line": 196,
"start_col": 0,
"start_line": 191
} | (*
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.
*)
/// Lenses for accessing and mutating in-place references holding datatypes in a heap
///
/// The basic idea is to write stateful lenses indexed by a "ghost" lens
/// where the ghost lens is a full specification of the stateful lens'
/// behavior on the heap
module StatefulLens
open Lens // Pure lenses
open FStar.Heap
open FStar.Ref
/// Rather than (:=), it's more convenient here to describe the effect of lens
/// using Heap.upd, instead of a combination of Heap.modifies and Heap.sel
assume val upd_ref (#a:Type) (r:ref a) (v:a) : ST unit
(requires (fun h -> True)) (ensures (fun h0 _ h1 -> h1 == upd h0 r v))
/// `hlens a b`: is a lens from a `(heap * a) ` to `b`
/// It is purely specificational.
/// In the blog post, we gloss over this detail, treating
/// hlens as pure lenses, rather than ghost lenses
noeq
type hlens a b = {
get: (heap * a) -> GTot b;
put: b -> (heap * a) -> GTot (heap * a)
}
/// `hlens a b` is just like `Lens.lens (heap * a) b`, except it uses the GTot effect.
/// Indeed, it is easy to turn a `lens a b` into an `hlens a b`
let as_hlens (l:lens 'a 'b) : hlens 'a 'b = {
get = (fun (h, x) -> x.[l]);
put = (fun y (h, x) -> h, (x.[l] <- y));
}
/// Composing hlenses is just like composing lenses
let compose_hlens #a #b #c (l:hlens a b) (m:hlens b c) : hlens a c = {
get = (fun (h0, x) -> m.get (h0, l.get (h0, x)));
put = (fun (z:c) (h0, x) -> let h1, b = m.put z (h0, (l.get (h0, x))) in l.put b (h1, x))
}
/// `stlens #a #b h`: This is the main type of this module
/// It provides a stateful lens from `a` to `b` whose behavior is fully characterized by `h`.
noeq
type stlens (#a:Type) (#b:Type) (l:hlens a b) = {
st_get : x:a -> ST b
(requires (fun h -> True))
(ensures (fun h0 y h1 -> h0==h1 /\ (l.get (h0, x) == y)));
st_put: y:b -> x:a -> ST a
(requires (fun h -> True))
(ensures (fun h0 x' h1 -> (h1, x') == (l.put y (h0, x))))
}
/// `stlens l m` can be composed into a stateful lens specified by the
/// composition of `l` and `m`
let compose_stlens #a #b #c (#l:hlens a b) (#m:hlens b c)
(sl:stlens l) (sm:stlens m)
: stlens (compose_hlens l m) = {
st_get = (fun (x:a) -> sm.st_get (sl.st_get x));
st_put = (fun (z:c) (x:a) -> sl.st_put (sm.st_put z (sl.st_get x)) x)
}
(** Now some simple stateful lenses **)
/// Any pure lens `l:lens a b` can be lifted into a stateful one
/// specified by the lifting of `l` itself to an hlens
let as_stlens (l:lens 'a 'b) : stlens (as_hlens l) = {
st_get = (fun (x:'a) -> x.[l]);
st_put = (fun (y:'b) (x:'a) -> x.[l] <- y)
}
/// `hlens_ref`: The specification of a lens for a single reference
let hlens_ref (#a:Type) : hlens (ref a) a = {
get = (fun (h, x) -> sel h x);
put = (fun y (h, x) -> (upd h x y, x))
}
/// `stlens_ref`: A stateful lens for a reference specified by `hlens_ref`
let stlens_ref (#a:Type) : stlens hlens_ref = {
st_get = (fun (x:ref a) -> !x);
st_put = (fun (y:a) (x:ref a) -> upd_ref x y; x)
}
////////////////////////////////////////////////////////////////////////////////
(** Now for some test code **)
/// test0: an accessor for a nested reference,
/// with a detailed spec just to check that it's all working
let test0 (c:ref (ref int)) : ST int
(requires (fun h -> True))
(ensures (fun h0 i h1 -> h0 == h1 /\ i == sel h1 (sel h1 c)))
= (compose_stlens stlens_ref stlens_ref).st_get c
/// test1: updated a nested reference with a 0
/// again, with a detailed spec just to check that it's all working
let test1 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 ->
c == d /\
(h1, d) == (compose_hlens hlens_ref hlens_ref).put 0 (h0, c) /\
h1 == upd (upd h0 (sel h0 c) 0) c (sel h0 c) /\
sel h0 c == sel h1 c /\ sel h1 (sel h1 c) = 0)) =
(compose_stlens stlens_ref stlens_ref).st_put 0 c
/// test2: Combining an access and a mutation
/// again, its spec shows that the c's final value is that same as its initial value
let test2 (c:ref (ref int)) : ST (ref (ref int))
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> c == d /\ sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
let i = (compose_stlens stlens_ref stlens_ref).st_get c in
(compose_stlens stlens_ref stlens_ref).st_put i c
////////////////////////////////////////////////////////////////////////////////
/// Now for some notation to clean up a bit
/// ////////////////////////////////////////////////////////////////////////////////
/// `s |.. t`: composes stateful lenses
let ( |.. ) #a #b #c (#l:hlens a b) (#m:hlens b c) = compose_stlens #a #b #c #l #m
/// `~. l`: lifts a pure lens to a stateful one
let ( ~. ) #a #b (l:lens a b) = as_stlens l
/// `s |... t`: composes a stateful lens with a pure one on the right
let ( |... ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
/// `x.[s]`: accessor of `x` using the stateful lens `s`
let ( .[] ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) = sl.st_get x
/// `x.[s] <- v`: mutator of `x` using the statful lens `s` to `v`
let ( .[]<- ) #a #b (#l:hlens a b) (x:a) (sl:stlens l) (y:b) = let _ = sl.st_put y x in ()
/// `v`: A stateful lens for a single reference
let v #a = stlens_ref #a
let deref = v
/// test3: test0 can be written more compactly like so
let test3 (c:ref (ref int)) = c.[v |.. v]
/// test4: and here's test2 written more compactly
let test4 (c:ref (ref int)) : ST unit
(requires (fun h -> addr_of (sel h c) <> addr_of c))
(ensures (fun h0 d h1 -> sel h1 (sel h1 c) = sel h0 (sel h0 c))) =
c.[v |.. v] <- c.[v |.. v]
/// test5: Finally, here's a deeply nested collection of references and objects
/// It's easy to reach in with a long lens and update one of the innermost fields
let test5 (c:ref (colored (ref (colored (ref circle))))) =
c.[v |... payload |.. v |... payload |.. v |... center |... x] <- 17
////////////////////////////////////////////////////////////////////////////////
// A simple 2d point defined as a pair of integers
noeq
type point = {
x:ref int;
y:ref int;
}
// A circle is a point and a radius
noeq
type circle = {
center: ref point;
radius: ref nat
}
let center : lens circle (ref point) = {
Lens.get = (fun c -> c.center);
Lens.put = (fun p c -> {c with center = p})
}
let x : lens point (ref int) = {
Lens.get = (fun p -> p.x);
Lens.put = (fun x p -> {p with x = x})
}
/// `s |^. t`: composes a stateful lens with a pure one on the right
let ( |^. ) #a #b #c (#l:hlens b c) (m:lens a b) (sl:stlens l) = (~. m) |.. sl
let ( |.^ ) #a #b #c (#l:hlens a b) (sl:stlens l) (m:lens b c) = sl |.. (~. m)
let ( |. ) #a #b #c (m:lens a b) (n:lens b c) = Lens.(m |.. n)
let ( .() ) #a #b (#l:hlens a b) (x:a) ($hs:(heap * stlens l)) = l.get (fst hs, x)
let ( .()<- ) #a #b (#l:hlens a b) (x:a) ($hs:(heap * stlens l)) (y:b) = l.put y (fst hs, x) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lens.fst.checked",
"FStar.Ref.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "StatefulLens.fst"
} | [
{
"abbrev": false,
"full_module": "Lens // Pure lenses",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ref",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lens",
"short_module": null
},
{
"abbrev": 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 | delta: Prims.int -> c: StatefulLens.circle -> FStar.ST.ST Prims.unit | FStar.ST.ST | [] | [] | [
"Prims.int",
"StatefulLens.circle",
"StatefulLens.op_String_Assignment",
"StatefulLens.compose_hlens",
"FStar.ST.ref",
"StatefulLens.point",
"StatefulLens.as_hlens",
"StatefulLens.center",
"StatefulLens.hlens_ref",
"StatefulLens.x",
"StatefulLens.op_Bar_Dot_Dot",
"StatefulLens.op_Bar_Dot_Hat",
"StatefulLens.op_Bar_Hat_Dot",
"StatefulLens.v",
"Prims.unit",
"Prims.op_Addition",
"StatefulLens.op_String_Access",
"FStar.Monotonic.Heap.heap",
"Prims.l_True",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"StatefulLens.op_Array_Assignment",
"StatefulLens.stlens",
"StatefulLens.op_Array_Access"
] | [] | false | true | false | false | false | let move_x (delta: int) (c: circle)
: ST unit
(requires (fun _ -> True))
(ensures
(fun h0 _ h1 ->
let l = center |^. v |.^ x |.. v in
(h1, c) == (c.(h0, l) <- c.(h0, l) + delta))) =
| c.[ center |^. v |.^ x |.. v ] <- c.[ center |^. v |.^ x |.. v ] + delta | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.commutative | val commutative : f: (_: a -> _: a -> a) -> Prims.logical | let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 42,
"start_col": 0,
"start_line": 41
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> a) -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.l_Forall",
"Prims.eq2",
"Prims.logical"
] | [] | false | false | false | true | true | let commutative #a (f: (a -> a -> a)) =
| forall x y. f x y == f y x | false |
|
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.associative | val associative : f: (_: a -> _: a -> a) -> Prims.logical | let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 39,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here. | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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: (_: a -> _: a -> a) -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.l_Forall",
"Prims.eq2",
"Prims.logical"
] | [] | false | false | false | true | true | let associative #a (f: (a -> a -> a)) =
| forall x y z. f x (f y z) == f (f x y) z | false |
|
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.is_unit | val is_unit : x: a -> f: (_: a -> _: a -> a) -> Prims.logical | let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 45,
"start_col": 0,
"start_line": 44
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> f: (_: a -> _: a -> a) -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"Prims.l_Forall",
"Prims.l_and",
"Prims.eq2",
"Prims.logical"
] | [] | false | false | false | true | true | let is_unit #a (x: a) (f: (a -> a -> a)) =
| forall y. f x y == y /\ f y x == y | false |
|
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.post | val post : a: Type -> c: OPLSS2021.ParNDSDiv.comm_monoid s -> Type | let post #s a (c:comm_monoid s) = a -> c.r | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 63,
"start_col": 0,
"start_line": 63
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 -> c: OPLSS2021.ParNDSDiv.comm_monoid s -> Type | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r"
] | [] | false | false | false | true | true | let post #s a (c: comm_monoid s) =
| a -> c.r | false |
|
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.return | val return (#s: _) (#c: comm_monoid s) (#a: _) (x: a) (post: (a -> c.r)) : m a (post x) post | val return (#s: _) (#c: comm_monoid s) (#a: _) (x: a) (post: (a -> c.r)) : m a (post x) post | let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 9,
"end_line": 202,
"start_col": 0,
"start_line": 200
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: a -> post: (_: a -> Mkcomm_monoid?.r c) -> OPLSS2021.ParNDSDiv.m a (post x) post | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.Ret",
"OPLSS2021.ParNDSDiv.m"
] | [] | false | false | false | false | false | let return #s (#c: comm_monoid s) #a (x: a) (post: (a -> c.r)) : m a (post x) post =
| Ret x | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.run | val run (#s #c: _) (i: nat) (#pre #a #post: _) (f: m a pre post) (state: s)
: Div (a & s)
(requires c.interp pre state)
(ensures fun (x, state') -> c.interp (post x) state') | val run (#s #c: _) (i: nat) (#pre #a #post: _) (f: m a pre post) (state: s)
: Div (a & s)
(requires c.interp pre state)
(ensures fun (x, state') -> c.interp (post x) state') | let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state' | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 194,
"start_col": 0,
"start_line": 184
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
* | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.nat -> f: OPLSS2021.ParNDSDiv.m a pre post -> state: s -> FStar.Pervasives.Div (a * s) | FStar.Pervasives.Div | [] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"Prims.nat",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.post",
"OPLSS2021.ParNDSDiv.m",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__interp",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__emp",
"OPLSS2021.ParNDSDiv.run",
"OPLSS2021.ParNDSDiv.step_result",
"OPLSS2021.ParNDSDiv.step"
] | [
"recursion"
] | false | true | false | false | false | let rec run #s #c (i: nat) #pre #a #post (f: m a pre post) (state: s)
: Div (a & s)
(requires c.interp pre state)
(ensures fun (x, state') -> c.interp (post x) state') =
| match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state' | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.step | val step (#s #c: _) (i: nat) (#pre #a #post: _) (f: m a pre post) (frame: c.r) (state: s)
: Div (step_result a post frame)
(requires c.interp (pre `c.star` frame) state)
(ensures fun _ -> True) | val step (#s #c: _) (i: nat) (#pre #a #post: _) (f: m a pre post) (frame: c.r) (state: s)
: Div (step_result a post frame)
(requires c.interp (pre `c.star` frame) state)
(ensures fun _ -> True) | let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 86,
"end_line": 174,
"start_col": 0,
"start_line": 138
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
* | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | i: Prims.nat -> f: OPLSS2021.ParNDSDiv.m a pre post -> frame: Mkcomm_monoid?.r c -> state: s
-> FStar.Pervasives.Div (OPLSS2021.ParNDSDiv.step_result a post frame) | FStar.Pervasives.Div | [] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"Prims.nat",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.post",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.Step",
"OPLSS2021.ParNDSDiv.Ret",
"OPLSS2021.ParNDSDiv.step_result",
"OPLSS2021.ParNDSDiv.action",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__post",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__interp",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"Prims.dtuple2",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__sem",
"FStar.Universe.raise_t",
"Prims.unit",
"OPLSS2021.ParNDSDiv.bools",
"OPLSS2021.ParNDSDiv.Par",
"OPLSS2021.ParNDSDiv.step",
"Prims.op_Addition",
"Prims.bool",
"Prims.l_True"
] | [
"recursion"
] | false | true | false | false | false | let rec step #s #c (i: nat) #pre #a #post (f: m a pre post) (frame: c.r) (state: s)
: Div (step_result a post frame)
(requires c.interp (pre `c.star` frame) state)
(ensures fun _ -> True) =
| match f with
| Ret x -> Step (post x) (Ret x) state i
| Act act1 k ->
let (| b , state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0) pre1 post1 (Ret x1) k -> Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0 pre1 post1 m1 k ->
if bools i
then
let Step pre0' m0' state' j = step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else
let Step pre1' m1' state' j = step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.bind | val bind
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#b: Type u#b)
(#p: c.r)
(#q: (a -> c.r))
(#r: (b -> c.r))
(f: m a p q)
(g: (x: a -> Dv (m b (q x) r)))
: Dv (m b p r) | val bind
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#b: Type u#b)
(#p: c.r)
(#q: (a -> c.r))
(#r: (b -> c.r))
(f: m a p q)
(g: (x: a -> Dv (m b (q x) r)))
: Dv (m b p r) | let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 234,
"start_col": 0,
"start_line": 208
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret` | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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: OPLSS2021.ParNDSDiv.m a p q -> g: (x: a -> FStar.Pervasives.Dv (OPLSS2021.ParNDSDiv.m b (q x) r))
-> FStar.Pervasives.Dv (OPLSS2021.ParNDSDiv.m b p r) | FStar.Pervasives.Dv | [] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.action",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__post",
"OPLSS2021.ParNDSDiv.Act",
"OPLSS2021.ParNDSDiv.bind",
"FStar.Universe.raise_t",
"Prims.unit",
"OPLSS2021.ParNDSDiv.post",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.Par",
"OPLSS2021.ParNDSDiv.Ret",
"FStar.Universe.raise_val"
] | [
"recursion"
] | false | true | false | false | false | let rec bind
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#b: Type u#b)
(#p: c.r)
(#q: (a -> c.r))
(#r: (b -> c.r))
(f: m a p q)
(g: (x: a -> Dv (m b (q x) r)))
: Dv (m b p r) =
| match f with
| Ret x -> g x
| Act act k -> Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml pre1 post1 mr k ->
let k:m b (post0 `c.star` post1) r = bind k g in
let ml':m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr':m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml' pre1 post1 mr' #b #r k | false |
Hacl.Bignum25519.fsti | Hacl.Bignum25519.gety | val gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1) | val gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1) | let gety (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1)
= sub p 5ul 5ul | {
"file_name": "code/ed25519/Hacl.Bignum25519.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 35,
"start_col": 0,
"start_line": 32
} | module Hacl.Bignum25519
module ST = FStar.HyperStack.ST
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module BSeq = Lib.ByteSequence
module S51 = Hacl.Spec.Curve25519.Field51.Definition
module F51 = Hacl.Impl.Ed25519.Field51
module SC = Spec.Curve25519
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(* Type abbreviations *)
inline_for_extraction noextract
let felem = lbuffer uint64 5ul
(* A point is buffer of size 20, that is 4 consecutive buffers of size 5 *)
inline_for_extraction noextract
let point = lbuffer uint64 20ul
inline_for_extraction noextract
let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1)
= sub p 0ul 5ul | {
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Finv.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum25519.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S51"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": 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 | p: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Hacl.Bignum25519.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Bignum25519.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum25519.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let gety (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1) =
| sub p 5ul 5ul | false |
Vale.AES.PPC64LE.AES128.fst | Vale.AES.PPC64LE.AES128.va_lemma_AES128EncryptBlock_6way | val va_lemma_AES128EncryptBlock_6way : va_b0:va_code -> va_s0:va_state -> in1:quad32 -> in2:quad32
-> in3:quad32 -> in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptBlock_6way ()) va_s0 /\ va_get_ok va_s0
/\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ FStar.Seq.Base.length #quad32 round_keys ==
11 /\ round_keys == Vale.AES.AES_BE_s.key_to_round_keys_word AES_128 key /\ va_get_vec 0 va_s0
== in1 /\ va_get_vec 1 va_s0 == in2 /\ va_get_vec 2 va_s0 == in3 /\ va_get_vec 3 va_s0 == in4
/\ va_get_vec 4 va_s0 == in5 /\ va_get_vec 5 va_s0 == in6 /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer i
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in1 /\ va_get_vec 1 va_sM
== Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in2 /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in3 /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in4 /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in5 /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in6 /\ va_state_eq va_sM (va_update_vec 6 va_sM
(va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))) | val va_lemma_AES128EncryptBlock_6way : va_b0:va_code -> va_s0:va_state -> in1:quad32 -> in2:quad32
-> in3:quad32 -> in4:quad32 -> in5:quad32 -> in6:quad32 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptBlock_6way ()) va_s0 /\ va_get_ok va_s0
/\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ FStar.Seq.Base.length #quad32 round_keys ==
11 /\ round_keys == Vale.AES.AES_BE_s.key_to_round_keys_word AES_128 key /\ va_get_vec 0 va_s0
== in1 /\ va_get_vec 1 va_s0 == in2 /\ va_get_vec 2 va_s0 == in3 /\ va_get_vec 3 va_s0 == in4
/\ va_get_vec 4 va_s0 == in5 /\ va_get_vec 5 va_s0 == in6 /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ (forall (i:nat) . i < 11 ==>
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer i
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys i)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in1 /\ va_get_vec 1 va_sM
== Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in2 /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in3 /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in4 /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in5 /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in6 /\ va_state_eq va_sM (va_update_vec 6 va_sM
(va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))))))) | let va_lemma_AES128EncryptBlock_6way va_b0 va_s0 in1 in2 in3 in4 in5 in6 key round_keys keys_buffer
=
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptBlock_6way va_mods in1 in2 in3 in4 in5 in6 key round_keys
keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock_6way ()) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 270 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 300 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in1) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 301 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in2) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 302 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in3) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 303 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in4) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 304 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in5) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 305 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in6)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.PPC64LE.AES128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 1065,
"start_col": 0,
"start_line": 1040
} | module Vale.AES.PPC64LE.AES128
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers_BE
#reset-options "--z3rlimit 20"
//-- KeyExpansionRound
val va_code_KeyExpansionRound : round:nat8 -> rcon:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionRound round rcon =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 3) 8) (va_CCons (va_code_Vsbox (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1))
(va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) rcon) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_CCons (va_code_RotWord (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) 3) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply`
(round + 1))) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))))))
val va_codegen_success_KeyExpansionRound : round:nat8 -> rcon:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionRound round rcon =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 3) 8) (va_pbool_and (va_codegen_success_Vsbox
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1)) (va_pbool_and (va_codegen_success_LoadImmShl64
(va_op_reg_opr_reg 10) rcon) (va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 10)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_RotWord
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_Vspltw (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) 3) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
12) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
12) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) (16 `op_Multiply` (round + 1))) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_ttrue
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat8) (rcon:nat8) (dst:buffer128)
(key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
(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 65 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 66 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 3) 8) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 67 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsbox (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 68 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) rcon) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 69 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 70 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 71 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_RotWord (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 72 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) 3) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 73 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 74 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 75 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 76 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 77 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 79 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 80 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` (round + 1))) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 81 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret dst (round + 1)) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 83 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.Def.Types_s.quad32_xor_reveal ()) (let (va_arg25:Vale.Def.Types_s.nat8) =
rcon in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 84 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.lemma_shl_rcon va_arg25) (let
(va_arg24:Vale.Def.Types_s.nat32) = rcon in let (va_arg23:Vale.Def.Types_s.quad32) = va_get_vec
1 va_old_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 85 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.lemma_simd_round_key va_arg23 va_arg24) (va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 86 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.expand_key_128_reveal ()) (va_QEmpty
(()))))))))))))))))))))))))
val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat8 -> rcon:nat8 ->
dst:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0
/\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) dst 11
(va_get_mem_layout va_s0) Secret /\ (0 <= round /\ round < 10) /\ rcon ==
Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\
va_get_vec 1 va_s0 == Vale.AES.AES_helpers_BE.expand_key_128 key round))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ va_get_vec 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ va_get_vec
1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128 key (round + 1) /\
Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 43 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 54 column 64 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 61 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
dst (round + 1) (va_get_mem_heaplet 1 va_sM))) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128 key (round + 1)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 63 column 82 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_KeyExpansionRound (round:nat8) (rcon:nat8) (dst:buffer128) (key:(seq nat32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= round /\ round < 10) /\ rcon ==
Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\
va_get_vec 1 va_s0 == Vale.AES.AES_helpers_BE.expand_key_128 key round /\ (forall
(va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4 va_x_v4
(va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0
(va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))))) in
va_get_ok va_sM /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg
3 va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst (round + 1)
(va_get_mem_heaplet 1 va_sM)) /\ va_get_vec 1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128
key (round + 1) /\ Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1
va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (())))
val va_wpProof_KeyExpansionRound : round:nat8 -> rcon:nat8 -> dst: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_KeyExpansionRound round rcon dst key va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon)
([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0
round rcon dst key in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; 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_KeyExpansionRound (round:nat8) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) :
(va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
(va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key))
//--
//-- KeyExpansionRoundUnrolledRecursive
val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n])
[@ "opaque_to_smt"]
let rec va_code_KeyExpansionRoundUnrolledRecursive n =
(va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons
(va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n -
1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ()))
(va_CNil ())))
val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n])
[@ "opaque_to_smt"]
let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n =
(va_pbool_and (if (0 < n && n <= 10) then va_pbool_and
(va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and
(va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)))
(va_ttrue ())) else va_ttrue ()) (va_ttrue ()))
val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq
nat32) -> dst:buffer128 -> n:int
-> Ghost (va_state & va_fuel)(decreases %[n])
(requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\
va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= n /\ n <= 10) /\
Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ key ==
Vale.AES.AES_helpers_BE.be_quad32_to_seq (va_get_vec 1 va_s0) /\ va_get_vec 1 va_s0 ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst 0
(va_get_mem_heaplet 1 va_s0)) /\ va_get_reg 3 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.modifies_buffer128 dst
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst n
(va_get_mem_heaplet 1 va_sM)) /\ (forall j . {:pattern(reverse_bytes_quad32 (buffer128_read dst
j (va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= n ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM)) ==
Vale.AES.AES_helpers_BE.expand_key_128 key j) /\ va_state_eq va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))
[@"opaque_to_smt"]
let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n =
va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive)
(va_code_KeyExpansionRoundUnrolledRecursive n);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
Vale.AES.AES_helpers_BE.expand_key_128_reveal ();
let va_b3 = va_tl va_b1 in
let va_c3 = va_hd va_b1 in
let (va_fc3, va_s3) =
(
if (0 < n && n <= 10) then
(
let va_b4 = va_get_block va_c3 in
let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst
(n - 1) in
let va_b5 = va_tl va_b4 in
let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1)
(Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in
let va_b6 = va_tl va_b5 in
let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in
let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in
let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in
(va_fc3, va_s3)
)
else
(
let va_b7 = va_get_block va_c3 in
let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in
(va_fc3, va_s3)
)
) in
let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in
(va_sM, va_fM)
[@ va_qattr]
let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= n /\ n <= 10) /\
Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ key ==
Vale.AES.AES_helpers_BE.be_quad32_to_seq (va_get_vec 1 va_s0) /\ va_get_vec 1 va_s0 ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst 0
(va_get_mem_heaplet 1 va_s0)) /\ va_get_reg 3 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap)
(va_x_heap1:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.modifies_buffer128 dst
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst n
(va_get_mem_heaplet 1 va_sM)) /\ (forall j . {:pattern(reverse_bytes_quad32 (buffer128_read dst
j (va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= n ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM)) ==
Vale.AES.AES_helpers_BE.expand_key_128 key j) ==> va_k va_sM (())))
val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n:int ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n)
([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive
(va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; 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_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) :
(va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) =
(va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec
2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_KeyExpansionRoundUnrolledRecursive key dst n)
(va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n))
//--
//-- KeyExpansion128Stdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansion128Stdcall () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 4) Secret) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_CNil ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansion128Stdcall () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 4) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and
(va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_ttrue ())))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = Vale.AES.AES_helpers_BE.be_quad32_to_seq
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem_heaplet 0 va_s))) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 4) Secret input_key_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret output_key_expansion_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.lemma_expand_key_128 key 11) (va_QLemma va_range1
"***** PRECONDITION NOT MET AT line 145 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
true (fun _ -> va_reveal_eq (`%key_to_round_keys_word) key_to_round_keys_word
key_to_round_keys_word) (fun _ -> va_reveal_opaque (`%key_to_round_keys_word)
key_to_round_keys_word) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 148 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 149 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 150 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_QEmpty
(())))))))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansion128Stdcall va_mods input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall ()) 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/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ (let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) =
Vale.AES.AES_helpers_BE.be_quad32_to_seq (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0))) in label
va_range1
"***** POSTCONDITION NOT MET AT line 133 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) (va_get_reg 4 va_sM)
input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 134 column 83 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = Vale.AES.AES_helpers_BE.be_quad32_to_seq
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem_heaplet 0 va_s0))) in label va_range1
"***** POSTCONDITION NOT MET AT line 136 column 70 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 138 column 133 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(forall j . {:pattern(reverse_bytes_quad32 (buffer128_read output_key_expansion_b j
(va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= 10 ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM)) ==
FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_BE_s.key_to_round_keys_word AES_128
key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansion128Stdcall input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall ()) va_s0
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AES128EncryptRound
val va_code_AES128EncryptRound : n:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptRound n =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_CNil ())))))
val va_codegen_success_AES128EncryptRound : n:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptRound n =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat8) (init:quad32) (round_keys:(seq
quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
(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 176 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 177 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer n) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 178 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_QEmpty
(()))))))
val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat8 -> init:quad32 ->
round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (1
<= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_vec 0 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 157 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init round_keys n)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_AES128EncryptRound (n:nat8) (init:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\
va_get_vec 0 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg 4
va_s0 == Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer
(va_get_mem_heaplet 0 va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0
va_s0) (va_get_reg 4 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer n
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0)) in va_get_ok va_sM /\ va_get_vec 0 va_sM
== Vale.AES.AES_BE_s.eval_rounds_def init round_keys n ==> va_k va_sM (())))
val va_wpProof_AES128EncryptRound : n:nat8 -> init:quad32 -> round_keys:(seq quad32) ->
keys_buffer: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_AES128EncryptRound n init round_keys keys_buffer va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_AES128EncryptRound (n:nat8) (init:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
(va_QProc (va_code_AES128EncryptRound n) ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init
round_keys keys_buffer))
//--
//-- AES128EncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptBlock () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
0) (va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_CCons
(va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons
(va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons
(va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons
(va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons
(va_code_AES128EncryptRound 9) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16
`op_Multiply` 10)) (va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_CCons (va_code_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2))
(va_CNil ())))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptBlock () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and
(va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound
3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and
(va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound
6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and
(va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound
9) (va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
2)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit
(va_code_AES128EncryptBlock ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 205 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 206 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 207 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 208 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 209 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 210 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 214 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 215 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 216 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 217 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 218 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 10) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 219 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 222 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 223 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.aes_encrypt_word_reveal ()) (va_QEmpty
(())))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 201 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AES128EncryptRound_6way
val va_code_AES128EncryptRound_6way : n:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptRound_6way n =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CNil ()))))))))))
val va_codegen_success_AES128EncryptRound_6way : n:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptRound_6way n =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipher
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptRound_6way (va_mods:va_mods_t) (n:nat8) (init1:quad32) (init2:quad32)
(init3:quad32) (init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound_6way n)) =
(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 260 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer n) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 263 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 264 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 265 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 266 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 267 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_QEmpty
(())))))))))))
val va_lemma_AES128EncryptRound_6way : va_b0:va_code -> va_s0:va_state -> n:nat8 -> init1:quad32 ->
init2:quad32 -> init3:quad32 -> init4:quad32 -> init5:quad32 -> init6:quad32 -> round_keys:(seq
quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptRound_6way n) va_s0 /\ va_get_ok va_s0 /\
(1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_vec 0 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys (n - 1) /\ va_get_vec 1 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys (n - 1) /\ va_get_vec 2 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys (n - 1) /\ va_get_vec 3 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys (n - 1) /\ va_get_vec 4 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys (n - 1) /\ va_get_vec 5 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n /\ va_get_vec 1
va_sM == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n /\ va_state_eq va_sM (va_update_vec 6
va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2
va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptRound_6way va_b0 va_s0 n init1 init2 init3 init4 init5 init6 round_keys
keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptRound_6way va_mods n init1 init2 init3 init4 init5 init6
round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound_6way n) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 226 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 256 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 257 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 258 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_AES128EncryptRound_6way (n:nat8) (init1:quad32) (init2:quad32) (init3:quad32)
(init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\
va_get_vec 0 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys (n - 1) /\ va_get_vec
1 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys (n - 1) /\ va_get_vec 2 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys (n - 1) /\ va_get_vec 3 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys (n - 1) /\ va_get_vec 4 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys (n - 1) /\ va_get_vec 5 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_r10:nat64) (va_x_v0:quad32)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32)
(va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4
(va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0
(va_upd_reg 10 va_x_r10 va_s0))))))) in va_get_ok va_sM /\ va_get_vec 0 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n /\ va_get_vec 1 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n ==> va_k va_sM (())))
val va_wpProof_AES128EncryptRound_6way : n:nat8 -> init1:quad32 -> init2:quad32 -> init3:quad32 ->
init4:quad32 -> init5:quad32 -> init6:quad32 -> round_keys:(seq quad32) -> keys_buffer: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_AES128EncryptRound_6way n init1 init2 init3 init4 init5
init6 round_keys keys_buffer va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound_6way n)
([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys keys_buffer
va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptRound_6way (va_code_AES128EncryptRound_6way n) va_s0 n
init1 init2 init3 init4 init5 init6 round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_AES128EncryptRound_6way (n:nat8) (init1:quad32) (init2:quad32) (init3:quad32)
(init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) :
(va_quickCode unit (va_code_AES128EncryptRound_6way n)) =
(va_QProc (va_code_AES128EncryptRound_6way n) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_wpProof_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys
keys_buffer))
//--
//-- AES128EncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptBlock_6way () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CCons (va_code_AES128EncryptRound_6way 1)
(va_CCons (va_code_AES128EncryptRound_6way 2) (va_CCons (va_code_AES128EncryptRound_6way 3)
(va_CCons (va_code_AES128EncryptRound_6way 4) (va_CCons (va_code_AES128EncryptRound_6way 5)
(va_CCons (va_code_AES128EncryptRound_6way 6) (va_CCons (va_code_AES128EncryptRound_6way 7)
(va_CCons (va_code_AES128EncryptRound_6way 8) (va_CCons (va_code_AES128EncryptRound_6way 9)
(va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipherlast
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons
(va_code_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (va_CNil ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptBlock_6way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_AES128EncryptRound_6way 1)
(va_pbool_and (va_codegen_success_AES128EncryptRound_6way 2) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 3) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 4) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 5) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 6) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 7) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 8) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 9) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipherlast
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (va_ttrue ())))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptBlock_6way (va_mods:va_mods_t) (in1:quad32) (in2:quad32) (in3:quad32)
(in4:quad32) (in5:quad32) (in6:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock_6way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 307 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in1 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 308 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in2 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 309 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init3:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in3 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 310 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init4:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in4 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 311 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init5:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in5 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 312 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in6 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 314 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 316 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 317 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 318 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 319 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 320 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 321 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 322 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 1 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 323 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 2 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 324 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 3 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 325 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 4 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 326 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 5 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 327 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 6 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 328 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 7 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 329 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 8 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 330 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 9 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 331 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 332 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 10) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 333 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 334 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 335 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 336 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 337 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 338 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 341 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 342 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.aes_encrypt_word_reveal ()) (va_QEmpty
(())))))))))))))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_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.PPC64LE.AES128.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.PPC64LE.Decls.va_code ->
va_s0: Vale.PPC64LE.Decls.va_state ->
in1: Vale.PPC64LE.Memory.quad32 ->
in2: Vale.PPC64LE.Memory.quad32 ->
in3: Vale.PPC64LE.Memory.quad32 ->
in4: Vale.PPC64LE.Memory.quad32 ->
in5: Vale.PPC64LE.Memory.quad32 ->
in6: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Prims.Ghost (Vale.PPC64LE.Decls.va_state * Vale.PPC64LE.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.PPC64LE.Decls.va_fuel",
"Vale.PPC64LE.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.PPC64LE.QuickCode.mod_t",
"Vale.PPC64LE.QuickCode.va_Mod_vec",
"Vale.PPC64LE.QuickCode.va_Mod_reg",
"Vale.PPC64LE.QuickCode.va_Mod_ok",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.PPC64LE.QuickCode.__proj__QProc__item__mods",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock_6way",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.PPC64LE.QuickCodes.label",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Vale.PPC64LE.Decls.va_get_ok",
"Vale.Def.Types_s.quad32",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.AES.AES_common_s.AES_128",
"Vale.PPC64LE.QuickCode.quickCode",
"Vale.AES.PPC64LE.AES128.va_qcode_AES128EncryptBlock_6way"
] | [] | false | false | false | false | false | let va_lemma_AES128EncryptBlock_6way va_b0 va_s0 in1 in2 in3 in4 in5 in6 key round_keys keys_buffer =
| let va_mods:va_mods_t =
[
va_Mod_vec 6;
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_vec 0;
va_Mod_reg 10;
va_Mod_ok
]
in
let va_qc =
va_qcode_AES128EncryptBlock_6way va_mods in1 in2 in3 in4 in5 in6 key round_keys keys_buffer
in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_AES128EncryptBlock_6way ())
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 270 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 300 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in1) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 301 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in2) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 302 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in3) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 303 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in4) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 304 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in5) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 305 column 50 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key in6))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_vec 6;
va_Mod_vec 5;
va_Mod_vec 4;
va_Mod_vec 3;
va_Mod_vec 2;
va_Mod_vec 1;
va_Mod_vec 0;
va_Mod_reg 10;
va_Mod_ok
])
va_sM
va_s0;
(va_sM, va_fM) | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.par | val par
(#s: _)
(#c: comm_monoid s)
(#p0 #q0: _)
(m0: m unit p0 (fun _ -> q0))
(#p1 #q1: _)
(m1: m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1)) | val par
(#s: _)
(#c: comm_monoid s)
(#p0 #q0: _)
(m0: m unit p0 (fun _ -> q0))
(#p1 #q1: _)
(m1: m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1)) | let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ()) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 15,
"end_line": 293,
"start_col": 0,
"start_line": 281
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 |
m0: OPLSS2021.ParNDSDiv.m Prims.unit p0 (fun _ -> q0) ->
m1: OPLSS2021.ParNDSDiv.m Prims.unit p1 (fun _ -> q1)
-> FStar.Pervasives.Dv
(OPLSS2021.ParNDSDiv.m Prims.unit
(Mkcomm_monoid?.star c p0 p1)
(fun _ -> Mkcomm_monoid?.star c q0 q1)) | FStar.Pervasives.Dv | [] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.m",
"Prims.unit",
"OPLSS2021.ParNDSDiv.Par",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.Ret",
"FStar.Universe.raise_t",
"OPLSS2021.ParNDSDiv.bind",
"FStar.Universe.raise_val"
] | [] | false | true | false | false | false | let par
#s
(#c: comm_monoid s)
#p0
#q0
(m0: m unit p0 (fun _ -> q0))
#p1
#q1
(m1: m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1)) =
| let m0':m (U.raise_t unit) p0 (fun _ -> q0) = bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ())) in
let m1':m (U.raise_t unit) p1 (fun _ -> q1) = bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ())) in
Par p0 q0 m0' p1 q1 m1' (Ret ()) | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.ret | val ret (a: Type u#a) (x: a) (p: (a -> hm.r)) : comp a (p x) p | val ret (a: Type u#a) (x: a) (p: (a -> hm.r)) : comp a (p x) p | let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 327,
"start_col": 0,
"start_line": 325
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 -> p: (_: a -> Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm)
-> OPLSS2021.ParNDSDiv.comp a (p x) p | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"Prims.unit",
"OPLSS2021.ParNDSDiv.return",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.comp"
] | [] | false | false | false | false | false | let ret (a: Type u#a) (x: a) (p: (a -> hm.r)) : comp a (p x) p =
| fun _ -> return x p | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.comp | val comp : a: Type ->
p: Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm ->
q: (_: a -> Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm)
-> Type0 | let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 323,
"start_col": 0,
"start_line": 322
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked, | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 ->
p: Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm ->
q: (_: a -> Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"Prims.unit",
"OPLSS2021.ParNDSDiv.m"
] | [] | false | false | false | true | true | let comp (a: Type u#a) (p: hm.r) (q: (a -> hm.r)) =
| unit -> Dv (m a p q) | false |
|
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.bnd | val bnd
(a: Type u#a)
(b: Type u#b)
(p: hm.r)
(q: (a -> hm.r))
(r: (b -> hm.r))
(f: comp a p q)
(g: (x: a -> comp b (q x) r))
: comp b p r | val bnd
(a: Type u#a)
(b: Type u#b)
(p: hm.r)
(q: (a -> hm.r))
(r: (b -> hm.r))
(f: comp a p q)
(g: (x: a -> comp b (q x) r))
: comp b p r | let bnd (a:Type u#a) (b:Type u#b) (p:hm.r) (q: a -> hm.r) (r: b -> hm.r)
(f:comp a p q) (g: (x:a -> comp b (q x) r))
: comp b p r
= fun _ -> bind (f()) (fun x -> g x ()) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 332,
"start_col": 0,
"start_line": 329
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q)
let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 ->
p: Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm ->
q: (_: a -> Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm) ->
r: (_: b -> Mkcomm_monoid?.r OPLSS2021.ParNDSDiv.hm) ->
f: OPLSS2021.ParNDSDiv.comp a p q ->
g: (x: a -> OPLSS2021.ParNDSDiv.comp b (q x) r)
-> OPLSS2021.ParNDSDiv.comp b p r | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"OPLSS2021.ParNDSDiv.comp",
"Prims.unit",
"OPLSS2021.ParNDSDiv.bind",
"OPLSS2021.ParNDSDiv.m"
] | [] | false | false | false | false | false | let bnd
(a: Type u#a)
(b: Type u#b)
(p: hm.r)
(q: (a -> hm.r))
(r: (b -> hm.r))
(f: comp a p q)
(g: (x: a -> comp b (q x) r))
: comp b p r =
| fun _ -> bind (f ()) (fun x -> g x ()) | false |
Hacl.Bignum25519.fsti | Hacl.Bignum25519.getx | val getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1) | val getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1) | let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1)
= sub p 0ul 5ul | {
"file_name": "code/ed25519/Hacl.Bignum25519.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 29,
"start_col": 0,
"start_line": 26
} | module Hacl.Bignum25519
module ST = FStar.HyperStack.ST
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module BSeq = Lib.ByteSequence
module S51 = Hacl.Spec.Curve25519.Field51.Definition
module F51 = Hacl.Impl.Ed25519.Field51
module SC = Spec.Curve25519
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(* Type abbreviations *)
inline_for_extraction noextract
let felem = lbuffer uint64 5ul
(* A point is buffer of size 20, that is 4 consecutive buffers of size 5 *)
inline_for_extraction noextract
let point = lbuffer uint64 20ul | {
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Finv.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum25519.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S51"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": 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 | p: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Hacl.Bignum25519.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Bignum25519.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum25519.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let getx (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1) =
| sub p 0ul 5ul | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.frame_action | val frame_action (#s: Type) (#c: comm_monoid s) (#a: Type) (f: action c a) (fr: c.r)
: g: action c a {g.post == (fun x -> (f.post x) `c.star` fr) /\ g.pre == f.pre `c.star` fr} | val frame_action (#s: Type) (#c: comm_monoid s) (#a: Type) (f: action c a) (fr: c.r)
: g: action c a {g.post == (fun x -> (f.post x) `c.star` fr) /\ g.pre == f.pre `c.star` fr} | let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem } | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 255,
"start_col": 0,
"start_line": 243
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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: OPLSS2021.ParNDSDiv.action c a -> fr: Mkcomm_monoid?.r c
-> g:
OPLSS2021.ParNDSDiv.action c a
{ Mkaction?.post g == (fun x -> Mkcomm_monoid?.star c (Mkaction?.post f x) fr) /\
Mkaction?.pre g == Mkcomm_monoid?.star c (Mkaction?.pre f) fr } | Prims.Tot | [
"total"
] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.action",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.Mkaction",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__interp",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"Prims.dtuple2",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__post",
"Prims.Mkdtuple2",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__sem",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__pre",
"Prims.l_and",
"Prims.eq2"
] | [] | false | false | false | false | false | let frame_action (#s: Type) (#c: comm_monoid s) (#a: Type) (f: action c a) (fr: c.r)
: g: action c a {g.post == (fun x -> (f.post x) `c.star` fr) /\ g.pre == f.pre `c.star` fr} =
| let pre = f.pre `c.star` fr in
let post x = (f.post x) `c.star` fr in
let sem (frame: c.r) (s0: s{c.interp (c.star pre frame) s0})
: (x: a & s1: s{c.interp ((post x) `c.star` frame) s1}) =
let (| x , s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre; post = post; sem = sem } | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.is_value | val is_value : exp -> Tot bool | val is_value : exp -> Tot bool | let is_value = EAbs? | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 30,
"start_col": 0,
"start_line": 30
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": 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 | _: StlcCbvDbPntSubstNoLists.exp -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"StlcCbvDbPntSubstNoLists.uu___is_EAbs"
] | [] | false | false | false | true | false | let is_value =
| EAbs? | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.frame_r | val frame_r (#a: Type u#a) (#p: hm.r) (#q: (a -> hm.r)) (#fr: hm.r) (f: (unit -> C a p q))
: C a (p `star` fr) (fun x -> (q x) `star` fr) | val frame_r (#a: Type u#a) (#p: hm.r) (#q: (a -> hm.r)) (#fr: hm.r) (f: (unit -> C a p q))
: C a (p `star` fr) (fun x -> (q x) `star` fr) | let frame_r (#a:Type u#a) (#p:hm.r) (#q: a -> hm.r) (#fr:hm.r)
(f: unit -> C a p q)
: C a (p `star` fr) (fun x -> q x `star` fr)
= let ff : m a p q = (reify (f())) () in
C?.reflect (fun () -> frame fr ff) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 466,
"start_col": 0,
"start_line": 462
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q)
let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p
let bnd (a:Type u#a) (b:Type u#b) (p:hm.r) (q: a -> hm.r) (r: b -> hm.r)
(f:comp a p q) (g: (x:a -> comp b (q x) r))
: comp b p r
= fun _ -> bind (f()) (fun x -> g x ())
reifiable
reflectable
effect {
C (a:Type) (pre:hm.r) (q: a -> hm.r)
with { repr = comp;
return = ret;
bind = bnd }
}
////////////////////////////////////////////////////////////////////////////////
// Some technicalities to lift pure and divergent computations to our new effect
////////////////////////////////////////////////////////////////////////////////
assume
val bind_pure_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> PURE a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (PURE, C) |> C = bind_pure_c_
assume
val bind_div_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> DIV a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (DIV, C) |> C = bind_div_c_
////////////////////////////////////////////////////////////////////////////////
// Assuming a simple heap model for this demo
////////////////////////////////////////////////////////////////////////////////
open FStar.Ghost
/// For this demo, we'll also assume that this assertions are affine
/// i.e., it's ok to forget some properties of the heap
assume
val hm_affine (r0 r1:hm.r) (h:heap)
: Lemma (hm.interp (r0 `hm.star` r1) h ==>
hm.interp r0 h)
/// Here's a ref type
assume
val ref : Type u#0 -> Type u#0
/// And two atomic heap assertions
assume
val pts_to (r:ref 'a) (x:'a) : hm.r
assume
val pure (p:prop) : hm.r
/// sel: Selected a reference from a heap, when that ref is live
assume
val sel (x:ref 'a) (v:erased 'a) (h:heap{hm.interp (pts_to x v) h})
: 'a
/// this tells us that sel is frameable
assume
val sel_ok (x:ref 'a) (v:erased 'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v `hm.star` frame) h ==>
(hm_affine (pts_to x v) frame h;
let v' = sel x v h in
hm.interp ((pts_to x v `hm.star` pure (reveal v == v')) `hm.star` frame) h))
/// upd: updates a heap at a given reference, when the heap contains it
assume
val upd (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap{hm.interp (pts_to x v0) h})
: Tot heap
/// and upd is frameable too
assume
val upd_ok (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v0 `hm.star` frame) h ==>
(hm_affine (pts_to x v0) frame h;
let h' = upd x v0 v h in
hm.interp (pts_to x v `hm.star` frame) h'))
assume
val rewrite (#a:Type u#a) (p: a -> hm.r) (x:erased a) (y:a)
: C unit (p y `star` pure (reveal x == y)) (fun _ -> p x)
////////////////////////////////////////////////////////////////////////////////
/// Here's a sample action for dereference
let (!) (#v0:erased 'a) (x:ref 'a)
: C 'a (pts_to x v0) (fun v -> pts_to x v0 `star` pure (reveal v0 == v))
= C?.reflect (fun _ ->
let act : action hm 'a =
{
pre = pts_to x v0;
post = (fun v -> pts_to x v0 `star` pure (reveal v0 == v)) ;
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
sel_ok x v0 h0 frame;
(| sel x v0 h0, h0 |))
} in
Act act Ret)
/// And a sample action for assignment
let (:=) (#v0:erased 'a) (x:ref 'a) (v:'a)
: C unit (pts_to x v0) (fun _ -> pts_to x v)
= C?.reflect (fun _ ->
let act : action hm unit =
{
pre = pts_to x v0;
post = (fun _ -> pts_to x v);
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
upd_ok x v0 v h0 frame;
(| (), upd x v0 v h0 |))
} in
Act act Ret) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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: (_: Prims.unit -> OPLSS2021.ParNDSDiv.C a) -> OPLSS2021.ParNDSDiv.C a | OPLSS2021.ParNDSDiv.C | [] | [] | [
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"Prims.unit",
"OPLSS2021.ParNDSDiv.frame",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.comp",
"OPLSS2021.ParNDSDiv.star"
] | [] | false | true | false | false | false | let frame_r (#a: Type u#a) (#p: hm.r) (#q: (a -> hm.r)) (#fr: hm.r) (f: (unit -> C a p q))
: C a (p `star` fr) (fun x -> (q x) `star` fr) =
| let ff:m a p q = (reify (f ())) () in
C?.reflect (fun () -> frame fr ff) | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.incr | val incr (#v0: erased int) (x: ref int) : C unit (pts_to x v0) (fun u -> pts_to x (v0 + 1)) | val incr (#v0: erased int) (x: ref int) : C unit (pts_to x v0) (fun u -> pts_to x (v0 + 1)) | let incr (#v0:erased int) (x:ref int)
: C unit (pts_to x v0) (fun u -> pts_to x (v0 + 1))
= let v = !x in
frame_r (fun _ -> x := v + 1);
rewrite (fun y -> pts_to x (y + 1)) v0 v | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 481,
"start_col": 0,
"start_line": 477
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q)
let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p
let bnd (a:Type u#a) (b:Type u#b) (p:hm.r) (q: a -> hm.r) (r: b -> hm.r)
(f:comp a p q) (g: (x:a -> comp b (q x) r))
: comp b p r
= fun _ -> bind (f()) (fun x -> g x ())
reifiable
reflectable
effect {
C (a:Type) (pre:hm.r) (q: a -> hm.r)
with { repr = comp;
return = ret;
bind = bnd }
}
////////////////////////////////////////////////////////////////////////////////
// Some technicalities to lift pure and divergent computations to our new effect
////////////////////////////////////////////////////////////////////////////////
assume
val bind_pure_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> PURE a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (PURE, C) |> C = bind_pure_c_
assume
val bind_div_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> DIV a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (DIV, C) |> C = bind_div_c_
////////////////////////////////////////////////////////////////////////////////
// Assuming a simple heap model for this demo
////////////////////////////////////////////////////////////////////////////////
open FStar.Ghost
/// For this demo, we'll also assume that this assertions are affine
/// i.e., it's ok to forget some properties of the heap
assume
val hm_affine (r0 r1:hm.r) (h:heap)
: Lemma (hm.interp (r0 `hm.star` r1) h ==>
hm.interp r0 h)
/// Here's a ref type
assume
val ref : Type u#0 -> Type u#0
/// And two atomic heap assertions
assume
val pts_to (r:ref 'a) (x:'a) : hm.r
assume
val pure (p:prop) : hm.r
/// sel: Selected a reference from a heap, when that ref is live
assume
val sel (x:ref 'a) (v:erased 'a) (h:heap{hm.interp (pts_to x v) h})
: 'a
/// this tells us that sel is frameable
assume
val sel_ok (x:ref 'a) (v:erased 'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v `hm.star` frame) h ==>
(hm_affine (pts_to x v) frame h;
let v' = sel x v h in
hm.interp ((pts_to x v `hm.star` pure (reveal v == v')) `hm.star` frame) h))
/// upd: updates a heap at a given reference, when the heap contains it
assume
val upd (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap{hm.interp (pts_to x v0) h})
: Tot heap
/// and upd is frameable too
assume
val upd_ok (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v0 `hm.star` frame) h ==>
(hm_affine (pts_to x v0) frame h;
let h' = upd x v0 v h in
hm.interp (pts_to x v `hm.star` frame) h'))
assume
val rewrite (#a:Type u#a) (p: a -> hm.r) (x:erased a) (y:a)
: C unit (p y `star` pure (reveal x == y)) (fun _ -> p x)
////////////////////////////////////////////////////////////////////////////////
/// Here's a sample action for dereference
let (!) (#v0:erased 'a) (x:ref 'a)
: C 'a (pts_to x v0) (fun v -> pts_to x v0 `star` pure (reveal v0 == v))
= C?.reflect (fun _ ->
let act : action hm 'a =
{
pre = pts_to x v0;
post = (fun v -> pts_to x v0 `star` pure (reveal v0 == v)) ;
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
sel_ok x v0 h0 frame;
(| sel x v0 h0, h0 |))
} in
Act act Ret)
/// And a sample action for assignment
let (:=) (#v0:erased 'a) (x:ref 'a) (v:'a)
: C unit (pts_to x v0) (fun _ -> pts_to x v)
= C?.reflect (fun _ ->
let act : action hm unit =
{
pre = pts_to x v0;
post = (fun _ -> pts_to x v);
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
upd_ok x v0 v h0 frame;
(| (), upd x v0 v h0 |))
} in
Act act Ret)
let frame_r (#a:Type u#a) (#p:hm.r) (#q: a -> hm.r) (#fr:hm.r)
(f: unit -> C a p q)
: C a (p `star` fr) (fun x -> q x `star` fr)
= let ff : m a p q = (reify (f())) () in
C?.reflect (fun () -> frame fr ff)
let par_c (#p0:hm.r) (#q0: hm.r)
(#p1:hm.r) (#q1: hm.r)
($f0: unit -> C unit p0 (fun _ -> q0))
($f1: unit -> C unit p1 (fun _ -> q1))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1)
= let ff0 : m unit p0 (fun _ -> q0) = reify (f0()) () in
let ff1 : m unit p1 (fun _ -> q1) = reify (f1()) () in
C?.reflect (fun () -> par ff0 ff1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: OPLSS2021.ParNDSDiv.ref Prims.int -> OPLSS2021.ParNDSDiv.C Prims.unit | OPLSS2021.ParNDSDiv.C | [] | [] | [
"FStar.Ghost.erased",
"Prims.int",
"OPLSS2021.ParNDSDiv.ref",
"OPLSS2021.ParNDSDiv.rewrite",
"OPLSS2021.ParNDSDiv.pts_to",
"Prims.op_Addition",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"Prims.unit",
"OPLSS2021.ParNDSDiv.frame_r",
"FStar.Ghost.reveal",
"OPLSS2021.ParNDSDiv.pure",
"Prims.eq2",
"OPLSS2021.ParNDSDiv.op_Colon_Equals",
"OPLSS2021.ParNDSDiv.op_Bang"
] | [] | false | true | false | false | false | let incr (#v0: erased int) (x: ref int) : C unit (pts_to x v0) (fun u -> pts_to x (v0 + 1)) =
| let v = !x in
frame_r (fun _ -> x := v + 1);
rewrite (fun y -> pts_to x (y + 1)) v0 v | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.par_c | val par_c
(#p0 #q0 #p1 #q1: hm.r)
($f0: (unit -> C unit p0 (fun _ -> q0)))
($f1: (unit -> C unit p1 (fun _ -> q1)))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1) | val par_c
(#p0 #q0 #p1 #q1: hm.r)
($f0: (unit -> C unit p0 (fun _ -> q0)))
($f1: (unit -> C unit p1 (fun _ -> q1)))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1) | let par_c (#p0:hm.r) (#q0: hm.r)
(#p1:hm.r) (#q1: hm.r)
($f0: unit -> C unit p0 (fun _ -> q0))
($f1: unit -> C unit p1 (fun _ -> q1))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1)
= let ff0 : m unit p0 (fun _ -> q0) = reify (f0()) () in
let ff1 : m unit p1 (fun _ -> q1) = reify (f1()) () in
C?.reflect (fun () -> par ff0 ff1) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 40,
"end_line": 475,
"start_col": 0,
"start_line": 468
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q)
let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p
let bnd (a:Type u#a) (b:Type u#b) (p:hm.r) (q: a -> hm.r) (r: b -> hm.r)
(f:comp a p q) (g: (x:a -> comp b (q x) r))
: comp b p r
= fun _ -> bind (f()) (fun x -> g x ())
reifiable
reflectable
effect {
C (a:Type) (pre:hm.r) (q: a -> hm.r)
with { repr = comp;
return = ret;
bind = bnd }
}
////////////////////////////////////////////////////////////////////////////////
// Some technicalities to lift pure and divergent computations to our new effect
////////////////////////////////////////////////////////////////////////////////
assume
val bind_pure_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> PURE a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (PURE, C) |> C = bind_pure_c_
assume
val bind_div_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> DIV a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (DIV, C) |> C = bind_div_c_
////////////////////////////////////////////////////////////////////////////////
// Assuming a simple heap model for this demo
////////////////////////////////////////////////////////////////////////////////
open FStar.Ghost
/// For this demo, we'll also assume that this assertions are affine
/// i.e., it's ok to forget some properties of the heap
assume
val hm_affine (r0 r1:hm.r) (h:heap)
: Lemma (hm.interp (r0 `hm.star` r1) h ==>
hm.interp r0 h)
/// Here's a ref type
assume
val ref : Type u#0 -> Type u#0
/// And two atomic heap assertions
assume
val pts_to (r:ref 'a) (x:'a) : hm.r
assume
val pure (p:prop) : hm.r
/// sel: Selected a reference from a heap, when that ref is live
assume
val sel (x:ref 'a) (v:erased 'a) (h:heap{hm.interp (pts_to x v) h})
: 'a
/// this tells us that sel is frameable
assume
val sel_ok (x:ref 'a) (v:erased 'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v `hm.star` frame) h ==>
(hm_affine (pts_to x v) frame h;
let v' = sel x v h in
hm.interp ((pts_to x v `hm.star` pure (reveal v == v')) `hm.star` frame) h))
/// upd: updates a heap at a given reference, when the heap contains it
assume
val upd (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap{hm.interp (pts_to x v0) h})
: Tot heap
/// and upd is frameable too
assume
val upd_ok (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v0 `hm.star` frame) h ==>
(hm_affine (pts_to x v0) frame h;
let h' = upd x v0 v h in
hm.interp (pts_to x v `hm.star` frame) h'))
assume
val rewrite (#a:Type u#a) (p: a -> hm.r) (x:erased a) (y:a)
: C unit (p y `star` pure (reveal x == y)) (fun _ -> p x)
////////////////////////////////////////////////////////////////////////////////
/// Here's a sample action for dereference
let (!) (#v0:erased 'a) (x:ref 'a)
: C 'a (pts_to x v0) (fun v -> pts_to x v0 `star` pure (reveal v0 == v))
= C?.reflect (fun _ ->
let act : action hm 'a =
{
pre = pts_to x v0;
post = (fun v -> pts_to x v0 `star` pure (reveal v0 == v)) ;
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
sel_ok x v0 h0 frame;
(| sel x v0 h0, h0 |))
} in
Act act Ret)
/// And a sample action for assignment
let (:=) (#v0:erased 'a) (x:ref 'a) (v:'a)
: C unit (pts_to x v0) (fun _ -> pts_to x v)
= C?.reflect (fun _ ->
let act : action hm unit =
{
pre = pts_to x v0;
post = (fun _ -> pts_to x v);
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
upd_ok x v0 v h0 frame;
(| (), upd x v0 v h0 |))
} in
Act act Ret)
let frame_r (#a:Type u#a) (#p:hm.r) (#q: a -> hm.r) (#fr:hm.r)
(f: unit -> C a p q)
: C a (p `star` fr) (fun x -> q x `star` fr)
= let ff : m a p q = (reify (f())) () in
C?.reflect (fun () -> frame fr ff) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 |
$f0: (_: Prims.unit -> OPLSS2021.ParNDSDiv.C Prims.unit) ->
$f1: (_: Prims.unit -> OPLSS2021.ParNDSDiv.C Prims.unit)
-> OPLSS2021.ParNDSDiv.C Prims.unit | OPLSS2021.ParNDSDiv.C | [] | [] | [
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm",
"Prims.unit",
"OPLSS2021.ParNDSDiv.par",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.comp",
"OPLSS2021.ParNDSDiv.star"
] | [] | false | true | false | false | false | let par_c
(#p0 #q0 #p1 #q1: hm.r)
($f0: (unit -> C unit p0 (fun _ -> q0)))
($f1: (unit -> C unit p1 (fun _ -> q1)))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1) =
| let ff0:m unit p0 (fun _ -> q0) = reify (f0 ()) () in
let ff1:m unit p1 (fun _ -> q1) = reify (f1 ()) () in
C?.reflect (fun () -> par ff0 ff1) | false |
Vale.AES.PPC64LE.AES128.fst | Vale.AES.PPC64LE.AES128.va_qcode_AES128EncryptBlock_6way | val va_qcode_AES128EncryptBlock_6way
(va_mods: va_mods_t)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AES128EncryptBlock_6way ())) | val va_qcode_AES128EncryptBlock_6way
(va_mods: va_mods_t)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AES128EncryptBlock_6way ())) | let va_qcode_AES128EncryptBlock_6way (va_mods:va_mods_t) (in1:quad32) (in2:quad32) (in3:quad32)
(in4:quad32) (in5:quad32) (in6:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptBlock_6way ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 307 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in1 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 308 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in2 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 309 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init3:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in3 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 310 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init4:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in4 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 311 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init5:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in5 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 312 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor in6 (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0) in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 314 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 316 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 317 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 318 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 319 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 320 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 321 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 322 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 1 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 323 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 2 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 324 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 3 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 325 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 4 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 326 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 5 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 327 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 6 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 328 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 7 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 329 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 8 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 330 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way 9 init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 331 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 332 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 10) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 333 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 334 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 335 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 336 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 337 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 338 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 341 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 342 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.aes_encrypt_word_reveal ()) (va_QEmpty
(())))))))))))))))))))))))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.AES128.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 43,
"end_line": 1037,
"start_col": 0,
"start_line": 918
} | module Vale.AES.PPC64LE.AES128
open Vale.Def.Opaque_s
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.Arch.Types
open Vale.AES.AES_helpers_BE
#reset-options "--z3rlimit 20"
//-- KeyExpansionRound
val va_code_KeyExpansionRound : round:nat8 -> rcon:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansionRound round rcon =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 0) 0) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 3) 8) (va_CCons (va_code_Vsbox (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1))
(va_CCons (va_code_LoadImmShl64 (va_op_reg_opr_reg 10) rcon) (va_CCons (va_code_Mtvsrws
(va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_CCons (va_code_RotWord (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_CCons (va_code_Vspltw (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) 3) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 1) 12) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 2)) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply`
(round + 1))) (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_CNil
())))))))))))))))))))
val va_codegen_success_KeyExpansionRound : round:nat8 -> rcon:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansionRound round rcon =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 0) 0) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 3) 8) (va_pbool_and (va_codegen_success_Vsbox
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1)) (va_pbool_and (va_codegen_success_LoadImmShl64
(va_op_reg_opr_reg 10) rcon) (va_pbool_and (va_codegen_success_Mtvsrws (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 10)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_RotWord
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_Vspltw (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) 3) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
12) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_Vsldoi (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_pbool_and
(va_codegen_success_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1)
12) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 3)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) (16 `op_Multiply` (round + 1))) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret) (va_ttrue
()))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansionRound (va_mods:va_mods_t) (round:nat8) (rcon:nat8) (dst:buffer128)
(key:(seq nat32)) : (va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
(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 65 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 0) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 66 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 3) 8) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 67 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsbox (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 1)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 68 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImmShl64 (va_op_reg_opr_reg 10) rcon) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 69 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Mtvsrws (va_op_vec_opr_vec 4) (va_op_reg_opr_reg 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 70 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 4)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 71 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_RotWord (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 72 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vspltw (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) 3) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 73 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 74 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 75 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 76 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 77 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 1) 12) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 78 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 79 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 80 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` (round + 1))) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 81 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 10) Secret dst (round + 1)) (fun (va_s:va_state) _ ->
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 83 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.Def.Types_s.quad32_xor_reveal ()) (let (va_arg25:Vale.Def.Types_s.nat8) =
rcon in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 84 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.lemma_shl_rcon va_arg25) (let
(va_arg24:Vale.Def.Types_s.nat32) = rcon in let (va_arg23:Vale.Def.Types_s.quad32) = va_get_vec
1 va_old_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 85 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.lemma_simd_round_key va_arg23 va_arg24) (va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 86 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.expand_key_128_reveal ()) (va_QEmpty
(()))))))))))))))))))))))))
val va_lemma_KeyExpansionRound : va_b0:va_code -> va_s0:va_state -> round:nat8 -> rcon:nat8 ->
dst:buffer128 -> key:(seq nat32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_KeyExpansionRound round rcon) va_s0 /\ va_get_ok va_s0
/\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0) dst 11
(va_get_mem_layout va_s0) Secret /\ (0 <= round /\ round < 10) /\ rcon ==
Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\
va_get_vec 1 va_s0 == Vale.AES.AES_helpers_BE.expand_key_128 key round))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ va_get_vec 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst (round + 1) (va_get_mem_heaplet 1 va_sM)) /\ va_get_vec
1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128 key (round + 1) /\
Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) /\ va_state_eq va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansionRound va_b0 va_s0 round rcon dst key =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansionRound va_mods round rcon dst key in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansionRound round rcon) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 43 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 54 column 64 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 61 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
dst (round + 1) (va_get_mem_heaplet 1 va_sM))) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 62 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128 key (round + 1)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 63 column 82 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_KeyExpansionRound (round:nat8) (rcon:nat8) (dst:buffer128) (key:(seq nat32))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= round /\ round < 10) /\ rcon ==
Vale.AES.AES_common_s.aes_rcon round /\ Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\
va_get_vec 1 va_s0 == Vale.AES.AES_helpers_BE.expand_key_128 key round /\ (forall
(va_x_mem:vale_heap) (va_x_heap1:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4 va_x_v4
(va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0
(va_upd_reg 10 va_x_r10 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))))) in
va_get_ok va_sM /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg
3 va_sM) dst 11 (va_get_mem_layout va_sM) Secret /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst (round + 1)
(va_get_mem_heaplet 1 va_sM)) /\ va_get_vec 1 va_sM == Vale.AES.AES_helpers_BE.expand_key_128
key (round + 1) /\ Vale.PPC64LE.Decls.modifies_buffer_specific128 dst (va_get_mem_heaplet 1
va_s0) (va_get_mem_heaplet 1 va_sM) (round + 1) (round + 1) ==> va_k va_sM (())))
val va_wpProof_KeyExpansionRound : round:nat8 -> rcon:nat8 -> dst: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_KeyExpansionRound round rcon dst key va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRound round rcon)
([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionRound round rcon dst key va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionRound (va_code_KeyExpansionRound round rcon) va_s0
round rcon dst key in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; 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_KeyExpansionRound (round:nat8) (rcon:nat8) (dst:buffer128) (key:(seq nat32)) :
(va_quickCode unit (va_code_KeyExpansionRound round rcon)) =
(va_QProc (va_code_KeyExpansionRound round rcon) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_KeyExpansionRound round rcon dst key) (va_wpProof_KeyExpansionRound round rcon dst key))
//--
//-- KeyExpansionRoundUnrolledRecursive
val va_code_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_code(decreases %[n])
[@ "opaque_to_smt"]
let rec va_code_KeyExpansionRoundUnrolledRecursive n =
(va_Block (va_CCons (if (0 < n && n <= 10) then va_Block (va_CCons
(va_code_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_CCons (va_code_KeyExpansionRound (n -
1) (Vale.AES.AES_common_s.aes_rcon (n - 1))) (va_CNil ()))) else va_Block (va_CNil ()))
(va_CNil ())))
val va_codegen_success_KeyExpansionRoundUnrolledRecursive : n:int -> Tot va_pbool(decreases %[n])
[@ "opaque_to_smt"]
let rec va_codegen_success_KeyExpansionRoundUnrolledRecursive n =
(va_pbool_and (if (0 < n && n <= 10) then va_pbool_and
(va_codegen_success_KeyExpansionRoundUnrolledRecursive (n - 1)) (va_pbool_and
(va_codegen_success_KeyExpansionRound (n - 1) (Vale.AES.AES_common_s.aes_rcon (n - 1)))
(va_ttrue ())) else va_ttrue ()) (va_ttrue ()))
val va_lemma_KeyExpansionRoundUnrolledRecursive : va_b0:va_code -> va_s0:va_state -> key:(seq
nat32) -> dst:buffer128 -> n:int
-> Ghost (va_state & va_fuel)(decreases %[n])
(requires (va_require_total va_b0 (va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 /\
va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= n /\ n <= 10) /\
Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ key ==
Vale.AES.AES_helpers_BE.be_quad32_to_seq (va_get_vec 1 va_s0) /\ va_get_vec 1 va_s0 ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst 0
(va_get_mem_heaplet 1 va_s0)) /\ va_get_reg 3 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.modifies_buffer128 dst
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst n
(va_get_mem_heaplet 1 va_sM)) /\ (forall j . {:pattern(reverse_bytes_quad32 (buffer128_read dst
j (va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= n ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM)) ==
Vale.AES.AES_helpers_BE.expand_key_128 key j) /\ va_state_eq va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))
[@"opaque_to_smt"]
let rec va_lemma_KeyExpansionRoundUnrolledRecursive va_b0 va_s0 key dst n =
va_reveal_opaque (`%va_code_KeyExpansionRoundUnrolledRecursive)
(va_code_KeyExpansionRoundUnrolledRecursive n);
let (va_old_s:va_state) = va_s0 in
let (va_b1:va_codes) = va_get_block va_b0 in
Vale.AES.AES_helpers_BE.expand_key_128_reveal ();
let va_b3 = va_tl va_b1 in
let va_c3 = va_hd va_b1 in
let (va_fc3, va_s3) =
(
if (0 < n && n <= 10) then
(
let va_b4 = va_get_block va_c3 in
let (va_s5, va_fc5) = va_lemma_KeyExpansionRoundUnrolledRecursive (va_hd va_b4) va_s0 key dst
(n - 1) in
let va_b5 = va_tl va_b4 in
let (va_s6, va_fc6) = va_lemma_KeyExpansionRound (va_hd va_b5) va_s5 (n - 1)
(Vale.AES.AES_common_s.aes_rcon (n - 1)) dst key in
let va_b6 = va_tl va_b5 in
let (va_s3, va_f6) = va_lemma_empty_total va_s6 va_b6 in
let va_f5 = va_lemma_merge_total va_b5 va_s5 va_fc6 va_s6 va_f6 va_s3 in
let va_fc3 = va_lemma_merge_total va_b4 va_s0 va_fc5 va_s5 va_f5 va_s3 in
(va_fc3, va_s3)
)
else
(
let va_b7 = va_get_block va_c3 in
let (va_s3, va_fc3) = va_lemma_empty_total va_s0 va_b7 in
(va_fc3, va_s3)
)
) in
let (va_sM, va_f3) = va_lemma_empty_total va_s3 va_b3 in
let va_fM = va_lemma_merge_total va_b1 va_s0 va_fc3 va_s3 va_f3 va_sM in
(va_sM, va_fM)
[@ va_qattr]
let va_wp_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg
3 va_s0) dst 11 (va_get_mem_layout va_s0) Secret /\ (0 <= n /\ n <= 10) /\
Vale.AES.AES_BE_s.is_aes_key_word AES_128 key /\ key ==
Vale.AES.AES_helpers_BE.be_quad32_to_seq (va_get_vec 1 va_s0) /\ va_get_vec 1 va_s0 ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst 0
(va_get_mem_heaplet 1 va_s0)) /\ va_get_reg 3 va_s0 == Vale.PPC64LE.Memory.buffer_addr
#Vale.PPC64LE.Memory.vuint128 dst (va_get_mem_heaplet 1 va_s0) /\ (forall (va_x_mem:vale_heap)
(va_x_heap1:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v1:quad32) (va_x_v2:quad32)
(va_x_v3:quad32) (va_x_v4:quad32) . let va_sM = va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3
(va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem va_s0))))))) in va_get_ok va_sM /\
Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) dst 11
(va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.modifies_buffer128 dst
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ va_get_vec 1 va_sM ==
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read dst n
(va_get_mem_heaplet 1 va_sM)) /\ (forall j . {:pattern(reverse_bytes_quad32 (buffer128_read dst
j (va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= n ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read dst j (va_get_mem_heaplet 1 va_sM)) ==
Vale.AES.AES_helpers_BE.expand_key_128 key j) ==> va_k va_sM (())))
val va_wpProof_KeyExpansionRoundUnrolledRecursive : key:(seq nat32) -> dst:buffer128 -> n:int ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_KeyExpansionRoundUnrolledRecursive n)
([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansionRoundUnrolledRecursive
(va_code_KeyExpansionRoundUnrolledRecursive n) va_s0 key dst n in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; 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_KeyExpansionRoundUnrolledRecursive (key:(seq nat32)) (dst:buffer128) (n:int) :
(va_quickCode unit (va_code_KeyExpansionRoundUnrolledRecursive n)) =
(va_QProc (va_code_KeyExpansionRoundUnrolledRecursive n) ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec
2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_KeyExpansionRoundUnrolledRecursive key dst n)
(va_wpProof_KeyExpansionRoundUnrolledRecursive key dst n))
//--
//-- KeyExpansion128Stdcall
[@ "opaque_to_smt" va_qattr]
let va_code_KeyExpansion128Stdcall () =
(va_Block (va_CCons (va_code_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 4) Secret) (va_CCons (va_code_Store128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_KeyExpansionRoundUnrolledRecursive 10) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_CNil ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_KeyExpansion128Stdcall () =
(va_pbool_and (va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 4) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and
(va_codegen_success_KeyExpansionRoundUnrolledRecursive 10) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_ttrue ())))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_KeyExpansion128Stdcall (va_mods:va_mods_t) (input_key_b:buffer128)
(output_key_expansion_b:buffer128) : (va_quickCode unit (va_code_KeyExpansion128Stdcall ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = Vale.AES.AES_helpers_BE.be_quad32_to_seq
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem_heaplet 0 va_s))) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 140 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 4) Secret input_key_b 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 142 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 3) Secret output_key_expansion_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 143 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_KeyExpansionRoundUnrolledRecursive key output_key_expansion_b 10) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 144 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_helpers_BE.lemma_expand_key_128 key 11) (va_QLemma va_range1
"***** PRECONDITION NOT MET AT line 145 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
true (fun _ -> va_reveal_eq (`%key_to_round_keys_word) key_to_round_keys_word
key_to_round_keys_word) (fun _ -> va_reveal_opaque (`%key_to_round_keys_word)
key_to_round_keys_word) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 148 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 149 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 150 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)) (va_QEmpty
(())))))))))))
[@"opaque_to_smt"]
let va_lemma_KeyExpansion128Stdcall va_b0 va_s0 input_key_b output_key_expansion_b =
let (va_mods:va_mods_t) = [va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_KeyExpansion128Stdcall va_mods input_key_b output_key_expansion_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_KeyExpansion128Stdcall ()) 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/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ (let (key:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) =
Vale.AES.AES_helpers_BE.be_quad32_to_seq (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read input_key_b 0 (va_get_mem_heaplet 0 va_s0))) in label
va_range1
"***** POSTCONDITION NOT MET AT line 133 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_sM) (va_get_reg 4 va_sM)
input_key_b 1 (va_get_mem_layout va_sM) Secret) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 134 column 83 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
output_key_expansion_b 11 (va_get_mem_layout va_sM) Secret)) /\ (let (key:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = Vale.AES.AES_helpers_BE.be_quad32_to_seq
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read input_key_b 0
(va_get_mem_heaplet 0 va_s0))) in label va_range1
"***** POSTCONDITION NOT MET AT line 136 column 70 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 output_key_expansion_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 138 column 133 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(forall j . {:pattern(reverse_bytes_quad32 (buffer128_read output_key_expansion_b j
(va_get_mem_heaplet 1 va_sM)))}0 <= j /\ j <= 10 ==> Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read output_key_expansion_b j (va_get_mem_heaplet 1 va_sM)) ==
FStar.Seq.Base.index #Vale.Def.Types_s.quad32 (Vale.AES.AES_BE_s.key_to_round_keys_word AES_128
key) j))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_KeyExpansion128Stdcall input_key_b output_key_expansion_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_KeyExpansion128Stdcall (va_code_KeyExpansion128Stdcall ()) va_s0
input_key_b output_key_expansion_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM
(va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_mem_heaplet 1
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0;
va_Mod_reg 10; va_Mod_mem_heaplet 1; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AES128EncryptRound
val va_code_AES128EncryptRound : n:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptRound n =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_CNil ())))))
val va_codegen_success_AES128EncryptRound : n:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptRound n =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptRound (va_mods:va_mods_t) (n:nat8) (init:quad32) (round_keys:(seq
quad32)) (keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
(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 176 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 177 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer n) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 178 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_QEmpty
(()))))))
val va_lemma_AES128EncryptRound : va_b0:va_code -> va_s0:va_state -> n:nat8 -> init:quad32 ->
round_keys:(seq quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptRound n) va_s0 /\ va_get_ok va_s0 /\ (1
<= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_vec 0 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init round_keys n /\ va_state_eq va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptRound va_b0 va_s0 n init round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptRound va_mods n init round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound n) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 157 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init round_keys n)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_AES128EncryptRound (n:nat8) (init:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\
va_get_vec 0 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init round_keys (n - 1) /\ va_get_reg 4
va_s0 == Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer
(va_get_mem_heaplet 0 va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0
va_s0) (va_get_reg 4 va_s0) keys_buffer 11 (va_get_mem_layout va_s0) Secret /\
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read keys_buffer n
(va_get_mem_heaplet 0 va_s0)) == FStar.Seq.Base.index #quad32 round_keys n /\ (forall
(va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32) . let va_sM = va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 va_s0)) in va_get_ok va_sM /\ va_get_vec 0 va_sM
== Vale.AES.AES_BE_s.eval_rounds_def init round_keys n ==> va_k va_sM (())))
val va_wpProof_AES128EncryptRound : n:nat8 -> init:quad32 -> round_keys:(seq quad32) ->
keys_buffer: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_AES128EncryptRound n init round_keys keys_buffer va_s0
va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound n) ([va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptRound n init round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptRound (va_code_AES128EncryptRound n) va_s0 n init
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_AES128EncryptRound (n:nat8) (init:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound n)) =
(va_QProc (va_code_AES128EncryptRound n) ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_AES128EncryptRound n init round_keys keys_buffer) (va_wpProof_AES128EncryptRound n init
round_keys keys_buffer))
//--
//-- AES128EncryptBlock
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptBlock () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10)
0) (va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_CCons
(va_code_AES128EncryptRound 1) (va_CCons (va_code_AES128EncryptRound 2) (va_CCons
(va_code_AES128EncryptRound 3) (va_CCons (va_code_AES128EncryptRound 4) (va_CCons
(va_code_AES128EncryptRound 5) (va_CCons (va_code_AES128EncryptRound 6) (va_CCons
(va_code_AES128EncryptRound 7) (va_CCons (va_code_AES128EncryptRound 8) (va_CCons
(va_code_AES128EncryptRound 9) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16
`op_Multiply` 10)) (va_CCons (va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons
(va_code_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_CCons (va_code_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2))
(va_CNil ())))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptBlock () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_pbool_and (va_codegen_success_AES128EncryptRound 1) (va_pbool_and
(va_codegen_success_AES128EncryptRound 2) (va_pbool_and (va_codegen_success_AES128EncryptRound
3) (va_pbool_and (va_codegen_success_AES128EncryptRound 4) (va_pbool_and
(va_codegen_success_AES128EncryptRound 5) (va_pbool_and (va_codegen_success_AES128EncryptRound
6) (va_pbool_and (va_codegen_success_AES128EncryptRound 7) (va_pbool_and
(va_codegen_success_AES128EncryptRound 8) (va_pbool_and (va_codegen_success_AES128EncryptRound
9) (va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
2)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)) (va_ttrue ())))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptBlock (va_mods:va_mods_t) (input:quad32) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_buffer:buffer128) : (va_quickCode unit
(va_code_AES128EncryptBlock ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 203 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540:(FStar.Seq.Base.seq a_539)) (i_541:Prims.nat) -> let (i_515:Prims.nat) =
i_541 in Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540)))
Vale.Def.Types_s.quad32 round_keys 0) (fun _ -> let (init:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor input (FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 205 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 206 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 207 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 208 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 1 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 209 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 2 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 210 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 3 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 211 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 4 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 212 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 5 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 213 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 6 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 214 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 7 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 215 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 8 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 216 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound 9 init round_keys keys_buffer) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 217 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 218 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer 10) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 219 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 2))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 222 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2)) (fun
(va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 223 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(fun (_:unit) -> Vale.AES.AES_BE_s.aes_encrypt_word_reveal ()) (va_QEmpty
(())))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptBlock va_b0 va_s0 input key round_keys keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptBlock va_mods input key round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptBlock ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 201 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.aes_encrypt_word AES_128 key input)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptBlock input key round_keys keys_buffer va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptBlock (va_code_AES128EncryptBlock ()) va_s0 input key
round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM
(va_update_ok va_sM va_s0)))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- AES128EncryptRound_6way
val va_code_AES128EncryptRound_6way : n:nat8 -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptRound_6way n =
(va_Block (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipher
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CNil ()))))))))))
val va_codegen_success_AES128EncryptRound_6way : n:nat8 -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptRound_6way n =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n))
(va_pbool_and (va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipher
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vcipher (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vcipher (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_AES128EncryptRound_6way (va_mods:va_mods_t) (n:nat8) (init1:quad32) (init2:quad32)
(init3:quad32) (init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32))
(keys_buffer:buffer128) : (va_quickCode unit (va_code_AES128EncryptRound_6way n)) =
(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 260 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` n)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret keys_buffer n) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 263 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 264 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 265 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 266 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 267 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vcipher (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_QEmpty
(())))))))))))
val va_lemma_AES128EncryptRound_6way : va_b0:va_code -> va_s0:va_state -> n:nat8 -> init1:quad32 ->
init2:quad32 -> init3:quad32 -> init4:quad32 -> init5:quad32 -> init6:quad32 -> round_keys:(seq
quad32) -> keys_buffer:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_AES128EncryptRound_6way n) va_s0 /\ va_get_ok va_s0 /\
(1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\ va_get_vec 0 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys (n - 1) /\ va_get_vec 1 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys (n - 1) /\ va_get_vec 2 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys (n - 1) /\ va_get_vec 3 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys (n - 1) /\ va_get_vec 4 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys (n - 1) /\ va_get_vec 5 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n /\ va_get_vec 1
va_sM == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n /\ va_state_eq va_sM (va_update_vec 6
va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2
va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
va_s0)))))))))))
[@"opaque_to_smt"]
let va_lemma_AES128EncryptRound_6way va_b0 va_s0 n init1 init2 init3 init4 init5 init6 round_keys
keys_buffer =
let (va_mods:va_mods_t) = [va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_AES128EncryptRound_6way va_mods n init1 init2 init3 init4 init5 init6
round_keys keys_buffer in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_AES128EncryptRound_6way n) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 226 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 0 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 2 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 256 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 3 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 257 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 4 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 258 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_get_vec 5 va_sM == Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_AES128EncryptRound_6way (n:nat8) (init1:quad32) (init2:quad32) (init3:quad32)
(init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (1 <= n /\ n < 10 /\ 10 <= FStar.Seq.Base.length #quad32 round_keys) /\
va_get_vec 0 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys (n - 1) /\ va_get_vec
1 va_s0 == Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys (n - 1) /\ va_get_vec 2 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys (n - 1) /\ va_get_vec 3 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys (n - 1) /\ va_get_vec 4 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys (n - 1) /\ va_get_vec 5 va_s0 ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys (n - 1) /\ va_get_reg 4 va_s0 ==
Vale.PPC64LE.Memory.buffer_addr #Vale.PPC64LE.Memory.vuint128 keys_buffer (va_get_mem_heaplet 0
va_s0) /\ Vale.PPC64LE.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg 4 va_s0)
keys_buffer 11 (va_get_mem_layout va_s0) Secret /\ Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read keys_buffer n (va_get_mem_heaplet 0 va_s0)) ==
FStar.Seq.Base.index #quad32 round_keys n /\ (forall (va_x_r10:nat64) (va_x_v0:quad32)
(va_x_v1:quad32) (va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v5:quad32)
(va_x_v6:quad32) . let va_sM = va_upd_vec 6 va_x_v6 (va_upd_vec 5 va_x_v5 (va_upd_vec 4 va_x_v4
(va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2 (va_upd_vec 1 va_x_v1 (va_upd_vec 0 va_x_v0
(va_upd_reg 10 va_x_r10 va_s0))))))) in va_get_ok va_sM /\ va_get_vec 0 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init1 round_keys n /\ va_get_vec 1 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init2 round_keys n /\ va_get_vec 2 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init3 round_keys n /\ va_get_vec 3 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init4 round_keys n /\ va_get_vec 4 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init5 round_keys n /\ va_get_vec 5 va_sM ==
Vale.AES.AES_BE_s.eval_rounds_def init6 round_keys n ==> va_k va_sM (())))
val va_wpProof_AES128EncryptRound_6way : n:nat8 -> init1:quad32 -> init2:quad32 -> init3:quad32 ->
init4:quad32 -> init5:quad32 -> init6:quad32 -> round_keys:(seq quad32) -> keys_buffer: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_AES128EncryptRound_6way n init1 init2 init3 init4 init5
init6 round_keys keys_buffer va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES128EncryptRound_6way n)
([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1;
va_Mod_vec 0; va_Mod_reg 10]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys keys_buffer
va_s0 va_k =
let (va_sM, va_f0) = va_lemma_AES128EncryptRound_6way (va_code_AES128EncryptRound_6way n) va_s0 n
init1 init2 init3 init4 init5 init6 round_keys keys_buffer in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 6 va_sM (va_update_vec 5 va_sM (va_update_vec 4 va_sM
(va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))))))));
va_lemma_norm_mods ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_AES128EncryptRound_6way (n:nat8) (init1:quad32) (init2:quad32) (init3:quad32)
(init4:quad32) (init5:quad32) (init6:quad32) (round_keys:(seq quad32)) (keys_buffer:buffer128) :
(va_quickCode unit (va_code_AES128EncryptRound_6way n)) =
(va_QProc (va_code_AES128EncryptRound_6way n) ([va_Mod_vec 6; va_Mod_vec 5; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10])
(va_wp_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys keys_buffer)
(va_wpProof_AES128EncryptRound_6way n init1 init2 init3 init4 init5 init6 round_keys
keys_buffer))
//--
//-- AES128EncryptBlock_6way
[@ "opaque_to_smt" va_qattr]
let va_code_AES128EncryptBlock_6way () =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CCons (va_code_AES128EncryptRound_6way 1)
(va_CCons (va_code_AES128EncryptRound_6way 2) (va_CCons (va_code_AES128EncryptRound_6way 3)
(va_CCons (va_code_AES128EncryptRound_6way 4) (va_CCons (va_code_AES128EncryptRound_6way 5)
(va_CCons (va_code_AES128EncryptRound_6way 6) (va_CCons (va_code_AES128EncryptRound_6way 7)
(va_CCons (va_code_AES128EncryptRound_6way 8) (va_CCons (va_code_AES128EncryptRound_6way 9)
(va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0) (va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_CCons (va_code_Vcipherlast
(va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6)) (va_CCons
(va_code_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 6))
(va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec
6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
4) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vcipherlast (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 5) (va_op_vec_opr_vec 6)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (va_CNil ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_AES128EncryptBlock_6way () =
(va_pbool_and (va_codegen_success_LoadImm64 (va_op_reg_opr_reg 10) 0) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 6))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_AES128EncryptRound_6way 1)
(va_pbool_and (va_codegen_success_AES128EncryptRound_6way 2) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 3) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 4) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 5) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 6) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 7) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 8) (va_pbool_and
(va_codegen_success_AES128EncryptRound_6way 9) (va_pbool_and (va_codegen_success_LoadImm64
(va_op_reg_opr_reg 10) (16 `op_Multiply` 10)) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 0)
(va_op_vec_opr_vec 6) (va_op_reg_opr_reg 4) (va_op_reg_opr_reg 10) Secret) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 0) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vcipherlast
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 6)) (va_pbool_and
(va_codegen_success_Vcipherlast (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec
6)) (va_pbool_and (va_codegen_success_Vcipherlast (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 6)
(va_op_vec_opr_vec 6) (va_op_vec_opr_vec 6)) (va_ttrue ()))))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_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.PPC64LE.AES128.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
in1: Vale.PPC64LE.Memory.quad32 ->
in2: Vale.PPC64LE.Memory.quad32 ->
in3: Vale.PPC64LE.Memory.quad32 ->
in4: Vale.PPC64LE.Memory.quad32 ->
in5: Vale.PPC64LE.Memory.quad32 ->
in6: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_buffer: Vale.PPC64LE.Memory.buffer128
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock_6way ()) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Machine_s.Block",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.InsBasic.va_code_LoadImm64",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer_index",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_code_Vxor",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptRound_6way",
"Prims.op_Multiply",
"Vale.PPC64LE.InsVector.va_code_Vcipherlast",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_qAssertSquash",
"Vale.PPC64LE.QuickCodes.va_range1",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Prims.squash",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.InsBasic.va_quick_LoadImm64",
"Vale.PPC64LE.InsVector.va_quick_Load128_byte16_buffer_index",
"Vale.PPC64LE.InsVector.va_quick_Vxor",
"Vale.AES.PPC64LE.AES128.va_quick_AES128EncryptRound_6way",
"Vale.PPC64LE.InsVector.va_quick_Vcipherlast",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Words_s.nat32",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.AES.AES_BE_s.aes_encrypt_word_def",
"Vale.AES.AES_BE_s.aes_encrypt_word_reveal",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.Def.Types_s.quad32_xor",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.AES128.va_code_AES128EncryptBlock_6way"
] | [] | false | false | false | false | false | let va_qcode_AES128EncryptBlock_6way
(va_mods: va_mods_t)
(in1 in2 in3 in4 in5 in6: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_buffer: buffer128)
: (va_quickCode unit (va_code_AES128EncryptBlock_6way ())) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 307 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540: (FStar.Seq.Base.seq a_539)) (i_541: Prims.nat) ->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540))) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init1:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in1
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 308 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540: (FStar.Seq.Base.seq a_539)) (i_541: Prims.nat) ->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540))) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init2:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in2
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 309 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540: (FStar.Seq.Base.seq a_539)) (i_541: Prims.nat) ->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515 (FStar.Seq.Base.length #a_539 s_540))
) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init3:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in3
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 310 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun a_539 (s_540: (FStar.Seq.Base.seq a_539)) (i_541: Prims.nat) ->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515
(FStar.Seq.Base.length #a_539 s_540))) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init4:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in4
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32 round_keys 0)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 311 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun
a_539
(s_540: (FStar.Seq.Base.seq a_539))
(i_541: Prims.nat)
->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515
(FStar.Seq.Base.length #a_539 s_540))) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init5:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in5
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32
round_keys
0)
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 312 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
((fun
a_539
(s_540: (FStar.Seq.Base.seq a_539))
(i_541: Prims.nat)
->
let i_515:Prims.nat = i_541 in
Prims.b2t (Prims.op_LessThan i_515
(FStar.Seq.Base.length #a_539 s_540))) Vale.Def.Types_s.quad32
round_keys
0)
(fun _ ->
let init6:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor in6
(FStar.Seq.Base.index #Vale.Def.Types_s.quad32
round_keys
0)
in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 314 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 10) 0)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet
0)
(va_op_vec_opr_vec 6)
(va_op_reg_opr_reg 4)
(va_op_reg_opr_reg 10)
Secret
keys_buffer
0)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 316 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 317 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 318 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 319 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3
)
(va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 320 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec
4)
(va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 321 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec
5)
(va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 6))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 322 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
1
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 323 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
2
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 324 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
3
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 325 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
4
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 326 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
5
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 327 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(va_quick_AES128EncryptRound_6way
6
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 328 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_AES128EncryptRound_6way
7
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 329 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_AES128EncryptRound_6way
8
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 330 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_AES128EncryptRound_6way
9
init1
init2
init3
init4
init5
init6
round_keys
keys_buffer
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 331 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_LoadImm64
(
va_op_reg_opr_reg
10
)
(
16
`op_Multiply`
10
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 332 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Load128_byte16_buffer_index
(
va_op_heaplet_mem_heaplet
0
)
(
va_op_vec_opr_vec
6
)
(
va_op_reg_opr_reg
4
)
(
va_op_reg_opr_reg
10
)
Secret
keys_buffer
10
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 333 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
0
)
(
va_op_vec_opr_vec
0
)
(
va_op_vec_opr_vec
6
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 334 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
1
)
(
va_op_vec_opr_vec
1
)
(
va_op_vec_opr_vec
6
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 335 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
2
)
(
va_op_vec_opr_vec
2
)
(
va_op_vec_opr_vec
6
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 336 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
3
)
(
va_op_vec_opr_vec
3
)
(
va_op_vec_opr_vec
6
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 337 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
4
)
(
va_op_vec_opr_vec
4
)
(
va_op_vec_opr_vec
6
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 338 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vcipherlast
(
va_op_vec_opr_vec
5
)
(
va_op_vec_opr_vec
5
)
(
va_op_vec_opr_vec
6
)
)
(
va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 341 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
6
)
(
va_op_vec_opr_vec
6
)
(
va_op_vec_opr_vec
6
)
)
(
fun
(
va_s:
va_state
)
_
->
va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 342 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.AES128.vaf *****"
(
fun
(
_:
unit
)
->
Vale.AES.AES_BE_s.aes_encrypt_word_reveal
()
)
(
va_QEmpty
(
()
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))) | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.empty | val empty : env | val empty : env | let empty _ = None | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 68,
"start_col": 0,
"start_line": 68
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": 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 | StlcCbvDbPntSubstNoLists.env | Prims.Tot | [
"total"
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"FStar.Pervasives.Native.None",
"StlcCbvDbPntSubstNoLists.ty",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let empty _ =
| None | false |
Hacl.Bignum25519.fsti | Hacl.Bignum25519.gett | val gett (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 15ul 5ul /\ h0 == h1) | val gett (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 15ul 5ul /\ h0 == h1) | let gett (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 15ul 5ul /\ h0 == h1)
= sub p 15ul 5ul | {
"file_name": "code/ed25519/Hacl.Bignum25519.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 47,
"start_col": 0,
"start_line": 44
} | module Hacl.Bignum25519
module ST = FStar.HyperStack.ST
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module BSeq = Lib.ByteSequence
module S51 = Hacl.Spec.Curve25519.Field51.Definition
module F51 = Hacl.Impl.Ed25519.Field51
module SC = Spec.Curve25519
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(* Type abbreviations *)
inline_for_extraction noextract
let felem = lbuffer uint64 5ul
(* A point is buffer of size 20, that is 4 consecutive buffers of size 5 *)
inline_for_extraction noextract
let point = lbuffer uint64 20ul
inline_for_extraction noextract
let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1)
= sub p 0ul 5ul
inline_for_extraction noextract
let gety (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1)
= sub p 5ul 5ul
inline_for_extraction noextract
let getz (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 10ul 5ul /\ h0 == h1)
= sub p 10ul 5ul | {
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Finv.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum25519.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S51"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": 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 | p: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Hacl.Bignum25519.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Bignum25519.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum25519.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let gett (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 15ul 5ul /\ h0 == h1) =
| sub p 15ul 5ul | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.par_incr | val par_incr (#v0 #v1: erased int) (x0 x1: ref int)
: C unit
((pts_to x0 v0) `star` (pts_to x1 v1))
(fun _ -> (pts_to x0 (v0 + 1)) `star` (pts_to x1 (v1 + 1))) | val par_incr (#v0 #v1: erased int) (x0 x1: ref int)
: C unit
((pts_to x0 v0) `star` (pts_to x1 v1))
(fun _ -> (pts_to x0 (v0 + 1)) `star` (pts_to x1 (v1 + 1))) | let par_incr (#v0 #v1:erased int)
(x0 x1: ref int)
: C unit (pts_to x0 v0 `star` pts_to x1 v1)
(fun _ -> pts_to x0 (v0 + 1) `star` pts_to x1 (v1 + 1))
= par_c (fun _ -> incr x0)
(fun _ -> incr x1) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 28,
"end_line": 488,
"start_col": 0,
"start_line": 483
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every
/// frameable action
let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k)
(**
* [par]: Parallel composition
* Works by just using the `Par` node and `Ret` as its continuation
**)
let par #s (#c:comm_monoid s)
#p0 #q0 (m0:m unit p0 (fun _ -> q0))
#p1 #q1 (m1:m unit p1 (fun _ -> q1))
: Dv (m unit (p0 `c.star` p1) (fun _ -> q0 `c.star` q1))
= let m0' : m (U.raise_t unit) p0 (fun _ -> q0) =
bind m0 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
let m1' : m (U.raise_t unit) p1 (fun _ -> q1) =
bind m1 (fun _ -> Ret (U.raise_val u#0 u#0 ()))
in
Par p0 q0 m0'
p1 q1 m1'
(Ret ())
////////////////////////////////////////////////////////////////////////////////
//The rest of this module shows how this semantic can be packaged up as an
//effect in F*
////////////////////////////////////////////////////////////////////////////////
/// Now for an instantiation of the state with a heap
/// just to demonstrate how that would go
/// Heaps are usually in a universe higher than the values they store
/// Pick it in universe 1
assume val heap : Type u#1
[@@erasable]
assume type r : Type u#1
assume val emp : r
assume val star : r -> r -> r
assume val interp : r -> heap -> prop
/// Assume some monoid of heap assertions
let hm : comm_monoid u#1 u#1 heap = {
r = r;
emp = emp;
star = star;
interp = interp;
laws = magic()
}
/// The representation of our effect is a thunked,
/// potentially divergent `m` computation
let comp (a:Type u#a) (p:hm.r) (q:a -> hm.r)
= unit -> Dv (m a p q)
let ret (a:Type u#a) (x:a) (p: a -> hm.r)
: comp a (p x) p
= fun _ -> return x p
let bnd (a:Type u#a) (b:Type u#b) (p:hm.r) (q: a -> hm.r) (r: b -> hm.r)
(f:comp a p q) (g: (x:a -> comp b (q x) r))
: comp b p r
= fun _ -> bind (f()) (fun x -> g x ())
reifiable
reflectable
effect {
C (a:Type) (pre:hm.r) (q: a -> hm.r)
with { repr = comp;
return = ret;
bind = bnd }
}
////////////////////////////////////////////////////////////////////////////////
// Some technicalities to lift pure and divergent computations to our new effect
////////////////////////////////////////////////////////////////////////////////
assume
val bind_pure_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> PURE a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (PURE, C) |> C = bind_pure_c_
assume
val bind_div_c_ (a:Type) (b:Type)
(wp:pure_wp a)
(pre:hm.r)
(post:b -> hm.r)
(f:eqtype_as_type unit -> DIV a wp)
(g:(x:a -> comp b pre post))
: Pure (comp b
pre
post)
(requires wp (fun _ -> True))
(ensures fun _ -> True)
polymonadic_bind (DIV, C) |> C = bind_div_c_
////////////////////////////////////////////////////////////////////////////////
// Assuming a simple heap model for this demo
////////////////////////////////////////////////////////////////////////////////
open FStar.Ghost
/// For this demo, we'll also assume that this assertions are affine
/// i.e., it's ok to forget some properties of the heap
assume
val hm_affine (r0 r1:hm.r) (h:heap)
: Lemma (hm.interp (r0 `hm.star` r1) h ==>
hm.interp r0 h)
/// Here's a ref type
assume
val ref : Type u#0 -> Type u#0
/// And two atomic heap assertions
assume
val pts_to (r:ref 'a) (x:'a) : hm.r
assume
val pure (p:prop) : hm.r
/// sel: Selected a reference from a heap, when that ref is live
assume
val sel (x:ref 'a) (v:erased 'a) (h:heap{hm.interp (pts_to x v) h})
: 'a
/// this tells us that sel is frameable
assume
val sel_ok (x:ref 'a) (v:erased 'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v `hm.star` frame) h ==>
(hm_affine (pts_to x v) frame h;
let v' = sel x v h in
hm.interp ((pts_to x v `hm.star` pure (reveal v == v')) `hm.star` frame) h))
/// upd: updates a heap at a given reference, when the heap contains it
assume
val upd (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap{hm.interp (pts_to x v0) h})
: Tot heap
/// and upd is frameable too
assume
val upd_ok (x:ref 'a) (v0:erased 'a) (v:'a) (h:heap) (frame:hm.r)
: Lemma (hm.interp (pts_to x v0 `hm.star` frame) h ==>
(hm_affine (pts_to x v0) frame h;
let h' = upd x v0 v h in
hm.interp (pts_to x v `hm.star` frame) h'))
assume
val rewrite (#a:Type u#a) (p: a -> hm.r) (x:erased a) (y:a)
: C unit (p y `star` pure (reveal x == y)) (fun _ -> p x)
////////////////////////////////////////////////////////////////////////////////
/// Here's a sample action for dereference
let (!) (#v0:erased 'a) (x:ref 'a)
: C 'a (pts_to x v0) (fun v -> pts_to x v0 `star` pure (reveal v0 == v))
= C?.reflect (fun _ ->
let act : action hm 'a =
{
pre = pts_to x v0;
post = (fun v -> pts_to x v0 `star` pure (reveal v0 == v)) ;
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
sel_ok x v0 h0 frame;
(| sel x v0 h0, h0 |))
} in
Act act Ret)
/// And a sample action for assignment
let (:=) (#v0:erased 'a) (x:ref 'a) (v:'a)
: C unit (pts_to x v0) (fun _ -> pts_to x v)
= C?.reflect (fun _ ->
let act : action hm unit =
{
pre = pts_to x v0;
post = (fun _ -> pts_to x v);
sem = (fun frame h0 ->
hm_affine (pts_to x v0) frame h0;
upd_ok x v0 v h0 frame;
(| (), upd x v0 v h0 |))
} in
Act act Ret)
let frame_r (#a:Type u#a) (#p:hm.r) (#q: a -> hm.r) (#fr:hm.r)
(f: unit -> C a p q)
: C a (p `star` fr) (fun x -> q x `star` fr)
= let ff : m a p q = (reify (f())) () in
C?.reflect (fun () -> frame fr ff)
let par_c (#p0:hm.r) (#q0: hm.r)
(#p1:hm.r) (#q1: hm.r)
($f0: unit -> C unit p0 (fun _ -> q0))
($f1: unit -> C unit p1 (fun _ -> q1))
: C unit (p0 `star` p1) (fun _ -> q0 `star` q1)
= let ff0 : m unit p0 (fun _ -> q0) = reify (f0()) () in
let ff1 : m unit p1 (fun _ -> q1) = reify (f1()) () in
C?.reflect (fun () -> par ff0 ff1)
let incr (#v0:erased int) (x:ref int)
: C unit (pts_to x v0) (fun u -> pts_to x (v0 + 1))
= let v = !x in
frame_r (fun _ -> x := v + 1);
rewrite (fun y -> pts_to x (y + 1)) v0 v | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 | x0: OPLSS2021.ParNDSDiv.ref Prims.int -> x1: OPLSS2021.ParNDSDiv.ref Prims.int
-> OPLSS2021.ParNDSDiv.C Prims.unit | OPLSS2021.ParNDSDiv.C | [] | [] | [
"FStar.Ghost.erased",
"Prims.int",
"OPLSS2021.ParNDSDiv.ref",
"OPLSS2021.ParNDSDiv.par_c",
"OPLSS2021.ParNDSDiv.pts_to",
"FStar.Ghost.reveal",
"Prims.op_Addition",
"Prims.unit",
"OPLSS2021.ParNDSDiv.incr",
"OPLSS2021.ParNDSDiv.star",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.heap",
"OPLSS2021.ParNDSDiv.hm"
] | [] | false | true | false | false | false | let par_incr (#v0 #v1: erased int) (x0 x1: ref int)
: C unit
((pts_to x0 v0) `star` (pts_to x1 v1))
(fun _ -> (pts_to x0 (v0 + 1)) `star` (pts_to x1 (v1 + 1))) =
| par_c (fun _ -> incr x0) (fun _ -> incr x1) | false |
Steel.Primitive.ForkJoin.Unix.fst | Steel.Primitive.ForkJoin.Unix.example4 | val example4: Prims.unit -> SteelK (ref int) emp (fun r -> pts_to r full_perm 2) | val example4: Prims.unit -> SteelK (ref int) emp (fun r -> pts_to r full_perm 2) | let example4 () : SteelK (ref int) emp (fun r -> pts_to r full_perm 2) =
let x = alloc_pt 0 in
let y = alloc_pt 1 in
let p1:thread (pts_to x full_perm 1) = kfork (fun _ -> write_pt #_ #0 x 1) in
let p2:thread emp = kfork (fun _ -> free_pt #_ #1 y) in
kjoin p1;
write_pt #_ #1 x 2;
kjoin p2;
x | {
"file_name": "lib/steel/Steel.Primitive.ForkJoin.Unix.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 3,
"end_line": 275,
"start_col": 0,
"start_line": 267
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Primitive.ForkJoin.Unix
(* This module shows that it's possible to layer continuations on top
of SteelT to get a direct style (or Unix style) fork/join. Very much a
prototype for now. *)
open FStar.Ghost
open Steel.Memory
open Steel.Effect.Atomic
open Steel.Effect
open Steel.Reference
open Steel.Primitive.ForkJoin
#set-options "--warn_error -330" //turn off the experimental feature warning
#set-options "--ide_id_info_off"
// (* Some helpers *)
let change_slprop_equiv (p q : vprop)
(proof : squash (p `equiv` q))
: SteelT unit p (fun _ -> q)
= rewrite_slprop p q (fun _ -> proof; reveal_equiv p q)
let change_slprop_imp (p q : vprop)
(proof : squash (p `can_be_split` q))
: SteelT unit p (fun _ -> q)
= rewrite_slprop p q (fun _ -> proof; reveal_can_be_split ())
(* Continuations into unit, but parametrized by the final heap
* proposition and with an implicit framing. I think ideally these would
* also be parametric in the final type (instead of being hardcoded to
* unit) but that means fork needs to be extended to be polymorphic in
* at least one of the branches. *)
type steelK (t:Type u#aa) (framed:bool) (pre : vprop) (post:t->vprop) =
#frame:vprop -> #postf:vprop ->
f:(x:t -> SteelT unit (frame `star` post x) (fun _ -> postf)) ->
SteelT unit (frame `star` pre) (fun _ -> postf)
(* The classic continuation monad *)
let return_ a (x:a) (#[@@@ framing_implicit] p: a -> vprop) : steelK a true (return_pre (p x)) p =
fun k -> k x
private
let rearrange3 (p q r:vprop) : Lemma
(((p `star` q) `star` r) `equiv` (p `star` (r `star` q)))
= let open FStar.Tactics in
assert (((p `star` q) `star` r) `equiv` (p `star` (r `star` q))) by
(norm [delta_attr [`%__reduce__]]; canon' false (`true_p) (`true_p))
private
let equiv_symmetric (p1 p2:vprop)
: Lemma (requires p1 `equiv` p2) (ensures p2 `equiv` p1)
= reveal_equiv p1 p2;
equiv_symmetric (hp_of p1) (hp_of p2);
reveal_equiv p2 p1
private
let can_be_split_forall_frame (#a:Type) (p q:post_t a) (frame:vprop) (x:a)
: Lemma (requires can_be_split_forall p q)
(ensures (frame `star` p x) `can_be_split` (frame `star` q x))
= let frame = hp_of frame in
let p = hp_of (p x) in
let q = hp_of (q x) in
reveal_can_be_split ();
assert (slimp p q);
slimp_star p q frame frame;
Steel.Memory.star_commutative p frame;
Steel.Memory.star_commutative q frame
let bind (a:Type) (b:Type)
(#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] pre_g:a -> pre_t) (#[@@@ framing_implicit] post_g:post_t b)
(#[@@@ framing_implicit] frame_f:vprop) (#[@@@ framing_implicit] frame_g:vprop)
(#[@@@ framing_implicit] p:squash (can_be_split_forall
(fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g)))
(#[@@@ framing_implicit] m1 : squash (maybe_emp framed_f frame_f))
(#[@@@ framing_implicit] m2:squash (maybe_emp framed_g frame_g))
(f:steelK a framed_f pre_f post_f)
(g:(x:a -> steelK b framed_g (pre_g x) post_g))
: steelK b
true
(pre_f `star` frame_f)
(fun y -> post_g y `star` frame_g)
= fun #frame (#post:vprop) (k:(y:b -> SteelT unit (frame `star` (post_g y `star` frame_g)) (fun _ -> post))) ->
// Need SteelT unit (frame `star` (pre_f `star` frame_f)) (fun _ -> post)
change_slprop_equiv (frame `star` (pre_f `star` frame_f)) ((frame `star` frame_f) `star` pre_f) (rearrange3 frame frame_f pre_f;
equiv_symmetric ((frame `star` frame_f) `star` pre_f) (frame `star` (pre_f `star` frame_f)) );
f #(frame `star` frame_f) #post
((fun (x:a) ->
// Need SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post)
change_slprop_imp
(frame `star` (post_f x `star` frame_f))
(frame `star` (pre_g x `star` frame_g))
(can_be_split_forall_frame (fun x -> post_f x `star` frame_f) (fun x -> pre_g x `star` frame_g) frame x);
g x #(frame `star` frame_g) #post
((fun (y:b) -> k y)
<: (y:b -> SteelT unit ((frame `star` frame_g) `star` post_g y) (fun _ -> post)))
)
<: (x:a -> SteelT unit ((frame `star` frame_f) `star` post_f x) (fun _ -> post)))
let subcomp (a:Type)
(#framed_f:eqtype_as_type bool) (#framed_g:eqtype_as_type bool)
(#[@@@ framing_implicit] pre_f:pre_t) (#[@@@ framing_implicit] post_f:post_t a)
(#[@@@ framing_implicit] pre_g:pre_t) (#[@@@ framing_implicit] post_g:post_t a)
(#[@@@ framing_implicit] p1:squash (can_be_split pre_g pre_f))
(#[@@@ framing_implicit] p2:squash (can_be_split_forall post_f post_g))
(f:steelK a framed_f pre_f post_f)
: Tot (steelK a framed_g pre_g post_g)
= fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post_g x) (fun _ -> postf))) ->
change_slprop_imp pre_g pre_f ();
f #frame #postf ((fun x -> change_slprop_imp (frame `star` post_f x) (frame `star` post_g x)
(can_be_split_forall_frame post_f post_g frame x);
k x) <: (x:a -> SteelT unit (frame `star` post_f x) (fun _ -> postf)))
// let if_then_else (a:Type u#aa)
// (#[@@@ framing_implicit] pre1:pre_t)
// (#[@@@ framing_implicit] post1:post_t a)
// (f : steelK a pre1 post1)
// (g : steelK a pre1 post1)
// (p:Type0) : Type =
// steelK a pre1 post1
// We did not define a bind between Div and Steel, so we indicate
// SteelKF as total to be able to reify and compose it when implementing fork
// This module is intended as proof of concept
total
reifiable
reflectable
layered_effect {
SteelKBase : a:Type -> framed:bool -> pre:vprop -> post:(a->vprop) -> Effect
with
repr = steelK;
return = return_;
bind = bind;
subcomp = subcomp
// if_then_else = if_then_else
}
effect SteelK (a:Type) (pre:pre_t) (post:post_t a) =
SteelKBase a false pre post
effect SteelKF (a:Type) (pre:pre_t) (post:post_t a) =
SteelKBase a true pre post
// We would need requires/ensures in SteelK to have a binding with Pure.
// But for our example, Tot is here sufficient
let bind_tot_steelK_ (a:Type) (b:Type)
(#framed:eqtype_as_type bool)
(#[@@@ framing_implicit] pre:pre_t) (#[@@@ framing_implicit] post:post_t b)
(f:eqtype_as_type unit -> Tot a) (g:(x:a -> steelK b framed pre post))
: steelK b
framed
pre
post
= fun #frame #postf (k:(x:b -> SteelT unit (frame `star` post x) (fun _ -> postf))) ->
let x = f () in
g x #frame #postf k
polymonadic_bind (PURE, SteelKBase) |> SteelKBase = bind_tot_steelK_
// (* Sanity check *)
let test_lift #p #q (f : unit -> SteelK unit p (fun _ -> q)) : SteelK unit p (fun _ -> q) =
();
f ();
()
(* Identity cont with frame, to eliminate a SteelK *)
let idk (#frame:vprop) (#a:Type) (x:a) : SteelT a frame (fun x -> frame)
= noop(); return x
let kfork (#p:vprop) (#q:vprop) (f : unit -> SteelK unit p (fun _ -> q))
: SteelK (thread q) p (fun _ -> emp)
=
SteelK?.reflect (
fun (#frame:vprop) (#postf:vprop)
(k : (x:(thread q) -> SteelT unit (frame `star` emp) (fun _ -> postf))) ->
noop ();
let t1 () : SteelT unit (emp `star` p) (fun _ -> q) =
let r : steelK unit false p (fun _ -> q) = reify (f ()) in
r #emp #q (fun _ -> idk())
in
let t2 (t:thread q) () : SteelT unit frame (fun _ -> postf) = k t in
let ff () : SteelT unit (p `star` frame) (fun _ -> postf) =
fork #p #q #frame #postf t1 t2
in
ff())
let kjoin (#p:vprop) (t : thread p) : SteelK unit emp (fun _ -> p)
= SteelK?.reflect (fun #f k -> join t; k ())
(* Example *)
assume val q : int -> vprop
assume val f : unit -> SteelK unit emp (fun _ -> emp)
assume val g : i:int -> SteelK unit emp (fun _ -> q i)
assume val h : unit -> SteelK unit emp (fun _ -> emp)
let example () : SteelK unit emp (fun _ -> q 1 `star` q 2) =
let p1:thread (q 1) = kfork (fun () -> g 1) in
let p2:thread (q 2) = kfork (fun () -> g 2) in
kjoin p1;
h();
kjoin p2
let as_steelk_repr' (a:Type) (pre:pre_t) (post:post_t a) (f:unit -> SteelT a pre post)
: steelK a false pre post
= fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) ->
let x = f () in
k x
let triv_pre (req:vprop) : req_t req = fun _ -> True
let triv_post (#a:Type) (req:vprop) (ens:post_t a) : ens_t req a ens = fun _ _ _ -> True
let as_steelk_repr (a:Type) (pre:pre_t) (post:post_t a)
(f:repr a false pre post (triv_pre pre) (triv_post pre post))// unit -> SteelT a pre post)
: steelK a false pre post
= as_steelk_repr' a pre post (fun _ -> SteelBase?.reflect f)
// let as_steelk_repr' (a:Type) (pre:slprop) (post:post_t a) (f:unit -> SteelT a pre post)
// : steelK a pre post
// = fun #frame #postf (k:(x:a -> SteelT unit (frame `star` post x) (fun _ -> postf))) ->
// let x = f () in
// k x
// let as_steelk (#a:Type) (#pre:slprop) (#post:post_t a) ($f:unit -> SteelT a pre post)
// : SteelK a pre post
// = SteelK?.reflect (as_steelk_repr a pre post f)
open Steel.FractionalPermission
sub_effect SteelBase ~> SteelKBase = as_steelk_repr
let example2 (r:ref int) : SteelK (thread (pts_to r full_perm 1)) (pts_to r full_perm 0) (fun _ -> emp) =
let p1 = kfork (fun _ -> write_pt #_ #0 r 1) in
p1
let alloc_pt (#a:Type) (x:a)
: SteelT (ref a) emp (fun r -> pts_to r full_perm x)
= alloc_pt x
let example3 (r:ref int) : SteelK (ref int) (pts_to r full_perm 0) (fun x -> pts_to r full_perm 1 `star` pts_to x full_perm 2) =
let p1 = kfork (fun _ -> write_pt #_ #0 r 1) in
let x = alloc_pt 2 in
kjoin p1;
x | {
"checked_file": "/",
"dependencies": [
"Steel.Reference.fsti.checked",
"Steel.Primitive.ForkJoin.fsti.checked",
"Steel.Memory.fsti.checked",
"Steel.FractionalPermission.fst.checked",
"Steel.Effect.Atomic.fsti.checked",
"Steel.Effect.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Primitive.ForkJoin.Unix.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Primitive.ForkJoin",
"short_module": null
},
{
"abbrev": 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 -> Steel.Primitive.ForkJoin.Unix.SteelK (Steel.Reference.ref Prims.int) | Steel.Primitive.ForkJoin.Unix.SteelK | [] | [] | [
"Prims.unit",
"Steel.Reference.ref",
"Prims.int",
"Steel.Primitive.ForkJoin.Unix.kjoin",
"Steel.Effect.Common.emp",
"Steel.Reference.write_pt",
"FStar.Ghost.hide",
"Steel.Reference.pts_to",
"Steel.FractionalPermission.full_perm",
"Steel.Primitive.ForkJoin.thread",
"Steel.Primitive.ForkJoin.Unix.kfork",
"FStar.Ghost.reveal",
"Steel.Reference.free_pt",
"Steel.Primitive.ForkJoin.Unix.alloc_pt",
"Steel.Effect.Common.vprop"
] | [] | false | true | false | false | false | let example4 () : SteelK (ref int) emp (fun r -> pts_to r full_perm 2) =
| let x = alloc_pt 0 in
let y = alloc_pt 1 in
let p1:thread (pts_to x full_perm 1) = kfork (fun _ -> write_pt #_ #0 x 1) in
let p2:thread emp = kfork (fun _ -> free_pt #_ #1 y) in
kjoin p1;
write_pt #_ #1 x 2;
kjoin p2;
x | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.subst_beta | val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e) | val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e) | let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2) | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 44,
"start_col": 0,
"start_line": 38
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: StlcCbvDbPntSubstNoLists.var ->
v: StlcCbvDbPntSubstNoLists.exp ->
e: StlcCbvDbPntSubstNoLists.exp
-> Prims.Tot StlcCbvDbPntSubstNoLists.exp | Prims.Tot | [
"total",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.exp",
"Prims.op_Equality",
"Prims.bool",
"Prims.op_LessThan",
"StlcCbvDbPntSubstNoLists.EVar",
"Prims.op_Subtraction",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.EAbs",
"StlcCbvDbPntSubstNoLists.subst_beta",
"Prims.op_Addition",
"StlcCbvDbPntSubstNoLists.EApp"
] | [
"recursion"
] | false | false | false | true | false | let rec subst_beta x v e =
| match e with
| EVar y -> if y = x then v else if y < x then EVar y else EVar (y - 1)
| EAbs t e1 -> EAbs t (subst_beta (x + 1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2) | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.step | val step : exp -> Tot (option exp) | val step : exp -> Tot (option exp) | let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 63,
"start_col": 0,
"start_line": 47
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": 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: StlcCbvDbPntSubstNoLists.exp -> FStar.Pervasives.Native.option StlcCbvDbPntSubstNoLists.exp | Prims.Tot | [
"total"
] | [] | [
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.is_value",
"StlcCbvDbPntSubstNoLists.ty",
"FStar.Pervasives.Native.Some",
"StlcCbvDbPntSubstNoLists.subst_beta",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"Prims.bool",
"StlcCbvDbPntSubstNoLists.step",
"StlcCbvDbPntSubstNoLists.EApp"
] | [
"recursion"
] | false | false | false | true | false | let rec step e =
| match e with
| EApp e1 e2 ->
if is_value e1
then
if is_value e2
then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None | false |
OPLSS2021.ParNDSDiv.fst | OPLSS2021.ParNDSDiv.frame | val frame
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#p: c.r)
(#q: (a -> c.r))
(fr: c.r)
(f: m a p q)
: Dv (m a (p `c.star` fr) (fun x -> (q x) `c.star` fr)) | val frame
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#p: c.r)
(#q: (a -> c.r))
(fr: c.r)
(f: m a p q)
: Dv (m a (p `c.star` fr) (fun x -> (q x) `c.star` fr)) | let rec frame (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#p:c.r)
(#q:a -> c.r)
(fr:c.r)
(f:m a p q)
: Dv (m a (p `c.star` fr) (fun x -> q x `c.star` fr))
= match f with
| Ret x -> Ret x
| Act f k ->
Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0)
pre1 post1 m1
(frame fr k) | {
"file_name": "examples/oplss2021/OPLSS2021.ParNDSDiv.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 275,
"start_col": 0,
"start_line": 260
} | (*
Copyright 2019-2021 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 OPLSS2021.ParNDSDiv
module U = FStar.Universe
(**
* This module provides a semantic model for a combined effect of
* divergence, state and parallel composition of atomic actions.
*
* It also builds a generic separation-logic-style program logic
* for this effect, in a partial correctness setting.
* It is also be possible to give a variant of this semantics for
* total correctness. However, we specifically focus on partial correctness
* here so that this semantics can be instantiated with lock operations,
* which may deadlock. See ParTot.fst for a total-correctness variant of
* these semantics.
*
*)
/// We start by defining some basic notions for a commutative monoid.
///
/// We could reuse FStar.Algebra.CommMonoid, but this style with
/// quanitifers was more convenient for the proof done here.
let associative #a (f: a -> a -> a) =
forall x y z. f x (f y z) == f (f x y) z
let commutative #a (f: a -> a -> a) =
forall x y. f x y == f y x
let is_unit #a (x:a) (f:a -> a -> a) =
forall y. f x y == y /\ f y x == y
(**
* In addition to being a commutative monoid over the carrier [r]
* a [comm_monoid s] also gives an interpretation of `r`
* as a predicate on states [s]
*)
noeq
type comm_monoid (s:Type) = {
r:Type;
emp: r;
star: r -> r -> r;
interp: r -> s -> prop;
laws: squash (associative star /\ commutative star /\ is_unit emp star)
}
(** [post a c] is a postcondition on [a]-typed result *)
let post #s a (c:comm_monoid s) = a -> c.r
(** [action c s]: atomic actions are, intuitively, single steps of
* computations interpreted as a [s -> a & s].
* However, we augment them with two features:
* 1. they have pre-condition [pre] and post-condition [post]
* 2. their type guarantees that they are frameable
* Thanks to Matt Parkinson for suggesting to set up atomic actions
* this way.
* Also see: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/views.pdf
*)
noeq
type action #s (c:comm_monoid s) (a:Type) = {
pre: c.r;
post: a -> c.r;
sem: (frame:c.r ->
s0:s{c.interp (c.star pre frame) s0} ->
(x:a & s1:s{c.interp (post x `c.star` frame) s1}));
}
(** [m s c a pre post] :
* A free monad for divergence, state and parallel composition
* with generic actions. The main idea:
*
* Every continuation may be divergent. As such, [m] is indexed by
* pre- and post-conditions so that we can do proofs
* intrinsically.
*
* Universe-polymorphic in both the state and result type
*
*)
noeq
type m (#s:Type u#s) (#c:comm_monoid u#s u#s s) : (a:Type u#a) -> c.r -> post a c -> Type =
| Ret : #a:_ -> #post:(a -> c.r) -> x:a -> m a (post x) post
| Act : #a:_ -> #post:(a -> c.r) -> #b:_ -> f:action c b -> k:(x:b -> Dv (m a (f.post x) post)) -> m a f.pre post
| Par : pre0:_ -> post0:_ -> m0: m (U.raise_t unit) pre0 (fun _ -> post0) ->
pre1:_ -> post1:_ -> m1: m (U.raise_t unit) pre1 (fun _ -> post1) ->
#a:_ -> #post:_ -> k:m a (c.star post0 post1) post ->
m a (c.star pre0 pre1) post
/// We assume a stream of booleans for the semantics given below
/// to resolve the nondeterminism of Par
assume
val bools : nat -> bool
/// The semantics comes in two levels:
///
/// 1. A single-step relation [step] which selects an atomic action to
/// execute in the tree of threads
///
/// 2. A top-level driver [run] which repeatedly invokes [step]
/// until it returns with a result and final state.
(**
* [step_result s c a q frame]:
* The result of evaluating a single step of a program
* - s, c: The state and its monoid
* - a : the result type
* - q : the postcondition to be satisfied after fully reducing the programs
* - frame: a framed assertion to carry through the proof
*)
noeq
type step_result #s (#c:comm_monoid s) a (q:post a c) (frame:c.r) =
| Step: p:_ -> //precondition of the reduct
m a p q -> //the reduct
state:s {c.interp (p `c.star` frame) state} -> //the next state, satisfying the precondition of the reduct
nat -> //position in the stream of booleans (less important)
step_result a q frame
(**
* [step i f frame state]: Reduces a single step of [f], while framing
* the assertion [frame]
*
*)
let rec step #s #c (i:nat) #pre #a #post (f:m a pre post) (frame:c.r) (state:s)
: Div (step_result a post frame)
(requires
c.interp (pre `c.star` frame) state)
(ensures fun _ -> True)
= match f with
| Ret x ->
//Nothing to do, just return
Step (post x) (Ret x) state i
| Act act1 k ->
//Evaluate the action and return the continuation as the reduct
let (| b, state' |) = act1.sem frame state in
Step (act1.post b) (k b) state' i
| Par pre0 post0 (Ret x0)
pre1 post1 (Ret x1)
k ->
//If both sides of a `Par` have returned
//then step to the continuation
Step (post0 `c.star` post1) k state i
| Par pre0 post0 m0
pre1 post1 m1
k ->
//Otherwise, sample a boolean and choose to go left or right to pick
//the next command to reduce
//The two sides are symmetric
if bools i
then let Step pre0' m0' state' j =
//Notice that, inductively, we instantiate the frame extending
//it to include the precondition of the other side of the par
step (i + 1) m0 (pre1 `c.star` frame) state in
Step (pre0' `c.star` pre1) (Par pre0' post0 m0' pre1 post1 m1 k) state' j
else let Step pre1' m1' state' j =
step (i + 1) m1 (pre0 `c.star` frame) state in
Step (pre0 `c.star` pre1') (Par pre0 post0 m0 pre1' post1 m1' k) state' j
(**
* [run i f state]: Top-level driver that repeatedly invokes [step]
*
* The type of [run] is the main theorem. It states that it is sound
* to interpret the indices of `m` as a Hoare triple in a
* partial-correctness semantics
*
*)
let rec run #s #c (i:nat) #pre #a #post (f:m a pre post) (state:s)
: Div (a & s)
(requires
c.interp pre state)
(ensures fun (x, state') ->
c.interp (post x) state')
= match f with
| Ret x -> x, state
| _ ->
let Step pre' f' state' j = step i f c.emp state in
run j f' state'
/// eff is a dependent parameterized monad. We give a return and bind
/// for it, though we don't prove the monad laws
(** [return]: easy, just use Ret *)
let return #s (#c:comm_monoid s) #a (x:a) (post:a -> c.r)
: m a (post x) post
= Ret x
(**
* [bind]: sequential composition works by pushing `g` into the continuation
* at each node, finally applying it at the terminal `Ret`
*)
let rec bind (#s:Type u#s)
(#c:comm_monoid s)
(#a:Type u#a)
(#b:Type u#b)
(#p:c.r)
(#q:a -> c.r)
(#r:b -> c.r)
(f:m a p q)
(g: (x:a -> Dv (m b (q x) r)))
: Dv (m b p r)
= match f with
| Ret x -> g x
| Act act k ->
Act act (fun x -> bind (k x) g)
| Par pre0 post0 ml
pre1 post1 mr
k ->
let k : m b (post0 `c.star` post1) r = bind k g in
let ml' : m (U.raise_t u#0 u#b unit) pre0 (fun _ -> post0) =
bind ml (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
let mr' : m (U.raise_t u#0 u#b unit) pre1 (fun _ -> post1) =
bind mr (fun _ -> Ret (U.raise_val u#0 u#b ()))
in
Par #s #c pre0 post0 ml'
pre1 post1 mr'
#b #r k
(* Next, a main property of this semantics is that it supports the
frame rule. Here's a proof of it *)
/// First, we prove that individual actions can be framed
///
/// --- That's not so hard, since we specifically required actions to
/// be frameable
let frame_action (#s:Type) (#c:comm_monoid s) (#a:Type) (f:action c a) (fr:c.r)
: g:action c a { g.post == (fun x -> f.post x `c.star` fr) /\
g.pre == f.pre `c.star` fr }
= let pre = f.pre `c.star` fr in
let post x = f.post x `c.star` fr in
let sem (frame:c.r) (s0:s{c.interp (c.star pre frame) s0})
: (x:a & s1:s{c.interp (post x `c.star` frame) s1})
= let (| x, s1 |) = f.sem (fr `c.star` frame) s0 in
(| x, s1 |)
in
{ pre = pre;
post = post;
sem = sem }
/// Now, to prove that computations can be framed, we'll just thread
/// the frame through the entire computation, passing it over every | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "OPLSS2021.ParNDSDiv.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Universe",
"short_module": "U"
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": false,
"full_module": "OPLSS2021",
"short_module": null
},
{
"abbrev": 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 | fr: Mkcomm_monoid?.r c -> f: OPLSS2021.ParNDSDiv.m a p q
-> FStar.Pervasives.Dv
(OPLSS2021.ParNDSDiv.m a (Mkcomm_monoid?.star c p fr) (fun x -> Mkcomm_monoid?.star c (q x) fr)) | FStar.Pervasives.Dv | [] | [] | [
"OPLSS2021.ParNDSDiv.comm_monoid",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__r",
"OPLSS2021.ParNDSDiv.m",
"OPLSS2021.ParNDSDiv.Ret",
"OPLSS2021.ParNDSDiv.__proj__Mkcomm_monoid__item__star",
"OPLSS2021.ParNDSDiv.action",
"OPLSS2021.ParNDSDiv.__proj__Mkaction__item__post",
"OPLSS2021.ParNDSDiv.Act",
"OPLSS2021.ParNDSDiv.frame_action",
"OPLSS2021.ParNDSDiv.frame",
"FStar.Universe.raise_t",
"Prims.unit",
"OPLSS2021.ParNDSDiv.post",
"OPLSS2021.ParNDSDiv.Par"
] | [
"recursion"
] | false | true | false | false | false | let rec frame
(#s: Type u#s)
(#c: comm_monoid s)
(#a: Type u#a)
(#p: c.r)
(#q: (a -> c.r))
(fr: c.r)
(f: m a p q)
: Dv (m a (p `c.star` fr) (fun x -> (q x) `c.star` fr)) =
| match f with
| Ret x -> Ret x
| Act f k -> Act (frame_action f fr) (fun x -> frame fr (k x))
| Par pre0 post0 m0 pre1 post1 m1 k ->
Par (pre0 `c.star` fr) (post0 `c.star` fr) (frame fr m0) pre1 post1 m1 (frame fr k) | false |
Hacl.Spec.K256.MathLemmas.fst | Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52 | val lemma_distr5_pow52 (a b0 b1 b2 b3 b4:int) : Lemma
(a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208) | val lemma_distr5_pow52 (a b0 b1 b2 b3 b4:int) : Lemma
(a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208) | let lemma_distr5_pow52 a b0 b1 b2 b3 b4 =
calc (==) {
a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208);
(==) { lemma_distr5 b0 (b1 * pow2 52) (b2 * pow2 104) (b3 * pow2 156) (b4 * pow2 208) a }
b0 * a + b1 * pow2 52 * a + b2 * pow2 104 * a + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b1 (pow2 52) a; lemma_swap_mul3 b2 (pow2 104) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b3 (pow2 156) a; lemma_swap_mul3 b4 (pow2 208) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * a * pow2 156 + b4 * a * pow2 208;
} | {
"file_name": "code/k256/Hacl.Spec.K256.MathLemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 199,
"start_col": 0,
"start_line": 190
} | module Hacl.Spec.K256.MathLemmas
open FStar.Mul
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val lemma_swap_mul3 (a b c:int) : Lemma (a * b * c == a * c * b)
let lemma_swap_mul3 a b c =
calc (==) {
a * b * c;
(==) { Math.Lemmas.paren_mul_right a b c }
a * (b * c);
(==) { Math.Lemmas.swap_mul b c }
a * (c * b);
(==) { Math.Lemmas.paren_mul_right a c b }
a * c * b;
}
val lemma_mod_mul_distr (a b:int) (n:pos) : Lemma (a * b % n = (a % n) * (b % n) % n)
let lemma_mod_mul_distr a b n =
Math.Lemmas.lemma_mod_mul_distr_l a b n;
Math.Lemmas.lemma_mod_mul_distr_r (a % n) b n
val lemma_mod_sub_distr (a b:int) (n:pos) : Lemma ((a - b) % n = (a % n - b % n) % n)
let lemma_mod_sub_distr a b n =
Math.Lemmas.lemma_mod_plus_distr_l a (- b) n;
Math.Lemmas.lemma_mod_sub_distr (a % n) b n
val lemma_ab_le_cd (a b c d:nat) : Lemma
(requires a <= c /\ b <= d)
(ensures a * b <= c * d)
let lemma_ab_le_cd a b c d =
Math.Lemmas.lemma_mult_le_left a b d;
Math.Lemmas.lemma_mult_le_right d a c
val lemma_ab_lt_cd (a b c d:pos) : Lemma
(requires a < c /\ b < d)
(ensures a * b < c * d)
let lemma_ab_lt_cd a b c d =
Math.Lemmas.lemma_mult_lt_left a b d;
Math.Lemmas.lemma_mult_lt_right d a c
val lemma_bound_mul64_wide (ma mb:nat) (mma mmb:nat) (a b:nat) : Lemma
(requires a <= ma * mma /\ b <= mb * mmb)
(ensures a * b <= ma * mb * (mma * mmb))
let lemma_bound_mul64_wide ma mb mma mmb a b =
calc (<=) {
a * b;
(<=) { lemma_ab_le_cd a b (ma * mma) (mb * mmb) }
(ma * mma) * (mb * mmb);
(==) { Math.Lemmas.paren_mul_right ma mma (mb * mmb) }
ma * (mma * (mb * mmb));
(==) {
Math.Lemmas.paren_mul_right mma mb mmb;
Math.Lemmas.swap_mul mma mb;
Math.Lemmas.paren_mul_right mb mma mmb }
ma * (mb * (mma * mmb));
(==) { Math.Lemmas.paren_mul_right ma mb (mma * mmb) }
ma * mb * (mma * mmb);
}
val lemma_distr_pow (a b:int) (c d:nat) : Lemma ((a + b * pow2 c) * pow2 d = a * pow2 d + b * pow2 (c + d))
let lemma_distr_pow a b c d =
calc (==) {
(a + b * pow2 c) * pow2 d;
(==) { Math.Lemmas.distributivity_add_left a (b * pow2 c) (pow2 d) }
a * pow2 d + b * pow2 c * pow2 d;
(==) { Math.Lemmas.paren_mul_right b (pow2 c) (pow2 d); Math.Lemmas.pow2_plus c d }
a * pow2 d + b * pow2 (c + d);
}
val lemma_distr_pow_pow (a:int) (b:nat) (c:int) (d e:nat) :
Lemma ((a * pow2 b + c * pow2 d) * pow2 e = a * pow2 (b + e) + c * pow2 (d + e))
let lemma_distr_pow_pow a b c d e =
calc (==) {
(a * pow2 b + c * pow2 d) * pow2 e;
(==) { lemma_distr_pow (a * pow2 b) c d e }
a * pow2 b * pow2 e + c * pow2 (d + e);
(==) { Math.Lemmas.paren_mul_right a (pow2 b) (pow2 e); Math.Lemmas.pow2_plus b e }
a * pow2 (b + e) + c * pow2 (d + e);
}
val lemma_distr_eucl_mul (r a:int) (b:pos) : Lemma (r * (a % b) + r * (a / b) * b = r * a)
let lemma_distr_eucl_mul r a b =
calc (==) {
r * (a % b) + r * (a / b) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b) b }
r * (a % b) + r * ((a / b) * b);
(==) { Math.Lemmas.distributivity_add_right r (a % b) (a / b * b) }
r * (a % b + a / b * b);
(==) { Math.Lemmas.euclidean_division_definition a b }
r * a;
}
val lemma_distr_eucl_mul_add (r a c:int) (b:pos) : Lemma (r * (a % b) + r * (a / b + c) * b = r * a + r * c * b)
let lemma_distr_eucl_mul_add r a c b =
calc (==) {
r * (a % b) + r * (a / b + c) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b + c) b }
r * (a % b) + r * ((a / b + c) * b);
(==) { Math.Lemmas.distributivity_add_left (a / b) c b }
r * (a % b) + r * ((a / b * b) + c * b);
(==) { Math.Lemmas.distributivity_add_right r (a / b * b) (c * b) }
r * (a % b) + r * (a / b * b) + r * (c * b);
(==) { Math.Lemmas.paren_mul_right r (a / b) b; Math.Lemmas.paren_mul_right r c b }
r * (a % b) + r * (a / b) * b + r * c * b;
(==) { lemma_distr_eucl_mul r a b }
r * a + r * c * b;
}
val lemma_distr_eucl (a b:int) : Lemma ((a / pow2 52 + b) * pow2 52 + a % pow2 52 = a + b * pow2 52)
let lemma_distr_eucl a b = lemma_distr_eucl_mul_add 1 a b (pow2 52)
val lemma_a_plus_b_pow2_mod2 (a b:int) (c:pos) : Lemma ((a + b * pow2 c) % 2 = a % 2)
let lemma_a_plus_b_pow2_mod2 a b c =
assert_norm (pow2 1 = 2);
Math.Lemmas.lemma_mod_plus_distr_r a (b * pow2 c) 2;
Math.Lemmas.pow2_multiplication_modulo_lemma_1 b 1 c
val lemma_as_nat64_horner (r0 r1 r2 r3:int) :
Lemma (r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192 ==
((r3 * pow2 64 + r2) * pow2 64 + r1) * pow2 64 + r0)
let lemma_as_nat64_horner r0 r1 r2 r3 =
calc (==) {
r0 + pow2 64 * (r1 + pow2 64 * (r2 + pow2 64 * r3));
(==) { Math.Lemmas.swap_mul (pow2 64) (r1 + pow2 64 * (r2 + pow2 64 * r3)) }
r0 + (r1 + pow2 64 * (r2 + pow2 64 * r3)) * pow2 64;
(==) { Math.Lemmas.swap_mul (pow2 64) (r2 + pow2 64 * r3) }
r0 + (r1 + (r2 + pow2 64 * r3) * pow2 64) * pow2 64;
(==) { lemma_distr_pow r1 (r2 + pow2 64 * r3) 64 64 }
r0 + r1 * pow2 64 + (r2 + pow2 64 * r3) * pow2 128;
(==) { Math.Lemmas.swap_mul (pow2 64) r3 }
r0 + r1 * pow2 64 + (r2 + r3 * pow2 64) * pow2 128;
(==) { lemma_distr_pow r2 r3 64 128 }
r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192;
}
val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0)
let lemma_as_nat_horner r0 r1 r2 r3 r4 =
calc (==) {
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
(==) { lemma_distr_pow r1 ((r4 * pow2 52 + r3) * pow2 52 + r2) 52 52 }
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r2 (r4 * pow2 52 + r3) 52 104 }
(r4 * pow2 52 + r3) * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r3 r4 52 156 }
r4 * pow2 208 + r3 * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
}
val lemma_distr5 (a0 a1 a2 a3 a4 b:int) : Lemma
((a0 + a1 + a2 + a3 + a4) * b = a0 * b + a1 * b + a2 * b + a3 * b + a4 * b)
let lemma_distr5 a0 a1 a2 a3 a4 b =
calc (==) {
(a0 + a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a0 (a1 + a2 + a3 + a4) b }
a0 * b + (a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a1 (a2 + a3 + a4) b }
a0 * b + a1 * b + (a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a2 (a3 + a4) b }
a0 * b + a1 * b + a2 * b + (a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a3 a4 b }
a0 * b + a1 * b + a2 * b + a3 * b + a4 * b;
}
val lemma_distr5_pow52 (a b0 b1 b2 b3 b4:int) : Lemma
(a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.MathLemmas.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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: Prims.int -> b0: Prims.int -> b1: Prims.int -> b2: Prims.int -> b3: Prims.int -> b4: Prims.int
-> FStar.Pervasives.Lemma
(ensures
a *
(b0 + b1 * Prims.pow2 52 + b2 * Prims.pow2 104 + b3 * Prims.pow2 156 + b4 * Prims.pow2 208) =
a * b0 + (a * b1) * Prims.pow2 52 + (a * b2) * Prims.pow2 104 + (a * b3) * Prims.pow2 156 +
(a * b4) * Prims.pow2 208) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Calc.calc_finish",
"Prims.eq2",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.MathLemmas.lemma_distr5",
"Prims.squash",
"Hacl.Spec.K256.MathLemmas.lemma_swap_mul3"
] | [] | false | false | true | false | false | let lemma_distr5_pow52 a b0 b1 b2 b3 b4 =
| calc ( == ) {
a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208);
( == ) { lemma_distr5 b0 (b1 * pow2 52) (b2 * pow2 104) (b3 * pow2 156) (b4 * pow2 208) a }
b0 * a + (b1 * pow2 52) * a + (b2 * pow2 104) * a + (b3 * pow2 156) * a + (b4 * pow2 208) * a;
( == ) { (lemma_swap_mul3 b1 (pow2 52) a;
lemma_swap_mul3 b2 (pow2 104) a) }
b0 * a + (b1 * a) * pow2 52 + (b2 * a) * pow2 104 + (b3 * pow2 156) * a + (b4 * pow2 208) * a;
( == ) { (lemma_swap_mul3 b3 (pow2 156) a;
lemma_swap_mul3 b4 (pow2 208) a) }
b0 * a + (b1 * a) * pow2 52 + (b2 * a) * pow2 104 + (b3 * a) * pow2 156 + (b4 * a) * pow2 208;
} | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.typable_empty_closed | val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e))) | val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e))) | let typable_empty_closed x #e #t h = free_in_context x h | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 120,
"start_col": 0,
"start_line": 120
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h)
let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2
val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: StlcCbvDbPntSubstNoLists.var ->
h: StlcCbvDbPntSubstNoLists.rtyping StlcCbvDbPntSubstNoLists.empty e t
-> FStar.Pervasives.Lemma
(ensures Prims.op_Negation (StlcCbvDbPntSubstNoLists.appears_free_in x e)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.empty",
"StlcCbvDbPntSubstNoLists.free_in_context",
"Prims.unit"
] | [] | true | false | true | false | false | let typable_empty_closed x #e #t h =
| free_in_context x h | false |
Hacl.Bignum25519.fsti | Hacl.Bignum25519.getz | val getz (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 10ul 5ul /\ h0 == h1) | val getz (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 10ul 5ul /\ h0 == h1) | let getz (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 10ul 5ul /\ h0 == h1)
= sub p 10ul 5ul | {
"file_name": "code/ed25519/Hacl.Bignum25519.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 18,
"end_line": 41,
"start_col": 0,
"start_line": 38
} | module Hacl.Bignum25519
module ST = FStar.HyperStack.ST
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
module BSeq = Lib.ByteSequence
module S51 = Hacl.Spec.Curve25519.Field51.Definition
module F51 = Hacl.Impl.Ed25519.Field51
module SC = Spec.Curve25519
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(* Type abbreviations *)
inline_for_extraction noextract
let felem = lbuffer uint64 5ul
(* A point is buffer of size 20, that is 4 consecutive buffers of size 5 *)
inline_for_extraction noextract
let point = lbuffer uint64 20ul
inline_for_extraction noextract
let getx (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 0ul 5ul /\ h0 == h1)
= sub p 0ul 5ul
inline_for_extraction noextract
let gety (p:point) : Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 5ul 5ul /\ h0 == h1)
= sub p 5ul 5ul | {
"checked_file": "/",
"dependencies": [
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Curve25519.Finv.fst.checked",
"Hacl.Spec.Curve25519.Field51.Definition.fst.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum25519.fsti"
} | [
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Curve25519.Field51.Definition",
"short_module": "S51"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl",
"short_module": null
},
{
"abbrev": 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 | p: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Hacl.Bignum25519.felem | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Bignum25519.point",
"Lib.Buffer.sub",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum25519.felem",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Prims.l_and",
"Prims.eq2",
"Lib.Buffer.gsub"
] | [] | false | true | false | false | false | let getz (p: point)
: Stack felem
(requires fun h -> live h p)
(ensures fun h0 f h1 -> f == gsub p 10ul 5ul /\ h0 == h1) =
| sub p 10ul 5ul | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.free_in_context | val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h) | val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h) | let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2 | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 61,
"end_line": 115,
"start_col": 0,
"start_line": 111
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: StlcCbvDbPntSubstNoLists.var -> h: StlcCbvDbPntSubstNoLists.rtyping g e t
-> FStar.Pervasives.Lemma (ensures StlcCbvDbPntSubstNoLists.appears_free_in x e ==> Some? (g x))
(decreases h) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"StlcCbvDbPntSubstNoLists.extend",
"StlcCbvDbPntSubstNoLists.free_in_context",
"Prims.op_Addition",
"StlcCbvDbPntSubstNoLists.TArrow",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec free_in_context x #e #g #t h =
| match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x + 1) h1
| TyApp h1 h2 ->
free_in_context x h1;
free_in_context x h2 | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.appears_free_in | val appears_free_in : x:var -> e:exp -> Tot bool (decreases e) | val appears_free_in : x:var -> e:exp -> Tot bool (decreases e) | let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1 | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 41,
"end_line": 107,
"start_col": 0,
"start_line": 103
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | x: StlcCbvDbPntSubstNoLists.var -> e: StlcCbvDbPntSubstNoLists.exp -> Prims.Tot Prims.bool | Prims.Tot | [
"total",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.exp",
"Prims.op_Equality",
"Prims.op_BarBar",
"StlcCbvDbPntSubstNoLists.appears_free_in",
"StlcCbvDbPntSubstNoLists.ty",
"Prims.op_Addition",
"Prims.bool"
] | [
"recursion"
] | false | false | false | true | false | let rec appears_free_in x e =
| match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x + 1) e1 | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.typing_extensional | val typing_extensional : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equal g g'} ->
Tot (rtyping g' e t) | val typing_extensional : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equal g g'} ->
Tot (rtyping g' e t) | let typing_extensional #e #g #t h g' = context_invariance h g' | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 144,
"start_col": 0,
"start_line": 144
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h)
let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2
val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e)))
(* [SMTPat (appears_free_in x e)] -- CH: adding this makes it fail! *)
let typable_empty_closed x #e #t h = free_in_context x h
val typable_empty_closed' : #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (forall (x:var). (not(appears_free_in x e))))
let typable_empty_closed' #e #t h = admit() (* CH: need forall_intro for showing this *)
type equal (g1:env) (g2:env) = forall (x:var). g1 x = g2 x
type equalE (e:exp) (g1:env) (g2:env) =
forall (x:var). appears_free_in x e ==> g1 x = g2 x
val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} ->
Tot (rtyping g' e t) (decreases h)
let rec context_invariance #e #g #t h g' =
match h with
| TyVar x -> TyVar x
| TyAbs t_y h1 ->
TyAbs t_y (context_invariance h1 (extend g' 0 t_y))
| TyApp h1 h2 ->
TyApp (context_invariance h1 g') (context_invariance h2 g')
val typing_extensional : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equal g g'} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: StlcCbvDbPntSubstNoLists.rtyping g e t ->
g': StlcCbvDbPntSubstNoLists.env{StlcCbvDbPntSubstNoLists.equal g g'}
-> StlcCbvDbPntSubstNoLists.rtyping g' e t | Prims.Tot | [
"total"
] | [] | [
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.equal",
"StlcCbvDbPntSubstNoLists.context_invariance"
] | [] | false | false | false | false | false | let typing_extensional #e #g #t h g' =
| context_invariance h g' | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.extend | val extend : env -> var -> ty -> Tot env | val extend : env -> var -> ty -> Tot env | let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1) | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 73,
"start_col": 0,
"start_line": 71
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": 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 | g: StlcCbvDbPntSubstNoLists.env -> x: StlcCbvDbPntSubstNoLists.var -> t: StlcCbvDbPntSubstNoLists.ty
-> StlcCbvDbPntSubstNoLists.env | Prims.Tot | [
"total"
] | [] | [
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.ty",
"Prims.op_LessThan",
"Prims.bool",
"Prims.op_Equality",
"FStar.Pervasives.Native.Some",
"Prims.op_Subtraction",
"FStar.Pervasives.Native.option"
] | [] | false | false | false | true | false | let extend g x t y =
| if y < x then g y else if y = x then Some t else g (y - 1) | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.progress | val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h) | val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h) | let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2 | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 100,
"start_col": 0,
"start_line": 96
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | h: StlcCbvDbPntSubstNoLists.rtyping StlcCbvDbPntSubstNoLists.empty e t
-> FStar.Pervasives.Lemma
(ensures StlcCbvDbPntSubstNoLists.is_value e \/ Some? (StlcCbvDbPntSubstNoLists.step e))
(decreases h) | FStar.Pervasives.Lemma | [
"lemma",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.empty",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.var",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"StlcCbvDbPntSubstNoLists.extend",
"StlcCbvDbPntSubstNoLists.TArrow",
"StlcCbvDbPntSubstNoLists.progress",
"Prims.unit"
] | [
"recursion"
] | false | false | true | false | false | let rec progress #e #t h =
| match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 ->
progress h1;
progress h2 | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.context_invariance | val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} ->
Tot (rtyping g' e t) (decreases h) | val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} ->
Tot (rtyping g' e t) (decreases h) | let rec context_invariance #e #g #t h g' =
match h with
| TyVar x -> TyVar x
| TyAbs t_y h1 ->
TyAbs t_y (context_invariance h1 (extend g' 0 t_y))
| TyApp h1 h2 ->
TyApp (context_invariance h1 g') (context_invariance h2 g') | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 63,
"end_line": 139,
"start_col": 0,
"start_line": 133
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h)
let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2
val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e)))
(* [SMTPat (appears_free_in x e)] -- CH: adding this makes it fail! *)
let typable_empty_closed x #e #t h = free_in_context x h
val typable_empty_closed' : #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (forall (x:var). (not(appears_free_in x e))))
let typable_empty_closed' #e #t h = admit() (* CH: need forall_intro for showing this *)
type equal (g1:env) (g2:env) = forall (x:var). g1 x = g2 x
type equalE (e:exp) (g1:env) (g2:env) =
forall (x:var). appears_free_in x e ==> g1 x = g2 x
val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h: StlcCbvDbPntSubstNoLists.rtyping g e t ->
g': StlcCbvDbPntSubstNoLists.env{StlcCbvDbPntSubstNoLists.equalE e g g'}
-> Prims.Tot (StlcCbvDbPntSubstNoLists.rtyping g' e t) | Prims.Tot | [
"total",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.equalE",
"StlcCbvDbPntSubstNoLists.var",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"StlcCbvDbPntSubstNoLists.TyVar",
"StlcCbvDbPntSubstNoLists.extend",
"StlcCbvDbPntSubstNoLists.TyAbs",
"StlcCbvDbPntSubstNoLists.context_invariance",
"StlcCbvDbPntSubstNoLists.TArrow",
"StlcCbvDbPntSubstNoLists.TyApp"
] | [
"recursion"
] | false | false | false | false | false | let rec context_invariance #e #g #t h g' =
| match h with
| TyVar x -> TyVar x
| TyAbs t_y h1 -> TyAbs t_y (context_invariance h1 (extend g' 0 t_y))
| TyApp h1 h2 -> TyApp (context_invariance h1 g') (context_invariance h2 g') | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.preservation | val preservation : #e:exp -> #t:ty -> h:rtyping empty e t{Some? (step e)} ->
Tot (rtyping empty (Some?.v (step e)) t) (decreases e) | val preservation : #e:exp -> #t:ty -> h:rtyping empty e t{Some? (step e)} ->
Tot (rtyping empty (Some?.v (step e)) t) (decreases e) | let rec preservation #e #t h =
let TyApp #g #e1 #e2 #t11 #t12 h1 h2 = h in
if is_value e1
then (if is_value e2
then let TyAbs t_x hbody = h1 in
substitution_preserves_typing 0 h2 hbody
else TyApp h1 (preservation h2))
//^^^^^^^^^^^^^^^^^
else TyApp (preservation h1) h2 | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 36,
"end_line": 177,
"start_col": 0,
"start_line": 169
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h)
let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2
val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e)))
(* [SMTPat (appears_free_in x e)] -- CH: adding this makes it fail! *)
let typable_empty_closed x #e #t h = free_in_context x h
val typable_empty_closed' : #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (forall (x:var). (not(appears_free_in x e))))
let typable_empty_closed' #e #t h = admit() (* CH: need forall_intro for showing this *)
type equal (g1:env) (g2:env) = forall (x:var). g1 x = g2 x
type equalE (e:exp) (g1:env) (g2:env) =
forall (x:var). appears_free_in x e ==> g1 x = g2 x
val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} ->
Tot (rtyping g' e t) (decreases h)
let rec context_invariance #e #g #t h g' =
match h with
| TyVar x -> TyVar x
| TyAbs t_y h1 ->
TyAbs t_y (context_invariance h1 (extend g' 0 t_y))
| TyApp h1 h2 ->
TyApp (context_invariance h1 g') (context_invariance h2 g')
val typing_extensional : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equal g g'} ->
Tot (rtyping g' e t)
let typing_extensional #e #g #t h g' = context_invariance h g'
val substitution_preserves_typing :
x:var -> #e:exp -> #v:exp -> #t_x:ty -> #t:ty -> #g:env ->
h1:rtyping empty v t_x ->
h2:rtyping (extend g x t_x) e t ->
Tot (rtyping g (subst_beta x v e) t) (decreases e)
let rec substitution_preserves_typing x #e #v #t_x #t #g h1 h2 =
match h2 with
| TyVar y ->
if x=y then (typable_empty_closed' h1; context_invariance h1 g)
else if y<x then context_invariance h2 g
else TyVar (y-1)
| TyAbs #g' t_y #e' #t' h21 ->
(let h21' = typing_extensional h21 (extend (extend g 0 t_y) (x+1) t_x) in
TyAbs t_y (substitution_preserves_typing (x+1) h1 h21'))
| TyApp #g' #e1 #e2 #t11 #t12 h21 h22 ->
(* CH: implicits don't work here, why? *)
(* NS: They do now *)
(TyApp // #g #(subst_beta x v e1) #(subst_beta x v e2) #t11 #t12
(substitution_preserves_typing x h1 h21)
(substitution_preserves_typing x h1 h22))
val preservation : #e:exp -> #t:ty -> h:rtyping empty e t{Some? (step e)} -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
h:
StlcCbvDbPntSubstNoLists.rtyping StlcCbvDbPntSubstNoLists.empty e t
{Some? (StlcCbvDbPntSubstNoLists.step e)}
-> Prims.Tot
(StlcCbvDbPntSubstNoLists.rtyping StlcCbvDbPntSubstNoLists.empty
(Some?.v (StlcCbvDbPntSubstNoLists.step e))
t) | Prims.Tot | [
"total",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.empty",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"StlcCbvDbPntSubstNoLists.step",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.TArrow",
"StlcCbvDbPntSubstNoLists.is_value",
"StlcCbvDbPntSubstNoLists.extend",
"StlcCbvDbPntSubstNoLists.substitution_preserves_typing",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Prims.bool",
"StlcCbvDbPntSubstNoLists.TyApp",
"StlcCbvDbPntSubstNoLists.preservation"
] | [
"recursion"
] | false | false | false | false | false | let rec preservation #e #t h =
| let TyApp #g #e1 #e2 #t11 #t12 h1 h2 = h in
if is_value e1
then
(if is_value e2
then
let TyAbs t_x hbody = h1 in
substitution_preserves_typing 0 h2 hbody
else TyApp h1 (preservation h2))
else TyApp (preservation h1) h2 | false |
StlcCbvDbPntSubstNoLists.fst | StlcCbvDbPntSubstNoLists.substitution_preserves_typing | val substitution_preserves_typing :
x:var -> #e:exp -> #v:exp -> #t_x:ty -> #t:ty -> #g:env ->
h1:rtyping empty v t_x ->
h2:rtyping (extend g x t_x) e t ->
Tot (rtyping g (subst_beta x v e) t) (decreases e) | val substitution_preserves_typing :
x:var -> #e:exp -> #v:exp -> #t_x:ty -> #t:ty -> #g:env ->
h1:rtyping empty v t_x ->
h2:rtyping (extend g x t_x) e t ->
Tot (rtyping g (subst_beta x v e) t) (decreases e) | let rec substitution_preserves_typing x #e #v #t_x #t #g h1 h2 =
match h2 with
| TyVar y ->
if x=y then (typable_empty_closed' h1; context_invariance h1 g)
else if y<x then context_invariance h2 g
else TyVar (y-1)
| TyAbs #g' t_y #e' #t' h21 ->
(let h21' = typing_extensional h21 (extend (extend g 0 t_y) (x+1) t_x) in
TyAbs t_y (substitution_preserves_typing (x+1) h1 h21'))
| TyApp #g' #e1 #e2 #t11 #t12 h21 h22 ->
(* CH: implicits don't work here, why? *)
(* NS: They do now *)
(TyApp // #g #(subst_beta x v e1) #(subst_beta x v e2) #t11 #t12
(substitution_preserves_typing x h1 h21)
(substitution_preserves_typing x h1 h22)) | {
"file_name": "examples/metatheory/StlcCbvDbPntSubstNoLists.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 165,
"start_col": 0,
"start_line": 151
} | (*
Copyright 2008-2014 Catalin Hritcu, Nikhil Swamy, Microsoft Research and Inria
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 StlcCbvDbPntSubstNoLists
type ty =
| TArrow : t1:ty -> t2:ty -> ty
type var = nat
type exp =
| EVar : var -> exp
| EApp : exp -> exp -> exp
| EAbs : ty -> exp -> exp
val is_value : exp -> Tot bool
let is_value = EAbs?
(* subst_beta is a generalization of the substitution we do for the beta rule,
when we've under x binders (useful for the substitution lemma) *)
(* This definition only works right for substituting _closed_ things
(otherwise it captures the variables in v, giving a wrong semantics);
this will be a problem when moving away from STLC! *)
val subst_beta : x:var -> v:exp -> e:exp -> Tot exp (decreases e)
let rec subst_beta x v e =
match e with
| EVar y -> if y = x then v
else if y < x then EVar y
else EVar (y-1)
| EAbs t e1 -> EAbs t (subst_beta (x+1) v e1)
| EApp e1 e2 -> EApp (subst_beta x v e1) (subst_beta x v e2)
val step : exp -> Tot (option exp)
let rec step e =
match e with
| EApp e1 e2 ->
if is_value e1 then
if is_value e2 then
match e1 with
| EAbs t e' -> Some (subst_beta 0 e2 e')
| _ -> None
else
match (step e2) with
| Some e2' -> Some (EApp e1 e2')
| None -> None
else
(match (step e1) with
| Some e1' -> Some (EApp e1' e2)
| None -> None)
| _ -> None
type env = var -> Tot (option ty)
val empty : env
let empty _ = None
val extend : env -> var -> ty -> Tot env
let extend g x t y = if y < x then g y
else if y = x then Some t
else g (y-1)
noeq type rtyping : env -> exp -> ty -> Type =
| TyVar : #g:env ->
x:var{Some? (g x)} ->
rtyping g (EVar x) (Some?.v (g x))
| TyAbs : #g:env ->
t:ty ->
#e1:exp ->
#t':ty ->
rtyping (extend g 0 t) e1 t' ->
rtyping g (EAbs t e1) (TArrow t t')
| TyApp : #g:env ->
#e1:exp ->
#e2:exp ->
#t11:ty ->
#t12:ty ->
rtyping g e1 (TArrow t11 t12) ->
rtyping g e2 t11 ->
rtyping g (EApp e1 e2) t12
val progress : #e:exp -> #t:ty -> h:rtyping empty e t ->
Lemma (requires True) (ensures (is_value e \/ (Some? (step e)))) (decreases h)
let rec progress #e #t h =
match h with
| TyVar _ -> ()
| TyAbs _ _ -> ()
| TyApp h1 h2 -> progress h1; progress h2
val appears_free_in : x:var -> e:exp -> Tot bool (decreases e)
let rec appears_free_in x e =
match e with
| EVar y -> x = y
| EApp e1 e2 -> appears_free_in x e1 || appears_free_in x e2
| EAbs _ e1 -> appears_free_in (x+1) e1
val free_in_context : x:var -> #e:exp -> #g:env -> #t:ty -> h:rtyping g e t ->
Lemma (requires True) (ensures (appears_free_in x e ==> Some? (g x))) (decreases h)
let rec free_in_context x #e #g #t h =
match h with
| TyVar x -> ()
| TyAbs t h1 -> free_in_context (x+1) h1
| TyApp h1 h2 -> free_in_context x h1; free_in_context x h2
val typable_empty_closed : x:var -> #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (not(appears_free_in x e)))
(* [SMTPat (appears_free_in x e)] -- CH: adding this makes it fail! *)
let typable_empty_closed x #e #t h = free_in_context x h
val typable_empty_closed' : #e:exp -> #t:ty -> rtyping empty e t ->
Lemma (ensures (forall (x:var). (not(appears_free_in x e))))
let typable_empty_closed' #e #t h = admit() (* CH: need forall_intro for showing this *)
type equal (g1:env) (g2:env) = forall (x:var). g1 x = g2 x
type equalE (e:exp) (g1:env) (g2:env) =
forall (x:var). appears_free_in x e ==> g1 x = g2 x
val context_invariance : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equalE e g g'} ->
Tot (rtyping g' e t) (decreases h)
let rec context_invariance #e #g #t h g' =
match h with
| TyVar x -> TyVar x
| TyAbs t_y h1 ->
TyAbs t_y (context_invariance h1 (extend g' 0 t_y))
| TyApp h1 h2 ->
TyApp (context_invariance h1 g') (context_invariance h2 g')
val typing_extensional : #e:exp -> #g:env -> #t:ty ->
h:(rtyping g e t) -> g':env{equal g g'} ->
Tot (rtyping g' e t)
let typing_extensional #e #g #t h g' = context_invariance h g'
val substitution_preserves_typing :
x:var -> #e:exp -> #v:exp -> #t_x:ty -> #t:ty -> #g:env ->
h1:rtyping empty v t_x ->
h2:rtyping (extend g x t_x) e t -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "StlcCbvDbPntSubstNoLists.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x: StlcCbvDbPntSubstNoLists.var ->
h1: StlcCbvDbPntSubstNoLists.rtyping StlcCbvDbPntSubstNoLists.empty v t_x ->
h2: StlcCbvDbPntSubstNoLists.rtyping (StlcCbvDbPntSubstNoLists.extend g x t_x) e t
-> Prims.Tot (StlcCbvDbPntSubstNoLists.rtyping g (StlcCbvDbPntSubstNoLists.subst_beta x v e) t) | Prims.Tot | [
"total",
""
] | [] | [
"StlcCbvDbPntSubstNoLists.var",
"StlcCbvDbPntSubstNoLists.exp",
"StlcCbvDbPntSubstNoLists.ty",
"StlcCbvDbPntSubstNoLists.env",
"StlcCbvDbPntSubstNoLists.rtyping",
"StlcCbvDbPntSubstNoLists.empty",
"StlcCbvDbPntSubstNoLists.extend",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.op_Equality",
"StlcCbvDbPntSubstNoLists.context_invariance",
"Prims.unit",
"StlcCbvDbPntSubstNoLists.typable_empty_closed'",
"Prims.bool",
"Prims.op_LessThan",
"StlcCbvDbPntSubstNoLists.TyVar",
"Prims.op_Subtraction",
"StlcCbvDbPntSubstNoLists.subst_beta",
"StlcCbvDbPntSubstNoLists.TyAbs",
"Prims.op_Addition",
"StlcCbvDbPntSubstNoLists.substitution_preserves_typing",
"StlcCbvDbPntSubstNoLists.typing_extensional",
"StlcCbvDbPntSubstNoLists.TArrow",
"StlcCbvDbPntSubstNoLists.TyApp"
] | [
"recursion"
] | false | false | false | false | false | let rec substitution_preserves_typing x #e #v #t_x #t #g h1 h2 =
| match h2 with
| TyVar y ->
if x = y
then
(typable_empty_closed' h1;
context_invariance h1 g)
else if y < x then context_invariance h2 g else TyVar (y - 1)
| TyAbs #g' t_y #e' #t' h21 ->
(let h21' = typing_extensional h21 (extend (extend g 0 t_y) (x + 1) t_x) in
TyAbs t_y (substitution_preserves_typing (x + 1) h1 h21'))
| TyApp #g' #e1 #e2 #t11 #t12 h21 h22 ->
(TyApp (substitution_preserves_typing x h1 h21) (substitution_preserves_typing x h1 h22)) | false |
Lib.LoopCombinators.fsti | Lib.LoopCombinators.fixed_i | val fixed_i : f: _ -> i: Prims.nat -> _ | let fixed_i f (i:nat) = f | {
"file_name": "lib/Lib.LoopCombinators.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 156,
"start_col": 0,
"start_line": 156
} | module Lib.LoopCombinators
(**
* fold_left-like loop combinator:
* [ repeat_left lo hi a f acc == f (hi - 1) .. ... (f (lo + 1) (f lo acc)) ]
*
* e.g. [ repeat_left 0 3 (fun _ -> list int) Cons [] == [2;1;0] ]
*
* It satisfies
* [ repeat_left lo hi (fun _ -> a) f acc == fold_left (flip f) acc [lo..hi-1] ]
*
* A simpler variant with a non-dependent accumuator used to be called [repeat_range]
*)
val repeat_left:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Tot (a hi) (decreases (hi - lo))
val repeat_left_all_ml:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> FStar.All.ML (a (i + 1)))
-> acc:a lo
-> FStar.All.ML (a hi)
(**
* fold_right-like loop combinator:
* [ repeat_right lo hi a f acc == f (hi - 1) .. ... (f (lo + 1) (f lo acc)) ]
*
* e.g. [ repeat_right 0 3 (fun _ -> list int) Cons [] == [2;1;0] ]
*
* It satisfies
* [ repeat_right lo hi (fun _ -> a) f acc == fold_right f acc [hi-1..lo] ]
*)
val repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Tot (a hi) (decreases (hi - lo))
val repeat_right_all_ml:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> FStar.All.ML (a (i + 1)))
-> acc:a lo
-> FStar.All.ML (a hi) (decreases (hi - lo))
(** Splitting a repetition *)
val repeat_right_plus:
lo:nat
-> mi:nat{lo <= mi}
-> hi:nat{mi <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Lemma (ensures
repeat_right lo hi a f acc ==
repeat_right mi hi a f (repeat_right lo mi a f acc))
(decreases hi)
(** Unfolding one iteration *)
val unfold_repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc0:a lo
-> i:nat{lo <= i /\ i < hi}
-> Lemma (
repeat_right lo (i + 1) a f acc0 ==
f i (repeat_right lo i a f acc0))
val eq_repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc0:a lo
-> Lemma (repeat_right lo lo a f acc0 == acc0)
(**
* [repeat_left] and [repeat_right] are equivalent.
*
* This follows from the third duality theorem
* [ fold_right f acc xs = fold_left (flip f) acc (reverse xs) ]
*)
val repeat_left_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Lemma (ensures repeat_right lo hi a f acc == repeat_left lo hi a f acc)
(decreases (hi - lo))
(**
* Repetition starting from 0
*
* Defined as [repeat_right] for convenience, but [repeat_left] may be more
* efficient when extracted to OCaml.
*)
val repeat_gen:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> a n
val repeat_gen_all_ml:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> FStar.All.ML (a (i + 1)))
-> acc0:a 0
-> FStar.All.ML (a n)
(** Unfolding one iteration *)
val unfold_repeat_gen:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> i:nat{i < n}
-> Lemma (repeat_gen (i + 1) a f acc0 == f i (repeat_gen i a f acc0))
val eq_repeat_gen0:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> Lemma (repeat_gen 0 a f acc0 == acc0)
val repeat_gen_def:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> Lemma (repeat_gen n a f acc0 == repeat_right 0 n a f acc0)
(**
* Repetition with a fixed accumulator type
*)
let fixed_a (a:Type) (i:nat) = a | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Lib.LoopCombinators.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | f: _ -> i: Prims.nat -> _ | Prims.Tot | [
"total"
] | [] | [
"Prims.nat"
] | [] | false | false | false | true | false | let fixed_i f (i: nat) =
| f | false |
|
Lib.LoopCombinators.fsti | Lib.LoopCombinators.fixed_a | val fixed_a : a: Type -> i: Prims.nat -> Type | let fixed_a (a:Type) (i:nat) = a | {
"file_name": "lib/Lib.LoopCombinators.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 154,
"start_col": 0,
"start_line": 154
} | module Lib.LoopCombinators
(**
* fold_left-like loop combinator:
* [ repeat_left lo hi a f acc == f (hi - 1) .. ... (f (lo + 1) (f lo acc)) ]
*
* e.g. [ repeat_left 0 3 (fun _ -> list int) Cons [] == [2;1;0] ]
*
* It satisfies
* [ repeat_left lo hi (fun _ -> a) f acc == fold_left (flip f) acc [lo..hi-1] ]
*
* A simpler variant with a non-dependent accumuator used to be called [repeat_range]
*)
val repeat_left:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Tot (a hi) (decreases (hi - lo))
val repeat_left_all_ml:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> FStar.All.ML (a (i + 1)))
-> acc:a lo
-> FStar.All.ML (a hi)
(**
* fold_right-like loop combinator:
* [ repeat_right lo hi a f acc == f (hi - 1) .. ... (f (lo + 1) (f lo acc)) ]
*
* e.g. [ repeat_right 0 3 (fun _ -> list int) Cons [] == [2;1;0] ]
*
* It satisfies
* [ repeat_right lo hi (fun _ -> a) f acc == fold_right f acc [hi-1..lo] ]
*)
val repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Tot (a hi) (decreases (hi - lo))
val repeat_right_all_ml:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> FStar.All.ML (a (i + 1)))
-> acc:a lo
-> FStar.All.ML (a hi) (decreases (hi - lo))
(** Splitting a repetition *)
val repeat_right_plus:
lo:nat
-> mi:nat{lo <= mi}
-> hi:nat{mi <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Lemma (ensures
repeat_right lo hi a f acc ==
repeat_right mi hi a f (repeat_right lo mi a f acc))
(decreases hi)
(** Unfolding one iteration *)
val unfold_repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc0:a lo
-> i:nat{lo <= i /\ i < hi}
-> Lemma (
repeat_right lo (i + 1) a f acc0 ==
f i (repeat_right lo i a f acc0))
val eq_repeat_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc0:a lo
-> Lemma (repeat_right lo lo a f acc0 == acc0)
(**
* [repeat_left] and [repeat_right] are equivalent.
*
* This follows from the third duality theorem
* [ fold_right f acc xs = fold_left (flip f) acc (reverse xs) ]
*)
val repeat_left_right:
lo:nat
-> hi:nat{lo <= hi}
-> a:(i:nat{lo <= i /\ i <= hi} -> Type)
-> f:(i:nat{lo <= i /\ i < hi} -> a i -> a (i + 1))
-> acc:a lo
-> Lemma (ensures repeat_right lo hi a f acc == repeat_left lo hi a f acc)
(decreases (hi - lo))
(**
* Repetition starting from 0
*
* Defined as [repeat_right] for convenience, but [repeat_left] may be more
* efficient when extracted to OCaml.
*)
val repeat_gen:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> a n
val repeat_gen_all_ml:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> FStar.All.ML (a (i + 1)))
-> acc0:a 0
-> FStar.All.ML (a n)
(** Unfolding one iteration *)
val unfold_repeat_gen:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> i:nat{i < n}
-> Lemma (repeat_gen (i + 1) a f acc0 == f i (repeat_gen i a f acc0))
val eq_repeat_gen0:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> Lemma (repeat_gen 0 a f acc0 == acc0)
val repeat_gen_def:
n:nat
-> a:(i:nat{i <= n} -> Type)
-> f:(i:nat{i < n} -> a i -> a (i + 1))
-> acc0:a 0
-> Lemma (repeat_gen n a f acc0 == repeat_right 0 n a f acc0)
(**
* Repetition with a fixed accumulator type
*) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.All.fst.checked"
],
"interface_file": false,
"source_file": "Lib.LoopCombinators.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Type -> i: Prims.nat -> Type | Prims.Tot | [
"total"
] | [] | [
"Prims.nat"
] | [] | false | false | false | true | true | let fixed_a (a: Type) (i: nat) =
| a | false |
|
HandleSmtGoal.fst | HandleSmtGoal.tac | val tac: Prims.unit -> Tac unit | val tac: Prims.unit -> Tac unit | let tac () : Tac unit =
dump "now" | {
"file_name": "examples/tactics/HandleSmtGoal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 7,
"start_col": 0,
"start_line": 6
} | module HandleSmtGoal
open FStar.Tactics.V2 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "HandleSmtGoal.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.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Stubs.Tactics.V2.Builtins.dump"
] | [] | false | true | false | false | false | let tac () : Tac unit =
| dump "now" | false |
HandleSmtGoal.fst | HandleSmtGoal.tac2 | val tac2: Prims.unit -> Tac unit | val tac2: Prims.unit -> Tac unit | let tac2 () : Tac unit =
apply_lemma (`test_lemma) | {
"file_name": "examples/tactics/HandleSmtGoal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 21,
"start_col": 0,
"start_line": 20
} | module HandleSmtGoal
open FStar.Tactics.V2
[@@ handle_smt_goals]
let tac () : Tac unit =
dump "now"
let f (x:int) : Pure unit (requires x == 2) (ensures fun _ -> True) =
assert (x == 2);
()
(* A bogus lemma, used only to obtain a simple goal that will not be solvable
if handle_smt_goal does not trigger. It also has a trivially true precondition,
but that is sent to SMT*)
assume
val test_lemma (_:unit) : Lemma (requires forall (x:nat). x >= 0) (ensures False) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "HandleSmtGoal.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.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.unit",
"FStar.Tactics.V2.Derived.apply_lemma"
] | [] | false | true | false | false | false | let tac2 () : Tac unit =
| apply_lemma (`test_lemma) | false |
HandleSmtGoal.fst | HandleSmtGoal.f | val f (x: int) : Pure unit (requires x == 2) (ensures fun _ -> True) | val f (x: int) : Pure unit (requires x == 2) (ensures fun _ -> True) | let f (x:int) : Pure unit (requires x == 2) (ensures fun _ -> True) =
assert (x == 2);
() | {
"file_name": "examples/tactics/HandleSmtGoal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 4,
"end_line": 11,
"start_col": 0,
"start_line": 9
} | module HandleSmtGoal
open FStar.Tactics.V2
[@@ handle_smt_goals]
let tac () : Tac unit =
dump "now" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "HandleSmtGoal.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 | x: Prims.int -> Prims.Pure Prims.unit | Prims.Pure | [] | [] | [
"Prims.int",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.l_True"
] | [] | false | false | false | false | false | let f (x: int) : Pure unit (requires x == 2) (ensures fun _ -> True) =
| assert (x == 2);
() | false |
HandleSmtGoal.fst | HandleSmtGoal.g | val g: Prims.unit -> Tot unit | val g: Prims.unit -> Tot unit | let g () : Tot unit =
assert (False) | {
"file_name": "examples/tactics/HandleSmtGoal.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 24,
"start_col": 0,
"start_line": 23
} | module HandleSmtGoal
open FStar.Tactics.V2
[@@ handle_smt_goals]
let tac () : Tac unit =
dump "now"
let f (x:int) : Pure unit (requires x == 2) (ensures fun _ -> True) =
assert (x == 2);
()
(* A bogus lemma, used only to obtain a simple goal that will not be solvable
if handle_smt_goal does not trigger. It also has a trivially true precondition,
but that is sent to SMT*)
assume
val test_lemma (_:unit) : Lemma (requires forall (x:nat). x >= 0) (ensures False)
[@@ handle_smt_goals]
let tac2 () : Tac unit =
apply_lemma (`test_lemma) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "HandleSmtGoal.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.unit -> Prims.unit | Prims.Tot | [
"total"
] | [] | [
"Prims.unit",
"Prims._assert",
"Prims.l_False"
] | [] | false | false | false | true | false | let g () : Tot unit =
| assert (False) | false |
TaskPool.fst | TaskPool.extract | val extract
(#p:pool)
(#a:Type0)
(#post : a -> vprop)
(th : task_handle p a post)
: stt a (handle_solved th) (fun x -> post x) | val extract
(#p:pool)
(#a:Type0)
(#post : a -> vprop)
(th : task_handle p a post)
: stt a (handle_solved th) (fun x -> post x) | let extract = __extract | {
"file_name": "share/steel/examples/pulse/parix/TaskPool.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 23,
"end_line": 65,
"start_col": 0,
"start_line": 65
} | (*
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 TaskPool
open Pulse.Lib.Pervasives
open Pulse.Lib.SpinLock
open Pulse.Lib.Par.Pledge
module T = FStar.Tactics.V2
let pool : Type0 = magic ()
let pool_alive (#[T.exact (`full_perm)]p : perm) (pool:pool) : vprop
= magic()
let pool_done = magic ()
let setup_pool (n:nat)
= magic ()
let task_handle pool a post = magic ()
let joinable #p #a #post th = magic ()
let joined #p #a #post th = magic ()
let handle_solved #p #a #post th = magic()
let spawn #a #pre #post p #e = magic ()
let spawn_ #pre #post p #e = magic ()
let must_be_done = magic ()
let join0 = magic ()
#set-options "--print_universes"
#set-options "--print_universes"
```pulse
fn __extract
(#p:pool)
(#a:Type0)
(#post : (a -> vprop))
(th : task_handle p a post)
requires handle_solved th
returns x:a
ensures post x
{
admit()
}
``` | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.SpinLock.fsti.checked",
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.Lib.Par.Pledge.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "TaskPool.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Par.Pledge",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Par.Pledge",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": 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 | th: TaskPool.task_handle p a post
-> Pulse.Lib.Core.stt a (TaskPool.handle_solved th) (fun x -> post x) | Prims.Tot | [
"total"
] | [] | [
"TaskPool.__extract"
] | [] | false | false | false | false | false | let extract =
| __extract | false |
TaskPool.fst | TaskPool.join | val join
(#p:pool)
(#a:Type0)
(#post : a -> vprop)
(th : task_handle p a post)
: stt a (joinable th) (fun x -> post x) | val join
(#p:pool)
(#a:Type0)
(#post : a -> vprop)
(th : task_handle p a post)
: stt a (joinable th) (fun x -> post x) | let join = __join | {
"file_name": "share/steel/examples/pulse/parix/TaskPool.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 17,
"end_line": 84,
"start_col": 0,
"start_line": 84
} | (*
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 TaskPool
open Pulse.Lib.Pervasives
open Pulse.Lib.SpinLock
open Pulse.Lib.Par.Pledge
module T = FStar.Tactics.V2
let pool : Type0 = magic ()
let pool_alive (#[T.exact (`full_perm)]p : perm) (pool:pool) : vprop
= magic()
let pool_done = magic ()
let setup_pool (n:nat)
= magic ()
let task_handle pool a post = magic ()
let joinable #p #a #post th = magic ()
let joined #p #a #post th = magic ()
let handle_solved #p #a #post th = magic()
let spawn #a #pre #post p #e = magic ()
let spawn_ #pre #post p #e = magic ()
let must_be_done = magic ()
let join0 = magic ()
#set-options "--print_universes"
#set-options "--print_universes"
```pulse
fn __extract
(#p:pool)
(#a:Type0)
(#post : (a -> vprop))
(th : task_handle p a post)
requires handle_solved th
returns x:a
ensures post x
{
admit()
}
```
let extract = __extract
let share_alive _ _ = admit()
let gather_alive _ _ = admit()
```pulse
fn __join
(#p:pool)
(#a:Type0)
(#post : (a -> vprop))
(th : task_handle p a post)
requires joinable th
returns x:a
ensures post x
{
join0 th;
extract th
} | {
"checked_file": "/",
"dependencies": [
"Pulse.Lib.SpinLock.fsti.checked",
"Pulse.Lib.Pervasives.fst.checked",
"Pulse.Lib.Par.Pledge.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "TaskPool.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Par.Pledge",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Par.Pledge",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.SpinLock",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Lib.Pervasives",
"short_module": null
},
{
"abbrev": 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 | th: TaskPool.task_handle p a post -> Pulse.Lib.Core.stt a (TaskPool.joinable th) (fun x -> post x) | Prims.Tot | [
"total"
] | [] | [
"TaskPool.__join"
] | [] | false | false | false | false | false | let join =
| __join | false |
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint8_t | val uint8_t : Prims.eqtype | let uint8_t = UInt8.t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 18,
"start_col": 0,
"start_line": 18
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt8.t"
] | [] | false | false | false | true | false | let uint8_t =
| UInt8.t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint32_t | val uint32_t : Prims.eqtype | let uint32_t = UInt32.t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t"
] | [] | false | false | false | true | false | let uint32_t =
| UInt32.t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint16_t | val uint16_t : Prims.eqtype | let uint16_t = UInt16.t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 20,
"start_col": 0,
"start_line": 20
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt16.t"
] | [] | false | false | false | true | false | let uint16_t =
| UInt16.t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint64_t | val uint64_t : Prims.eqtype | let uint64_t = UInt64.t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 24,
"start_col": 0,
"start_line": 24
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Prims.eqtype | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt64.t"
] | [] | false | false | false | true | false | let uint64_t =
| UInt64.t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint8_p | val uint8_p : Type0 | let uint8_p = B.buffer uint8_t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 27,
"start_col": 0,
"start_line": 27
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.buffer",
"EverCrypt.Helpers.uint8_t"
] | [] | false | false | false | true | true | let uint8_p =
| B.buffer uint8_t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint64_p | val uint64_p : Type0 | let uint64_p = B.buffer uint64_t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 33,
"start_col": 0,
"start_line": 33
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t
inline_for_extraction noextract
let uint8_p = B.buffer uint8_t
inline_for_extraction noextract
let uint16_p = B.buffer uint16_t
inline_for_extraction noextract
let uint32_p = B.buffer uint32_t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.buffer",
"EverCrypt.Helpers.uint64_t"
] | [] | false | false | false | true | true | let uint64_p =
| B.buffer uint64_t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint16_p | val uint16_p : Type0 | let uint16_p = B.buffer uint16_t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 29,
"start_col": 0,
"start_line": 29
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t
inline_for_extraction noextract
let uint8_p = B.buffer uint8_t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.buffer",
"EverCrypt.Helpers.uint16_t"
] | [] | false | false | false | true | true | let uint16_p =
| B.buffer uint16_t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint32_p | val uint32_p : Type0 | let uint32_p = B.buffer uint32_t | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 31,
"start_col": 0,
"start_line": 31
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t
inline_for_extraction noextract
let uint8_p = B.buffer uint8_t
inline_for_extraction noextract
let uint16_p = B.buffer uint16_t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | Type0 | Prims.Tot | [
"total"
] | [] | [
"LowStar.Buffer.buffer",
"EverCrypt.Helpers.uint32_t"
] | [] | false | false | false | true | true | let uint32_p =
| B.buffer uint32_t | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint8_l | val uint8_l : p: EverCrypt.Helpers.uint8_p -> Type0 | let uint8_l (p:uint8_p) = l:UInt32.t {B.length p = UInt32.v l} | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 62,
"end_line": 38,
"start_col": 0,
"start_line": 38
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t
inline_for_extraction noextract
let uint8_p = B.buffer uint8_t
inline_for_extraction noextract
let uint16_p = B.buffer uint16_t
inline_for_extraction noextract
let uint32_p = B.buffer uint32_t
inline_for_extraction noextract
let uint64_p = B.buffer uint64_t
inline_for_extraction noextract
let uint8_pl (l:nat) = p:uint8_p {B.length p = l} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: EverCrypt.Helpers.uint8_p -> Type0 | Prims.Tot | [
"total"
] | [] | [
"EverCrypt.Helpers.uint8_p",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"LowStar.Monotonic.Buffer.length",
"EverCrypt.Helpers.uint8_t",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.v"
] | [] | false | false | false | true | true | let uint8_l (p: uint8_p) =
| l: UInt32.t{B.length p = UInt32.v l} | false |
|
EverCrypt.Helpers.fsti | EverCrypt.Helpers.uint8_pl | val uint8_pl : l: Prims.nat -> Type0 | let uint8_pl (l:nat) = p:uint8_p {B.length p = l} | {
"file_name": "providers/evercrypt/EverCrypt.Helpers.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 49,
"end_line": 36,
"start_col": 0,
"start_line": 36
} | module EverCrypt.Helpers
module B = LowStar.Buffer
open FStar.HyperStack.ST
/// Small helpers
inline_for_extraction noextract
let (!$) = C.String.((!$))
/// For the time being, we do not write any specifications and just try to reach
/// agreement on calling conventions. A series of convenient type abbreviations
/// follows.
effect Stack_ (a: Type) = Stack a (fun _ -> True) (fun _ _ _ -> True)
inline_for_extraction noextract
let uint8_t = UInt8.t
inline_for_extraction noextract
let uint16_t = UInt16.t
inline_for_extraction noextract
let uint32_t = UInt32.t
inline_for_extraction noextract
let uint64_t = UInt64.t
inline_for_extraction noextract
let uint8_p = B.buffer uint8_t
inline_for_extraction noextract
let uint16_p = B.buffer uint16_t
inline_for_extraction noextract
let uint32_p = B.buffer uint32_t
inline_for_extraction noextract
let uint64_p = B.buffer uint64_t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "EverCrypt.Helpers.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "EverCrypt",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.nat -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"EverCrypt.Helpers.uint8_p",
"Prims.b2t",
"Prims.op_Equality",
"LowStar.Monotonic.Buffer.length",
"EverCrypt.Helpers.uint8_t",
"LowStar.Buffer.trivial_preorder"
] | [] | false | false | false | true | true | let uint8_pl (l: nat) =
| p: uint8_p{B.length p = l} | false |
|
Problem01.fst | Problem01.remove_elem_from_list | val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat) | val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat) | let rec remove_elem_from_list p i =
match p with
| a::q -> if i = 0 then q else a::remove_elem_from_list q (i-1) | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 65,
"end_line": 30,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Problem01
open FStar.List.Tot
val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)})
let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.list Prims.nat -> i: Prims.nat{i < FStar.List.Tot.Base.length p} -> Prims.list Prims.nat | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.Cons",
"Problem01.remove_elem_from_list",
"Prims.op_Subtraction"
] | [
"recursion"
] | false | false | false | false | false | let rec remove_elem_from_list p i =
| match p with | a :: q -> if i = 0 then q else a :: remove_elem_from_list q (i - 1) | false |
Problem01.fst | Problem01.prefix | val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)}) | val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)}) | let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 57,
"end_line": 25,
"start_col": 0,
"start_line": 21
} | (*
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 Problem01
open FStar.List.Tot | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.list Prims.nat -> str: Prims.list Prims.nat
-> b: Prims.bool{b <==> (exists (l: Prims.list Prims.nat). p @ l = str)} | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.op_Equality",
"Problem01.prefix",
"Prims.bool",
"Prims.l_iff",
"Prims.b2t",
"Prims.l_Exists",
"FStar.List.Tot.Base.append"
] | [
"recursion"
] | false | false | false | false | false | let rec prefix p str =
| match p, str with
| [], _ -> true
| a :: q, [] -> false
| a :: q, a' :: q' -> if a = a' then prefix q q' else false | false |
Hacl.Spec.K256.MathLemmas.fst | Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52_sub | val lemma_distr5_pow52_sub (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 c:int) : Lemma
((b0 * c - a0) + (b1 * c - a1) * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208 ==
(b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) * c -
(a0 + a1 * pow2 52 + a2 * pow2 104 + a3 * pow2 156 + a4 * pow2 208)) | val lemma_distr5_pow52_sub (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 c:int) : Lemma
((b0 * c - a0) + (b1 * c - a1) * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208 ==
(b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) * c -
(a0 + a1 * pow2 52 + a2 * pow2 104 + a3 * pow2 156 + a4 * pow2 208)) | let lemma_distr5_pow52_sub a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 c =
calc (==) {
(b0 * c - a0) + (b1 * c - a1) * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208;
(==) { Math.Lemmas.distributivity_sub_left (b1 * c) a1 (pow2 52) }
c * b0 - a0 + c * b1 * pow2 52 - a1 * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208;
(==) { Math.Lemmas.distributivity_sub_left (b2 * c) a2 (pow2 104) }
c * b0 - a0 + c * b1 * pow2 52 - a1 * pow2 52 + c * b2 * pow2 104 - a2 * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208;
(==) { Math.Lemmas.distributivity_sub_left (b3 * c) a3 (pow2 156) }
c * b0 - a0 + c * b1 * pow2 52 - a1 * pow2 52 + c * b2 * pow2 104 - a2 * pow2 104 +
c * b3 * pow2 156 - a3 * pow2 156 + (b4 * c - a4) * pow2 208;
(==) { Math.Lemmas.distributivity_sub_left (b4 * c) a4 (pow2 208) }
c * b0 - a0 + c * b1 * pow2 52 - a1 * pow2 52 + c * b2 * pow2 104 - a2 * pow2 104 +
c * b3 * pow2 156 - a3 * pow2 156 + c * b4 * pow2 208 - a4 * pow2 208;
(==) { lemma_distr5_pow52 c b0 b1 b2 b3 b4 }
(b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) * c -
(a0 + a1 * pow2 52 + a2 * pow2 104 + a3 * pow2 156 + a4 * pow2 208);
} | {
"file_name": "code/k256/Hacl.Spec.K256.MathLemmas.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 251,
"start_col": 0,
"start_line": 232
} | module Hacl.Spec.K256.MathLemmas
open FStar.Mul
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
val lemma_swap_mul3 (a b c:int) : Lemma (a * b * c == a * c * b)
let lemma_swap_mul3 a b c =
calc (==) {
a * b * c;
(==) { Math.Lemmas.paren_mul_right a b c }
a * (b * c);
(==) { Math.Lemmas.swap_mul b c }
a * (c * b);
(==) { Math.Lemmas.paren_mul_right a c b }
a * c * b;
}
val lemma_mod_mul_distr (a b:int) (n:pos) : Lemma (a * b % n = (a % n) * (b % n) % n)
let lemma_mod_mul_distr a b n =
Math.Lemmas.lemma_mod_mul_distr_l a b n;
Math.Lemmas.lemma_mod_mul_distr_r (a % n) b n
val lemma_mod_sub_distr (a b:int) (n:pos) : Lemma ((a - b) % n = (a % n - b % n) % n)
let lemma_mod_sub_distr a b n =
Math.Lemmas.lemma_mod_plus_distr_l a (- b) n;
Math.Lemmas.lemma_mod_sub_distr (a % n) b n
val lemma_ab_le_cd (a b c d:nat) : Lemma
(requires a <= c /\ b <= d)
(ensures a * b <= c * d)
let lemma_ab_le_cd a b c d =
Math.Lemmas.lemma_mult_le_left a b d;
Math.Lemmas.lemma_mult_le_right d a c
val lemma_ab_lt_cd (a b c d:pos) : Lemma
(requires a < c /\ b < d)
(ensures a * b < c * d)
let lemma_ab_lt_cd a b c d =
Math.Lemmas.lemma_mult_lt_left a b d;
Math.Lemmas.lemma_mult_lt_right d a c
val lemma_bound_mul64_wide (ma mb:nat) (mma mmb:nat) (a b:nat) : Lemma
(requires a <= ma * mma /\ b <= mb * mmb)
(ensures a * b <= ma * mb * (mma * mmb))
let lemma_bound_mul64_wide ma mb mma mmb a b =
calc (<=) {
a * b;
(<=) { lemma_ab_le_cd a b (ma * mma) (mb * mmb) }
(ma * mma) * (mb * mmb);
(==) { Math.Lemmas.paren_mul_right ma mma (mb * mmb) }
ma * (mma * (mb * mmb));
(==) {
Math.Lemmas.paren_mul_right mma mb mmb;
Math.Lemmas.swap_mul mma mb;
Math.Lemmas.paren_mul_right mb mma mmb }
ma * (mb * (mma * mmb));
(==) { Math.Lemmas.paren_mul_right ma mb (mma * mmb) }
ma * mb * (mma * mmb);
}
val lemma_distr_pow (a b:int) (c d:nat) : Lemma ((a + b * pow2 c) * pow2 d = a * pow2 d + b * pow2 (c + d))
let lemma_distr_pow a b c d =
calc (==) {
(a + b * pow2 c) * pow2 d;
(==) { Math.Lemmas.distributivity_add_left a (b * pow2 c) (pow2 d) }
a * pow2 d + b * pow2 c * pow2 d;
(==) { Math.Lemmas.paren_mul_right b (pow2 c) (pow2 d); Math.Lemmas.pow2_plus c d }
a * pow2 d + b * pow2 (c + d);
}
val lemma_distr_pow_pow (a:int) (b:nat) (c:int) (d e:nat) :
Lemma ((a * pow2 b + c * pow2 d) * pow2 e = a * pow2 (b + e) + c * pow2 (d + e))
let lemma_distr_pow_pow a b c d e =
calc (==) {
(a * pow2 b + c * pow2 d) * pow2 e;
(==) { lemma_distr_pow (a * pow2 b) c d e }
a * pow2 b * pow2 e + c * pow2 (d + e);
(==) { Math.Lemmas.paren_mul_right a (pow2 b) (pow2 e); Math.Lemmas.pow2_plus b e }
a * pow2 (b + e) + c * pow2 (d + e);
}
val lemma_distr_eucl_mul (r a:int) (b:pos) : Lemma (r * (a % b) + r * (a / b) * b = r * a)
let lemma_distr_eucl_mul r a b =
calc (==) {
r * (a % b) + r * (a / b) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b) b }
r * (a % b) + r * ((a / b) * b);
(==) { Math.Lemmas.distributivity_add_right r (a % b) (a / b * b) }
r * (a % b + a / b * b);
(==) { Math.Lemmas.euclidean_division_definition a b }
r * a;
}
val lemma_distr_eucl_mul_add (r a c:int) (b:pos) : Lemma (r * (a % b) + r * (a / b + c) * b = r * a + r * c * b)
let lemma_distr_eucl_mul_add r a c b =
calc (==) {
r * (a % b) + r * (a / b + c) * b;
(==) { Math.Lemmas.paren_mul_right r (a / b + c) b }
r * (a % b) + r * ((a / b + c) * b);
(==) { Math.Lemmas.distributivity_add_left (a / b) c b }
r * (a % b) + r * ((a / b * b) + c * b);
(==) { Math.Lemmas.distributivity_add_right r (a / b * b) (c * b) }
r * (a % b) + r * (a / b * b) + r * (c * b);
(==) { Math.Lemmas.paren_mul_right r (a / b) b; Math.Lemmas.paren_mul_right r c b }
r * (a % b) + r * (a / b) * b + r * c * b;
(==) { lemma_distr_eucl_mul r a b }
r * a + r * c * b;
}
val lemma_distr_eucl (a b:int) : Lemma ((a / pow2 52 + b) * pow2 52 + a % pow2 52 = a + b * pow2 52)
let lemma_distr_eucl a b = lemma_distr_eucl_mul_add 1 a b (pow2 52)
val lemma_a_plus_b_pow2_mod2 (a b:int) (c:pos) : Lemma ((a + b * pow2 c) % 2 = a % 2)
let lemma_a_plus_b_pow2_mod2 a b c =
assert_norm (pow2 1 = 2);
Math.Lemmas.lemma_mod_plus_distr_r a (b * pow2 c) 2;
Math.Lemmas.pow2_multiplication_modulo_lemma_1 b 1 c
val lemma_as_nat64_horner (r0 r1 r2 r3:int) :
Lemma (r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192 ==
((r3 * pow2 64 + r2) * pow2 64 + r1) * pow2 64 + r0)
let lemma_as_nat64_horner r0 r1 r2 r3 =
calc (==) {
r0 + pow2 64 * (r1 + pow2 64 * (r2 + pow2 64 * r3));
(==) { Math.Lemmas.swap_mul (pow2 64) (r1 + pow2 64 * (r2 + pow2 64 * r3)) }
r0 + (r1 + pow2 64 * (r2 + pow2 64 * r3)) * pow2 64;
(==) { Math.Lemmas.swap_mul (pow2 64) (r2 + pow2 64 * r3) }
r0 + (r1 + (r2 + pow2 64 * r3) * pow2 64) * pow2 64;
(==) { lemma_distr_pow r1 (r2 + pow2 64 * r3) 64 64 }
r0 + r1 * pow2 64 + (r2 + pow2 64 * r3) * pow2 128;
(==) { Math.Lemmas.swap_mul (pow2 64) r3 }
r0 + r1 * pow2 64 + (r2 + r3 * pow2 64) * pow2 128;
(==) { lemma_distr_pow r2 r3 64 128 }
r0 + r1 * pow2 64 + r2 * pow2 128 + r3 * pow2 192;
}
val lemma_as_nat_horner (r0 r1 r2 r3 r4:int) :
Lemma (r0 + r1 * pow2 52 + r2 * pow2 104 + r3 * pow2 156 + r4 * pow2 208 ==
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0)
let lemma_as_nat_horner r0 r1 r2 r3 r4 =
calc (==) {
(((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 52 + r1) * pow2 52 + r0;
(==) { lemma_distr_pow r1 ((r4 * pow2 52 + r3) * pow2 52 + r2) 52 52 }
((r4 * pow2 52 + r3) * pow2 52 + r2) * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r2 (r4 * pow2 52 + r3) 52 104 }
(r4 * pow2 52 + r3) * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
(==) { lemma_distr_pow r3 r4 52 156 }
r4 * pow2 208 + r3 * pow2 156 + r2 * pow2 104 + r1 * pow2 52 + r0;
}
val lemma_distr5 (a0 a1 a2 a3 a4 b:int) : Lemma
((a0 + a1 + a2 + a3 + a4) * b = a0 * b + a1 * b + a2 * b + a3 * b + a4 * b)
let lemma_distr5 a0 a1 a2 a3 a4 b =
calc (==) {
(a0 + a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a0 (a1 + a2 + a3 + a4) b }
a0 * b + (a1 + a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a1 (a2 + a3 + a4) b }
a0 * b + a1 * b + (a2 + a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a2 (a3 + a4) b }
a0 * b + a1 * b + a2 * b + (a3 + a4) * b;
(==) { Math.Lemmas.distributivity_add_left a3 a4 b }
a0 * b + a1 * b + a2 * b + a3 * b + a4 * b;
}
val lemma_distr5_pow52 (a b0 b1 b2 b3 b4:int) : Lemma
(a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208)
let lemma_distr5_pow52 a b0 b1 b2 b3 b4 =
calc (==) {
a * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208);
(==) { lemma_distr5 b0 (b1 * pow2 52) (b2 * pow2 104) (b3 * pow2 156) (b4 * pow2 208) a }
b0 * a + b1 * pow2 52 * a + b2 * pow2 104 * a + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b1 (pow2 52) a; lemma_swap_mul3 b2 (pow2 104) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * pow2 156 * a + b4 * pow2 208 * a;
(==) { lemma_swap_mul3 b3 (pow2 156) a; lemma_swap_mul3 b4 (pow2 208) a }
b0 * a + b1 * a * pow2 52 + b2 * a * pow2 104 + b3 * a * pow2 156 + b4 * a * pow2 208;
}
val lemma_distr5_pow52_mul_pow (a b0 b1 b2 b3 b4: int) (p:nat) : Lemma
(a * pow2 p * (b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) =
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) +
a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p))
let lemma_distr5_pow52_mul_pow a b0 b1 b2 b3 b4 p =
let b_sum = b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208 in
calc (==) {
a * pow2 p * b_sum;
(==) { lemma_swap_mul3 a (pow2 p) b_sum }
a * b_sum * pow2 p;
(==) { lemma_distr5_pow52 a b0 b1 b2 b3 b4 }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156 + a * b4 * pow2 208) * pow2 p;
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156) (a * b4) 208 p }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104 + a * b3 * pow2 156) * pow2 p + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104) (a * b3) 156 p }
(a * b0 + a * b1 * pow2 52 + a * b2 * pow2 104) * pow2 p + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0 + a * b1 * pow2 52) (a * b2) 104 p }
(a * b0 + a * b1 * pow2 52) * pow2 p + a * b2 * pow2 (104 + p) + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
(==) { lemma_distr_pow (a * b0) (a * b1) 52 p }
a * b0 * pow2 p + a * b1 * pow2 (52 + p) + a * b2 * pow2 (104 + p) + a * b3 * pow2 (156 + p) + a * b4 * pow2 (208 + p);
}
val lemma_distr5_pow52_sub (a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 c:int) : Lemma
((b0 * c - a0) + (b1 * c - a1) * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 + (b4 * c - a4) * pow2 208 ==
(b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) * c -
(a0 + a1 * pow2 52 + a2 * pow2 104 + a3 * pow2 156 + a4 * pow2 208)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.MathLemmas.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"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 |
a0: Prims.int ->
a1: Prims.int ->
a2: Prims.int ->
a3: Prims.int ->
a4: Prims.int ->
b0: Prims.int ->
b1: Prims.int ->
b2: Prims.int ->
b3: Prims.int ->
b4: Prims.int ->
c: Prims.int
-> FStar.Pervasives.Lemma
(ensures
b0 * c - a0 + (b1 * c - a1) * Prims.pow2 52 + (b2 * c - a2) * Prims.pow2 104 +
(b3 * c - a3) * Prims.pow2 156 +
(b4 * c - a4) * Prims.pow2 208 ==
(b0 + b1 * Prims.pow2 52 + b2 * Prims.pow2 104 + b3 * Prims.pow2 156 + b4 * Prims.pow2 208) *
c -
(a0 + a1 * Prims.pow2 52 + a2 * Prims.pow2 104 + a3 * Prims.pow2 156 + a4 * Prims.pow2 208)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.int",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Addition",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Prims.pow2",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.distributivity_sub_left",
"Prims.squash",
"Hacl.Spec.K256.MathLemmas.lemma_distr5_pow52"
] | [] | false | false | true | false | false | let lemma_distr5_pow52_sub a0 a1 a2 a3 a4 b0 b1 b2 b3 b4 c =
| calc ( == ) {
(b0 * c - a0) + (b1 * c - a1) * pow2 52 + (b2 * c - a2) * pow2 104 + (b3 * c - a3) * pow2 156 +
(b4 * c - a4) * pow2 208;
( == ) { Math.Lemmas.distributivity_sub_left (b1 * c) a1 (pow2 52) }
c * b0 - a0 + (c * b1) * pow2 52 - a1 * pow2 52 + (b2 * c - a2) * pow2 104 +
(b3 * c - a3) * pow2 156 +
(b4 * c - a4) * pow2 208;
( == ) { Math.Lemmas.distributivity_sub_left (b2 * c) a2 (pow2 104) }
c * b0 - a0 + (c * b1) * pow2 52 - a1 * pow2 52 + (c * b2) * pow2 104 - a2 * pow2 104 +
(b3 * c - a3) * pow2 156 +
(b4 * c - a4) * pow2 208;
( == ) { Math.Lemmas.distributivity_sub_left (b3 * c) a3 (pow2 156) }
c * b0 - a0 + (c * b1) * pow2 52 - a1 * pow2 52 + (c * b2) * pow2 104 - a2 * pow2 104 +
(c * b3) * pow2 156 -
a3 * pow2 156 +
(b4 * c - a4) * pow2 208;
( == ) { Math.Lemmas.distributivity_sub_left (b4 * c) a4 (pow2 208) }
c * b0 - a0 + (c * b1) * pow2 52 - a1 * pow2 52 + (c * b2) * pow2 104 - a2 * pow2 104 +
(c * b3) * pow2 156 -
a3 * pow2 156 +
(c * b4) * pow2 208 -
a4 * pow2 208;
( == ) { lemma_distr5_pow52 c b0 b1 b2 b3 b4 }
(b0 + b1 * pow2 52 + b2 * pow2 104 + b3 * pow2 156 + b4 * pow2 208) * c -
(a0 + a1 * pow2 52 + a2 * pow2 104 + a3 * pow2 156 + a4 * pow2 208);
} | false |
CQueue.LList.fst | CQueue.LList.elim_cllist | val elim_cllist
(#opened: _)
(#a: Type0)
(c: cllist_ptrvalue a)
: SteelAtomic (cllist_lvalue a) opened
(cllist c)
(fun c' -> vptr (cllist_head c') `star` vptr (cllist_tail c'))
(fun _ -> True)
(fun h c' h' ->
cllist_ptrvalue_is_null c == false /\
(c' <: cllist_ptrvalue a) == c /\
h (cllist c) == { vllist_head = h' (vptr (cllist_head c')); vllist_tail = h' (vptr (cllist_tail c')) }
) | val elim_cllist
(#opened: _)
(#a: Type0)
(c: cllist_ptrvalue a)
: SteelAtomic (cllist_lvalue a) opened
(cllist c)
(fun c' -> vptr (cllist_head c') `star` vptr (cllist_tail c'))
(fun _ -> True)
(fun h c' h' ->
cllist_ptrvalue_is_null c == false /\
(c' <: cllist_ptrvalue a) == c /\
h (cllist c) == { vllist_head = h' (vptr (cllist_head c')); vllist_tail = h' (vptr (cllist_tail c')) }
) | let elim_cllist
#opened #a c
=
let c2 = elim_cllist_ghost c in
let c : cllist_lvalue a = c in
change_equal_slprop (vptr (cllist_head c2)) (vptr (cllist_head c));
change_equal_slprop (vptr (cllist_tail c2)) (vptr (cllist_tail c));
return c | {
"file_name": "share/steel/examples/steel/CQueue.LList.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 10,
"end_line": 125,
"start_col": 0,
"start_line": 118
} | module CQueue.LList
noeq
type cllist_ptrvalue (a: Type0) = {
head: ref (ccell_ptrvalue a);
tail: ref (ref (ccell_ptrvalue a));
all_or_none_null: squash (is_null head == is_null tail);
}
let cllist_ptrvalue_null a = {head = null; tail = null; all_or_none_null = ()}
let cllist_ptrvalue_is_null #a x = is_null x.head
let cllist_head #a c =
c.head
let cllist_tail #a c =
c.tail
#push-options "--ide_id_info_off"
let cllist0_refine
(#a: Type0)
(c: cllist_ptrvalue a)
(_: t_of emp)
: Tot prop
= cllist_ptrvalue_is_null c == false
// unfold
let cllist0_rewrite
(#a: Type0)
(c: cllist_ptrvalue a)
(_: t_of (emp `vrefine` cllist0_refine c))
: Tot (cllist_lvalue a)
= c
[@@ __steel_reduce__]
let cllist0 (a: Type0) (c: cllist_lvalue a) : Tot vprop =
(vptr (cllist_head c) `star` vptr (cllist_tail c))
// unfold
let cllist_rewrite
(#a: Type0)
(c: cllist_ptrvalue a)
(x: dtuple2 (cllist_lvalue a) (vdep_payload (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (cllist0 a)))
: GTot (vllist a)
= let p =
dsnd #(cllist_lvalue a) #(vdep_payload (emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c) (cllist0 a)) x
in
{
vllist_head = fst p;
vllist_tail = snd p;
}
[@@ __steel_reduce__ ; __reduce__] // to avoid manual unfoldings through change_slprop
let cllist1
(#a: Type0)
(c: cllist_ptrvalue a)
: Tot vprop
= emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a `vrewrite` cllist_rewrite c
let cllist_hp
#a c
= hp_of (cllist1 c)
let cllist_sel
#a c
= sel_of (cllist1 c)
let intro_cllist
#opened #a c
=
intro_vrefine emp (cllist0_refine c);
intro_vrewrite (emp `vrefine` cllist0_refine c) (cllist0_rewrite c);
reveal_star (vptr (cllist_head c)) (vptr (cllist_tail c));
intro_vdep
(emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c)
(vptr (cllist_head c) `star` vptr (cllist_tail c))
(cllist0 a);
intro_vrewrite
(emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a)
(cllist_rewrite c);
change_slprop_rel
(cllist1 c)
(cllist c)
(fun x y -> x == y)
(fun m ->
assert_norm (hp_of (cllist1 c) == cllist_hp c);
assert_norm (sel_of (cllist1 c) m === sel_of (cllist c) m)
)
let elim_cllist_ghost
#opened #a c
=
change_slprop_rel
(cllist c)
(cllist1 c)
(fun x y -> x == y)
(fun m ->
assert_norm (hp_of (cllist1 c) == cllist_hp c);
assert_norm (sel_of (cllist1 c) m === sel_of (cllist c) m)
);
elim_vrewrite
(emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c `vdep` cllist0 a)
(cllist_rewrite c);
let c' : Ghost.erased (cllist_lvalue a) = elim_vdep
(emp `vrefine` cllist0_refine c `vrewrite` cllist0_rewrite c)
(cllist0 a)
in
elim_vrewrite (emp `vrefine` cllist0_refine c) (cllist0_rewrite c);
elim_vrefine emp (cllist0_refine c);
change_equal_slprop
(cllist0 a c')
(vptr (cllist_head (Ghost.reveal c')) `star` vptr (cllist_tail (Ghost.reveal c')));
reveal_star (vptr (cllist_head (Ghost.reveal c'))) (vptr (cllist_tail (Ghost.reveal c')));
c' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "CQueue.LList.fst"
} | [
{
"abbrev": false,
"full_module": "Steel.Reference",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.FractionalPermission",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect.Atomic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue.Cell",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": false,
"full_module": "CQueue",
"short_module": null
},
{
"abbrev": 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: CQueue.LList.cllist_ptrvalue a -> Steel.Effect.Atomic.SteelAtomic (CQueue.LList.cllist_lvalue a) | Steel.Effect.Atomic.SteelAtomic | [] | [] | [
"Steel.Memory.inames",
"CQueue.LList.cllist_ptrvalue",
"Steel.Effect.Atomic.return",
"CQueue.LList.cllist_lvalue",
"Steel.Effect.Common.VStar",
"Steel.Reference.vptrp",
"CQueue.Cell.ccell_ptrvalue",
"CQueue.LList.cllist_head",
"Steel.FractionalPermission.full_perm",
"Steel.Reference.ref",
"CQueue.LList.cllist_tail",
"Steel.Effect.Common.vprop",
"Prims.unit",
"Steel.Effect.Atomic.change_equal_slprop",
"Steel.Reference.vptr",
"FStar.Ghost.reveal",
"FStar.Ghost.erased",
"CQueue.LList.elim_cllist_ghost"
] | [] | false | true | false | false | false | let elim_cllist #opened #a c =
| let c2 = elim_cllist_ghost c in
let c:cllist_lvalue a = c in
change_equal_slprop (vptr (cllist_head c2)) (vptr (cllist_head c));
change_equal_slprop (vptr (cllist_tail c2)) (vptr (cllist_tail c));
return c | false |
Problem01.fst | Problem01.test_relaxed_prefix | val test_relaxed_prefix: p:list nat -> str:list nat ->
Tot (b:bool{b <==> (b2t (prefix p str) \/
(exists (i:nat). i < length p && prefix (remove_elem_from_list p i) str))}) | val test_relaxed_prefix: p:list nat -> str:list nat ->
Tot (b:bool{b <==> (b2t (prefix p str) \/
(exists (i:nat). i < length p && prefix (remove_elem_from_list p i) str))}) | let test_relaxed_prefix p str =
prefix p str || (if length p > 0 then test_prefix p (length p - 1) str else false) | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 84,
"end_line": 57,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Problem01
open FStar.List.Tot
val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)})
let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false
val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat)
let rec remove_elem_from_list p i =
match p with
| a::q -> if i = 0 then q else a::remove_elem_from_list q (i-1)
val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat ->
Tot (b:bool{b ==> (exists (i:nat). i <= n /\ prefix (remove_elem_from_list p i) str)})
let rec test_prefix p n str =
match n with
| 0 -> prefix (remove_elem_from_list p n) str
| n -> prefix (remove_elem_from_list p n) str || test_prefix p (n - 1) str
let test_prefix_exists_to_b (p:list nat) (n:nat{n < length p}) (str:list nat)
(h:squash (exists (i:nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str)
= let goal n = test_prefix p n str in
let rec aux (n:nat{n < length p}) (i:nat{i <= n /\ prefix (remove_elem_from_list p i) str}) : GTot (squash (goal n))
= if n > i then aux (n - 1) i
in
Classical.exists_elim (goal n) h (aux n)
let test_prefix_iff (p:list nat) (n:nat{n < length p}) (str:list nat)
: Lemma (test_prefix p n str <==> (exists (i:nat). i <= n && prefix (remove_elem_from_list p i) str))
[SMTPat (test_prefix p n str)]
= Classical.impl_intro (test_prefix_exists_to_b p n str)
val test_relaxed_prefix: p:list nat -> str:list nat ->
Tot (b:bool{b <==> (b2t (prefix p str) \/ | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: Prims.list Prims.nat -> str: Prims.list Prims.nat
-> b:
Prims.bool
{ b <==>
Problem01.prefix p str \/
(exists (i: Prims.nat).
i < FStar.List.Tot.Base.length p &&
Problem01.prefix (Problem01.remove_elem_from_list p i) str) } | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.nat",
"Prims.op_BarBar",
"Problem01.prefix",
"Prims.op_GreaterThan",
"FStar.List.Tot.Base.length",
"Problem01.test_prefix",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.l_iff",
"Prims.b2t",
"Prims.l_or",
"Prims.l_Exists",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Problem01.remove_elem_from_list"
] | [] | false | false | false | false | false | let test_relaxed_prefix p str =
| prefix p str || (if length p > 0 then test_prefix p (length p - 1) str else false) | false |
Problem01.fst | Problem01.test_prefix_iff | val test_prefix_iff (p: list nat) (n: nat{n < length p}) (str: list nat)
: Lemma
(test_prefix p n str <==> (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
[SMTPat (test_prefix p n str)] | val test_prefix_iff (p: list nat) (n: nat{n < length p}) (str: list nat)
: Lemma
(test_prefix p n str <==> (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
[SMTPat (test_prefix p n str)] | let test_prefix_iff (p:list nat) (n:nat{n < length p}) (str:list nat)
: Lemma (test_prefix p n str <==> (exists (i:nat). i <= n && prefix (remove_elem_from_list p i) str))
[SMTPat (test_prefix p n str)]
= Classical.impl_intro (test_prefix_exists_to_b p n str) | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 51,
"start_col": 0,
"start_line": 48
} | (*
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 Problem01
open FStar.List.Tot
val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)})
let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false
val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat)
let rec remove_elem_from_list p i =
match p with
| a::q -> if i = 0 then q else a::remove_elem_from_list q (i-1)
val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat ->
Tot (b:bool{b ==> (exists (i:nat). i <= n /\ prefix (remove_elem_from_list p i) str)})
let rec test_prefix p n str =
match n with
| 0 -> prefix (remove_elem_from_list p n) str
| n -> prefix (remove_elem_from_list p n) str || test_prefix p (n - 1) str
let test_prefix_exists_to_b (p:list nat) (n:nat{n < length p}) (str:list nat)
(h:squash (exists (i:nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str)
= let goal n = test_prefix p n str in
let rec aux (n:nat{n < length p}) (i:nat{i <= n /\ prefix (remove_elem_from_list p i) str}) : GTot (squash (goal n))
= if n > i then aux (n - 1) i
in
Classical.exists_elim (goal n) h (aux n) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Prims.list Prims.nat ->
n: Prims.nat{n < FStar.List.Tot.Base.length p} ->
str: Prims.list Prims.nat
-> FStar.Pervasives.Lemma
(ensures
Problem01.test_prefix p n str <==>
(exists (i: Prims.nat). i <= n && Problem01.prefix (Problem01.remove_elem_from_list p i) str
)) [SMTPat (Problem01.test_prefix p n str)] | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"FStar.Classical.impl_intro",
"Prims.squash",
"Prims.l_Exists",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Problem01.prefix",
"Problem01.remove_elem_from_list",
"Problem01.test_prefix",
"Problem01.test_prefix_exists_to_b",
"Prims.unit",
"Prims.l_True",
"Prims.l_iff",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.bool",
"Prims.l_imp",
"Prims.l_and",
"Prims.Nil"
] | [] | false | false | true | false | false | let test_prefix_iff (p: list nat) (n: nat{n < length p}) (str: list nat)
: Lemma
(test_prefix p n str <==> (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
[SMTPat (test_prefix p n str)] =
| Classical.impl_intro (test_prefix_exists_to_b p n str) | false |
Problem01.fst | Problem01.test_prefix_exists_to_b | val test_prefix_exists_to_b
(p: list nat)
(n: nat{n < length p})
(str: list nat)
(h: squash (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str) | val test_prefix_exists_to_b
(p: list nat)
(n: nat{n < length p})
(str: list nat)
(h: squash (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str) | let test_prefix_exists_to_b (p:list nat) (n:nat{n < length p}) (str:list nat)
(h:squash (exists (i:nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str)
= let goal n = test_prefix p n str in
let rec aux (n:nat{n < length p}) (i:nat{i <= n /\ prefix (remove_elem_from_list p i) str}) : GTot (squash (goal n))
= if n > i then aux (n - 1) i
in
Classical.exists_elim (goal n) h (aux n) | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 44,
"end_line": 46,
"start_col": 0,
"start_line": 39
} | (*
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 Problem01
open FStar.List.Tot
val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)})
let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false
val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat)
let rec remove_elem_from_list p i =
match p with
| a::q -> if i = 0 then q else a::remove_elem_from_list q (i-1)
val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat ->
Tot (b:bool{b ==> (exists (i:nat). i <= n /\ prefix (remove_elem_from_list p i) str)})
let rec test_prefix p n str =
match n with
| 0 -> prefix (remove_elem_from_list p n) str
| n -> prefix (remove_elem_from_list p n) str || test_prefix p (n - 1) str | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Prims.list Prims.nat ->
n: Prims.nat{n < FStar.List.Tot.Base.length p} ->
str: Prims.list Prims.nat ->
h:
Prims.squash (exists (i: Prims.nat).
i <= n && Problem01.prefix (Problem01.remove_elem_from_list p i) str)
-> FStar.Pervasives.Lemma (ensures Problem01.test_prefix p n str) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"Prims.squash",
"Prims.l_Exists",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"Problem01.prefix",
"Problem01.remove_elem_from_list",
"FStar.Classical.exists_elim",
"Prims.l_and",
"Prims.op_GreaterThan",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.l_imp",
"Problem01.test_prefix",
"Prims.unit",
"Prims.l_True",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let test_prefix_exists_to_b
(p: list nat)
(n: nat{n < length p})
(str: list nat)
(h: squash (exists (i: nat). i <= n && prefix (remove_elem_from_list p i) str))
: Lemma (test_prefix p n str) =
| let goal n = test_prefix p n str in
let rec aux (n: nat{n < length p}) (i: nat{i <= n /\ prefix (remove_elem_from_list p i) str})
: GTot (squash (goal n)) =
if n > i then aux (n - 1) i
in
Classical.exists_elim (goal n) h (aux n) | false |
Vale.AES.PPC64LE.GCTR.fst | Vale.AES.PPC64LE.GCTR.va_qcode_Gctr_blocks128_6way_body | val va_qcode_Gctr_blocks128_6way_body
(va_mods: va_mods_t)
(alg: algorithm)
(in_b out_b: buffer128)
(old_icb: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b: buffer128)
(plain_quads: (seq quad32))
: (va_quickCode unit (va_code_Gctr_blocks128_6way_body alg)) | val va_qcode_Gctr_blocks128_6way_body
(va_mods: va_mods_t)
(alg: algorithm)
(in_b out_b: buffer128)
(old_icb: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b: buffer128)
(plain_quads: (seq quad32))
: (va_quickCode unit (va_code_Gctr_blocks128_6way_body alg)) | let va_qcode_Gctr_blocks128_6way_body (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_6way_body alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 383 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s))) (fun _ -> let (ctr_enc_0:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s))) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 384 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s + 1))) (fun _ -> let (ctr_enc_1:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s + 1) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s + 1))) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 385 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s + 2))) (fun _ -> let (ctr_enc_2:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s + 2) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s + 2))) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 386 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s + 3))) (fun _ -> let (ctr_enc_3:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s + 3) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s + 3))) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 387 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s + 4))) (fun _ -> let (ctr_enc_4:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s + 4) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s + 4))) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 388 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 8 va_s + 5))) (fun _ -> let (ctr_enc_5:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 8 va_s + 5) (va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8
va_s + 5))) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 390 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 391 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 8)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 392 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 9)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 393 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 10)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 394 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 11)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 395 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 12)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 397 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock_6way alg (va_get_vec 7 va_s) (Vale.AES.GCTR_BE.inc32lite (va_get_vec
7 va_s) 1) (Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s) 2) (Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s) 3) (Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s) 4)
(Vale.AES.GCTR_BE.inc32lite (va_get_vec 7 va_s) 5) key round_keys keys_b) (fun (va_s:va_state)
_ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 399 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 14)
(va_op_reg_opr_reg 3) Secret in_b (va_get_reg 8 va_s)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 400 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 15)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 27) Secret in_b (va_get_reg 8 va_s + 1)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 401 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 16)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 28) Secret in_b (va_get_reg 8 va_s + 2)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 402 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 17)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 29) Secret in_b (va_get_reg 8 va_s + 3)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 403 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 18)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 30) Secret in_b (va_get_reg 8 va_s + 4)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 404 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 19)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 31) Secret in_b (va_get_reg 8 va_s + 5)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14) (va_op_vec_opr_vec 0)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 407 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 15) (va_op_vec_opr_vec 1)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 16) (va_op_vec_opr_vec 2)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 17) (va_op_vec_opr_vec 3)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 410 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 18) (va_op_vec_opr_vec 4)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 411 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 19) (va_op_vec_opr_vec 5)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store_3blocks128_1 out_b) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store_3blocks128_2 out_b) (fun (va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 415 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s) (va_get_mem_heaplet 1 va_s)) == ctr_enc_0) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s + 1) (va_get_mem_heaplet 1 va_s)) == ctr_enc_1) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 417 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s + 2) (va_get_mem_heaplet 1 va_s)) == ctr_enc_2) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 418 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s + 3) (va_get_mem_heaplet 1 va_s)) == ctr_enc_3) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 419 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s + 4) (va_get_mem_heaplet 1 va_s)) == ctr_enc_4) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 420 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8
va_s + 5) (va_get_mem_heaplet 1 va_s)) == ctr_enc_5) (let (va_arg64:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg63:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg62:Vale.Def.Types_s.quad32) = old_icb in let (va_arg61:Prims.nat) = va_get_reg 8 va_s in
let (va_arg60:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg59:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg58:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 422 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg58 va_arg59 va_arg60
va_arg61 va_arg62 va_arg63 va_arg64) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 424 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 6) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 425 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 3) (6 `op_Multiply` 16)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 426 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) (6 `op_Multiply` 16)) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 427 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 13))
(va_QEmpty (()))))))))))))))))))))))))))))))))))))))))) | {
"file_name": "obj/Vale.AES.PPC64LE.GCTR.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 59,
"end_line": 1591,
"start_col": 0,
"start_line": 1424
} | module Vale.AES.PPC64LE.GCTR
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.PPC64LE.AES
open Vale.AES.GCTR_BE_s
open Vale.AES.GCTR_BE
open Vale.AES.GCM_helpers_BE
open Vale.Poly1305.Math
open Vale.Def.Words.Two_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.PPC64LE.State
open Vale.PPC64LE.Decls
open Vale.PPC64LE.InsBasic
open Vale.PPC64LE.InsMem
open Vale.PPC64LE.InsVector
open Vale.PPC64LE.InsStack
open Vale.PPC64LE.QuickCode
open Vale.PPC64LE.QuickCodes
open Vale.AES.Types_helpers
#reset-options "--z3rlimit 30"
open Vale.Lib.Basic
#reset-options "--z3rlimit 20"
//-- Gctr_register
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_register alg =
(va_Block (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_CCons
(va_code_AESEncryptBlock alg) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_CNil ()))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_register alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_register (va_mods:va_mods_t) (alg:algorithm) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_register alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 99 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE_s.inc32 (va_get_vec 7 va_s) 0 == va_get_vec 7 va_s) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 100 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 101 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 102 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (va_get_vec 7 va_s)) (fun _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 102 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 0 va_s == Vale.AES.AES_BE_s.aes_encrypt_word alg key (va_get_vec 7 va_s)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 104 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> let (va_arg15:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg14:Vale.AES.AES_common_s.algorithm) = alg in let (va_arg13:Vale.Def.Types_s.quad32) =
va_get_vec 1 va_old_s in let (va_arg12:Vale.Def.Types_s.quad32) = va_get_vec 7 va_s in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 107 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.gctr_encrypt_one_block va_arg12 va_arg13 va_arg14 va_arg15)
(va_QEmpty (()))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_register va_b0 va_s0 alg key round_keys keys_b =
let (va_mods:va_mods_t) = [va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok] in
let va_qc = va_qcode_Gctr_register va_mods alg key round_keys keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_register alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 80 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 96 column 142 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE (Vale.Def.Words.Seq_s.seq_four_to_seq_BE
#Vale.Def.Words_s.nat32 (FStar.Seq.Base.create #quad32 1 (va_get_vec 1 va_sM))) ==
Vale.AES.GCTR_BE_s.gctr_encrypt (va_get_vec 7 va_sM) (Vale.Arch.Types.be_quad32_to_bytes
(va_get_vec 1 va_s0)) alg key) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 97 column 60 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 1 va_sM == Vale.AES.GCTR_BE_s.gctr_encrypt_block (va_get_vec 7 va_sM) (va_get_vec 1
va_s0) alg key 0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok]) va_sM
va_s0;
(va_sM, va_fM)
[@"opaque_to_smt"]
let va_wpProof_Gctr_register alg key round_keys keys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_register (va_code_Gctr_register alg) va_s0 alg key round_keys
keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 2 va_sM (va_update_vec 1 va_sM (va_update_vec 0 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM va_s0))))));
va_lemma_norm_mods ([va_Mod_vec 2; va_Mod_vec 1; va_Mod_vec 0; va_Mod_reg 10]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
//--
//-- Gctr_blocks128_body_1way
val va_code_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_body_1way alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Store128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9)
Secret) (va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_body_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_body_1way alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0))
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_body_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) (plain_quads:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_body_1way alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 152 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun (alg_10591:Vale.AES.AES_common_s.algorithm) (key_10592:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_10593:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg key (Vale.AES.GCTR_BE_s.inc32
old_icb (va_get_reg 6 va_s + count))) (fun _ -> let (ctr_enc:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b (va_get_reg 6 va_s + count) (va_get_mem_heaplet 1
va_s))) (Vale.AES.AES_BE_s.aes_encrypt_word alg key (Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 6 va_s + count))) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 154 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 155 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock alg (va_get_vec 7 va_s) key round_keys keys_b) (fun (va_s:va_state) _
-> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 157 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 9) Secret in_b (va_get_reg 6 va_s + count)) (va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 158 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vxor (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 0)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 159 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 9) Secret out_b (va_get_reg 6 va_s + count)) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 160 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 6
va_s + count) (va_get_mem_heaplet 1 va_s)) == ctr_enc) (let (va_arg24:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg23:Vale.AES.AES_common_s.algorithm) = alg in let
(va_arg22:Vale.Def.Types_s.quad32) = old_icb in let (va_arg21:Prims.nat) = va_get_reg 6 va_s +
count in let (va_arg20:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_quads in let
(va_arg19:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1
va_old_s) out_b) in let (va_arg18:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
out_b) in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 162 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq va_arg18 va_arg19 va_arg20
va_arg21 va_arg22 va_arg23 va_arg24) (va_QEmpty (())))))))))))
val va_lemma_Gctr_blocks128_body_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> count:nat -> old_icb:quad32 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> plain_quads:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_body_1way alg) va_s0 /\ va_get_ok va_s0
/\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count `op_Multiply` 16
/\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_body_1way va_b0 va_s0 alg in_b out_b count old_icb key round_keys
keys_b plain_quads =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_body_1way va_mods alg in_b out_b count old_icb key round_keys
keys_b plain_quads in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_body_1way alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 110 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 148 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.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 149 column 132 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) in_b)) (va_get_reg 6 va_sM + count + 1)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 150 column 126 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + count + 1) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_ok;
va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (count:nat)
(old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (plain_quads:(seq
quad32)) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= count /\ count < va_get_reg 26 va_s0 /\ va_get_reg 9 va_s0 == count
`op_Multiply` 16 /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg 3 va_s0) in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7
va_s0) out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
(Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.AES.GCTR_BE.partial_seq_agreement plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0 + count)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\
Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 + count) plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
out_b)) key old_icb /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 < pow2_32 /\ va_get_vec 7 va_s0
== Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0 + count) /\ aes_reqs alg key
round_keys keys_b (va_get_reg 4 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0))
/\ (forall (va_x_mem:vale_heap) (va_x_r10:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_mem va_x_mem va_s0)))) in va_get_ok va_sM
/\ (Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.partial_seq_agreement plain_quads
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
in_b)) (va_get_reg 6 va_sM + count + 1) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6
va_sM + count + 1) plain_quads (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b)) key old_icb) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_body_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
count:nat -> old_icb:quad32 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
plain_quads:(seq 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_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_body_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_mem]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count old_icb key round_keys keys_b
plain_quads va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_body_1way (va_code_Gctr_blocks128_body_1way alg)
va_s0 alg in_b out_b count old_icb key round_keys keys_b plain_quads in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10;
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_Gctr_blocks128_body_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(count:nat) (old_icb:quad32) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(plain_quads:(seq quad32)) : (va_quickCode unit (va_code_Gctr_blocks128_body_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_body_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_vec 2; va_Mod_vec
0; va_Mod_reg 10; va_Mod_mem]) (va_wp_Gctr_blocks128_body_1way alg in_b out_b count old_icb key
round_keys keys_b plain_quads) (va_wpProof_Gctr_blocks128_body_1way alg in_b out_b count
old_icb key round_keys keys_b plain_quads))
//--
//-- Mod_cr0
val va_code_Mod_cr0 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Mod_cr0 () =
(va_Block (va_CNil ()))
val va_codegen_success_Mod_cr0 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Mod_cr0 () =
(va_ttrue ())
[@ "opaque_to_smt" va_qattr]
let va_qcode_Mod_cr0 (va_mods:va_mods_t) : (va_quickCode unit (va_code_Mod_cr0 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QEmpty (())))
val va_lemma_Mod_cr0 : va_b0:va_code -> va_s0:va_state
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Mod_cr0 ()) va_s0 /\ va_get_ok va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0))))
[@"opaque_to_smt"]
let va_lemma_Mod_cr0 va_b0 va_s0 =
let (va_mods:va_mods_t) = [va_Mod_cr0; va_Mod_ok] in
let va_qc = va_qcode_Mod_cr0 va_mods in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Mod_cr0 ()) va_qc va_s0 (fun va_s0
va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 165 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM)) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_cr0; va_Mod_ok]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Mod_cr0 (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (forall (va_x_cr0:cr0_t) . let va_sM = va_upd_cr0 va_x_cr0 va_s0 in va_get_ok
va_sM ==> va_k va_sM (())))
val va_wpProof_Mod_cr0 : va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Mod_cr0 va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_s0 va_k
((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Mod_cr0 va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Mod_cr0 (va_code_Mod_cr0 ()) va_s0 in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_cr0 va_sM (va_update_ok va_sM va_s0)));
va_lemma_norm_mods ([va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Mod_cr0 () : (va_quickCode unit (va_code_Mod_cr0 ())) =
(va_QProc (va_code_Mod_cr0 ()) ([va_Mod_cr0]) va_wp_Mod_cr0 va_wpProof_Mod_cr0)
//--
//-- Gctr_blocks128_1way_body0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_body0 alg =
(va_Block (va_CCons (va_code_Mod_cr0 ()) (va_CCons (va_code_Gctr_blocks128_body_1way alg)
(va_CCons (va_code_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_CCons
(va_code_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_CCons (va_code_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_CNil ())))))))
val va_codegen_success_Gctr_blocks128_1way_body0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_body0 alg =
(va_pbool_and (va_codegen_success_Mod_cr0 ()) (va_pbool_and
(va_codegen_success_Gctr_blocks128_body_1way alg) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_pbool_and (va_codegen_success_AddImm
(va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_ttrue ()))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_body0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_body0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 257 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Mod_cr0 ()) (fun (va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 259 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_body_1way alg in_b out_b (va_get_reg 8 va_s) old_icb key round_keys
keys_b old_plain) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 261 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 262 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AddImm (va_op_reg_opr_reg 9) (va_op_reg_opr_reg 9) 16) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 263 column 16 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 3)) (va_QEmpty
(()))))))))
val va_lemma_Gctr_blocks128_1way_body0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_body0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) /\ va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_body0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_body0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_body0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 254 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 /\ (forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap)
(va_x_mem:vale_heap) (va_x_ok:bool) (va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64)
(va_x_v0:quad32) (va_x_v2:quad32) (va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7
(va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok (va_upd_mem va_x_mem (va_upd_mem_heaplet 1
va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM
/\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16 `op_Multiply`
va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb
(va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b
va_in_out_b \/ va_in_in_b == va_in_out_b) /\ Vale.PPC64LE.Decls.validSrcAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM) va_in_in_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM) va_in_out_b (va_get_reg 6 va_sM) (va_get_reg
26 va_sM) (va_get_mem_layout va_sM) Secret /\ va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg
26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8
va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
precedes_wrap (va_get_reg 26 va_sM - va_get_reg 8 va_sM) (va_get_reg 26 va_s0 - va_get_reg 8
va_s0) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_body0 : va_old:va_state -> alg:algorithm -> va_in_in_b:buffer128
-> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32 ->
va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq 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_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_body0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb
va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_body0 (va_code_Gctr_blocks128_1way_body0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_body0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_body0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_body0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_body0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way_while0
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way_while0 alg =
(va_Block (va_CCons (va_While (va_cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (va_Block
(va_CCons (va_code_Gctr_blocks128_1way_body0 alg) (va_CNil ())))) (va_CNil ())))
val va_codegen_success_Gctr_blocks128_1way_while0 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way_while0 alg =
(va_pbool_and (va_codegen_success_Gctr_blocks128_1way_body0 alg) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way_while0 (va_mods:va_mods_t) (va_old:va_state) (alg:algorithm)
(va_in_in_b:buffer128) (va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32)
(va_in_old_plain:(seq quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) :
(va_quickCode unit (va_code_Gctr_blocks128_1way_while0 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (in_b:buffer128) =
va_in_in_b in let (key:(seq nat32)) = va_in_key in let (keys_b:buffer128) = va_in_keys_b in let
(old_icb:quad32) = va_in_old_icb in let (old_plain:(seq quad32)) = va_in_old_plain in let
(out_b:buffer128) = va_in_out_b in let (round_keys:(seq quad32)) = va_in_round_keys in va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_qWhile va_mods (Cmp_ne (va_op_cmp_reg 8) (va_op_cmp_reg 26)) (fun va_g -> qblock va_mods
(fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_body0 va_old alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))) (fun (va_s:va_state) va_g -> va_get_ok va_s /\ (0 <= va_get_reg
8 va_s /\ va_get_reg 8 va_s <= va_get_reg 26 va_s) /\ va_get_reg 9 va_s == 16 `op_Multiply`
va_get_reg 8 va_s /\ va_get_vec 7 va_s == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s
+ va_get_reg 8 va_s) /\ (Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 3 va_s) in_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s) (va_get_reg 7 va_s) out_b
(va_get_reg 6 va_s) (va_get_reg 26 va_s) (va_get_mem_layout va_s) Secret /\ va_get_reg 3 va_s +
16 `op_Multiply` va_get_reg 26 va_s < pow2_64 /\ va_get_reg 7 va_s + 16 `op_Multiply`
va_get_reg 26 va_s < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128
in_b == Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 out_b /\ (va_get_reg 8
va_s =!= va_get_reg 26 va_s ==> Vale.AES.GCTR_BE.partial_seq_agreement old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s)
in_b)) (va_get_reg 6 va_s + va_get_reg 8 va_s) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b)) /\ va_get_reg 6 va_s + va_get_reg 26 va_s < pow2_32 /\
aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s) (va_get_mem_heaplet 0 va_s)
(va_get_mem_layout va_s) /\ va_get_vec 3 va_s == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 1 0 0 0 /\ Vale.PPC64LE.Decls.modifies_buffer128 out_b
(va_get_mem_heaplet 1 va_old) (va_get_mem_heaplet 1 va_s) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s + va_get_reg 8 va_s) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b)) key old_icb /\ (va_get_reg 6 va_s
+ va_get_reg 26 va_s == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s) out_b ==
Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) out_b)) (fun (va_s:va_state) va_g ->
va_get_reg 26 va_s - va_get_reg 8 va_s) (())) (fun (va_s:va_state) va_g -> let va_g = () in
va_QEmpty (()))))
val va_lemma_Gctr_blocks128_1way_while0 : va_b0:va_code -> va_s0:va_state -> va_old:va_state ->
alg:algorithm -> va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 ->
va_in_old_icb:quad32 -> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 ->
va_in_round_keys:(seq quad32)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way_while0 alg) va_s0 /\ va_get_ok
va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\ va_get_reg 9
va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (0
<= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ va_get_reg 9 va_sM == 16
`op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite
va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) /\ va_state_eq va_sM (va_update_vec 7 va_sM
(va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM
(va_update_reg 10 va_sM (va_update_ok va_sM (va_update_mem va_sM (va_update_mem_heaplet 1 va_sM
(va_update_cr0 va_sM va_s0))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way_while0 va_b0 va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys =
let va_old = va_expand_state va_old in
let (va_mods:va_mods_t) = [va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0] in
let va_qc = va_qcode_Gctr_blocks128_1way_while0 va_mods va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way_while0 alg) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 229 column 28 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 230 column 34 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 231 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM +
va_get_reg 8 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 235 column 62 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 236 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 237 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 238 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 239 column 41 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 7 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 240 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_out_b) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 241 column 143 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==> Vale.AES.GCTR_BE.partial_seq_agreement
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 242 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 245 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM) (va_get_mem_heaplet
0 va_sM) (va_get_mem_layout va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 248 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 3 va_sM == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 251 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 252 column 122 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 8 va_sM)
va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 253 column 83 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) (va_s0:va_state) (va_k:(va_state
-> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (0 <= va_get_reg 8 va_s0 /\ va_get_reg 8 va_s0 <= va_get_reg 26 va_s0) /\
va_get_reg 9 va_s0 == 16 `op_Multiply` va_get_reg 8 va_s0 /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
va_in_in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
va_in_out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
va_get_reg 3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_s0 =!= va_get_reg 26 va_s0 ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0)
va_in_in_b)) (va_get_reg 6 va_s0 + va_get_reg 8 va_s0) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_vec 3 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_s0 +
va_get_reg 8 va_s0) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_s0 + va_get_reg 26 va_s0 == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_s0) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
(forall (va_x_cr0:cr0_t) (va_x_heap1:vale_heap) (va_x_mem:vale_heap) (va_x_ok:bool)
(va_x_r10:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_v0:quad32) (va_x_v2:quad32)
(va_x_v7:quad32) . let va_sM = va_upd_vec 7 va_x_v7 (va_upd_vec 2 va_x_v2 (va_upd_vec 0 va_x_v0
(va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8 (va_upd_reg 10 va_x_r10 (va_upd_ok va_x_ok
(va_upd_mem va_x_mem (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0 va_s0))))))))) in
va_get_ok va_sM /\ (0 <= va_get_reg 8 va_sM /\ va_get_reg 8 va_sM <= va_get_reg 26 va_sM) /\
va_get_reg 9 va_sM == 16 `op_Multiply` va_get_reg 8 va_sM /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite va_in_old_icb (va_get_reg 6 va_sM + va_get_reg 8 va_sM) /\
(Vale.PPC64LE.Decls.buffers_disjoint128 va_in_in_b va_in_out_b \/ va_in_in_b == va_in_out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 3 va_sM)
va_in_in_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_sM) (va_get_reg 7 va_sM)
va_in_out_b (va_get_reg 6 va_sM) (va_get_reg 26 va_sM) (va_get_mem_layout va_sM) Secret /\
va_get_reg 3 va_sM + 16 `op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ va_get_reg 7 va_sM + 16
`op_Multiply` va_get_reg 26 va_sM < pow2_64 /\ Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_out_b /\ (va_get_reg 8 va_sM =!= va_get_reg 26 va_sM ==>
Vale.AES.GCTR_BE.partial_seq_agreement va_in_old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
va_in_in_b)) (va_get_reg 6 va_sM + va_get_reg 8 va_sM) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 va_in_in_b)) /\ va_get_reg 6 va_sM + va_get_reg 26 va_sM <
pow2_32 /\ aes_reqs alg va_in_key va_in_round_keys va_in_keys_b (va_get_reg 4 va_sM)
(va_get_mem_heaplet 0 va_sM) (va_get_mem_layout va_sM) /\ va_get_vec 3 va_sM ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 1 0 0 0 /\
Vale.PPC64LE.Decls.modifies_buffer128 va_in_out_b (va_get_mem_heaplet 1 va_old)
(va_get_mem_heaplet 1 va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM +
va_get_reg 8 va_sM) va_in_old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) va_in_out_b)) va_in_key va_in_old_icb /\
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) va_in_out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_old) va_in_out_b) /\
~(va_get_reg 8 va_sM =!= va_get_reg 26 va_sM) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way_while0 : va_old:va_state -> alg:algorithm ->
va_in_in_b:buffer128 -> va_in_key:(seq nat32) -> va_in_keys_b:buffer128 -> va_in_old_icb:quad32
-> va_in_old_plain:(seq quad32) -> va_in_out_b:buffer128 -> va_in_round_keys:(seq 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_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key
va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way_while0 alg)
([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10;
va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way_while0 (va_code_Gctr_blocks128_1way_while0 alg)
va_s0 va_old alg va_in_in_b va_in_key va_in_keys_b va_in_old_icb va_in_old_plain va_in_out_b
va_in_round_keys in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_vec 7 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM
(va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_reg 10 va_sM (va_update_ok va_sM
(va_update_mem va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM va_s0)))))))))));
va_lemma_norm_mods ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 9; va_Mod_reg 8;
va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1; va_Mod_cr0]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gctr_blocks128_1way_while0 (va_old:va_state) (alg:algorithm) (va_in_in_b:buffer128)
(va_in_key:(seq nat32)) (va_in_keys_b:buffer128) (va_in_old_icb:quad32) (va_in_old_plain:(seq
quad32)) (va_in_out_b:buffer128) (va_in_round_keys:(seq quad32)) : (va_quickCode unit
(va_code_Gctr_blocks128_1way_while0 alg)) =
(va_QProc (va_code_Gctr_blocks128_1way_while0 alg) ([va_Mod_vec 7; va_Mod_vec 2; va_Mod_vec 0;
va_Mod_reg 9; va_Mod_reg 8; va_Mod_reg 10; va_Mod_ok; va_Mod_mem; va_Mod_mem_heaplet 1;
va_Mod_cr0]) (va_wp_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys)
(va_wpProof_Gctr_blocks128_1way_while0 va_old alg va_in_in_b va_in_key va_in_keys_b
va_in_old_icb va_in_old_plain va_in_out_b va_in_round_keys))
#pop-options
//--
//-- Gctr_blocks128_1way
#push-options "--z3rlimit 30"
val va_code_Gctr_blocks128_1way : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_1way alg =
(va_Block (va_CCons (va_code_Vspltisw (va_op_vec_opr_vec 3) 1) (va_CCons (va_code_Vspltisw
(va_op_vec_opr_vec 4) 0) (va_CCons (va_code_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 3) 4) (va_CCons (va_code_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_CCons
(va_code_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_CCons (va_code_Gctr_blocks128_1way_while0 alg)
(va_CNil ()))))))))
val va_codegen_success_Gctr_blocks128_1way : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_1way alg =
(va_pbool_and (va_codegen_success_Vspltisw (va_op_vec_opr_vec 3) 1) (va_pbool_and
(va_codegen_success_Vspltisw (va_op_vec_opr_vec 4) 0) (va_pbool_and (va_codegen_success_Vsldoi
(va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_pbool_and
(va_codegen_success_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_pbool_and
(va_codegen_success_Gctr_blocks128_1way_while0 alg) (va_ttrue ())))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gctr_blocks128_1way (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128)
(out_b:buffer128) (old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way 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 219 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 3) 1) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 220 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vspltisw (va_op_vec_opr_vec 4) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 221 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vsldoi (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 3) 4) (va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 223 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 8) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 224 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_LoadImm64 (va_op_reg_opr_reg 9) 0) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 226 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Gctr_blocks128_1way_while0 va_old_s alg in_b key keys_b old_icb old_plain out_b
round_keys) (va_QEmpty (())))))))))
val va_lemma_Gctr_blocks128_1way : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
in_b:buffer128 -> out_b:buffer128 -> old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32)
-> round_keys:(seq quad32) -> keys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gctr_blocks128_1way alg) va_s0 /\ va_get_ok va_s0 /\
((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7 va_sM (va_update_vec 4
va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0 va_sM (va_update_reg 10
va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gctr_blocks128_1way va_b0 va_s0 alg in_b out_b old_icb old_plain key round_keys keys_b
=
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4;
va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok;
va_Mod_mem] in
let va_qc = va_qcode_Gctr_blocks128_1way va_mods alg in_b out_b old_icb old_plain key round_keys
keys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gctr_blocks128_1way alg) va_qc va_s0
(fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 171 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 212 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.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 215 column 118 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM) old_plain
(Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out_b)) key old_icb) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 216 column 51 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_vec 7 va_sM == Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 217 column 79 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_reg 6 va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet
1 va_sM) out_b == Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_ok; va_Mod_mem])
va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (old_icb:quad32)
(old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ ((Vale.PPC64LE.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\
Vale.PPC64LE.Decls.validSrcAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 3 va_s0)
in_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 6 va_s0) (va_get_reg 26 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg
3 va_s0 + 16 `op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ va_get_reg 7 va_s0 + 16
`op_Multiply` va_get_reg 26 va_s0 < pow2_64 /\ l_and (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b == Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 out_b) (Vale.PPC64LE.Decls.buffer_length
#Vale.PPC64LE.Memory.vuint128 in_b < pow2_32) /\ va_get_reg 6 va_s0 + va_get_reg 26 va_s0 ==
Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b /\ va_get_reg 6 va_s0 +
va_get_reg 26 va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg 4 va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
Vale.AES.GCTR_BE.partial_seq_agreement old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b)) (va_get_reg 6 va_s0)
(Vale.PPC64LE.Decls.buffer_length #Vale.PPC64LE.Memory.vuint128 in_b) /\ va_get_vec 7 va_s0 ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_s0) /\ Vale.AES.GCTR_BE.gctr_partial_def
alg (va_get_reg 6 va_s0) old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq
(Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) key old_icb) /\ (forall
(va_x_mem:vale_heap) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64) (va_x_v0:quad32)
(va_x_v2:quad32) (va_x_v3:quad32) (va_x_v4:quad32) (va_x_v7:quad32) (va_x_cr0:cr0_t)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_cr0 va_x_cr0
(va_upd_vec 7 va_x_v7 (va_upd_vec 4 va_x_v4 (va_upd_vec 3 va_x_v3 (va_upd_vec 2 va_x_v2
(va_upd_vec 0 va_x_v0 (va_upd_reg 10 va_x_r10 (va_upd_reg 9 va_x_r9 (va_upd_reg 8 va_x_r8
(va_upd_mem va_x_mem va_s0)))))))))) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR_BE.gctr_partial_def alg (va_get_reg 6 va_sM + va_get_reg 26 va_sM)
old_plain (Vale.Arch.Types.reverse_bytes_quad32_seq (Vale.PPC64LE.Decls.s128
(va_get_mem_heaplet 1 va_sM) out_b)) key old_icb /\ va_get_vec 7 va_sM ==
Vale.AES.GCTR_BE.inc32lite old_icb (va_get_reg 6 va_sM + va_get_reg 26 va_sM) /\ (va_get_reg 6
va_sM + va_get_reg 26 va_sM == 0 ==> Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b
== Vale.PPC64LE.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) ==> va_k va_sM (())))
val va_wpProof_Gctr_blocks128_1way : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 ->
old_icb:quad32 -> old_plain:(seq quad32) -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_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_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key
round_keys keys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gctr_blocks128_1way alg)
([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2;
va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b va_s0
va_k =
let (va_sM, va_f0) = va_lemma_Gctr_blocks128_1way (va_code_Gctr_blocks128_1way alg) va_s0 alg
in_b out_b old_icb old_plain key round_keys keys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_cr0 va_sM (va_update_vec 7
va_sM (va_update_vec 4 va_sM (va_update_vec 3 va_sM (va_update_vec 2 va_sM (va_update_vec 0
va_sM (va_update_reg 10 va_sM (va_update_reg 9 va_sM (va_update_reg 8 va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0)))))))))))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7; va_Mod_vec 4; va_Mod_vec 3;
va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg 8; 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_Gctr_blocks128_1way (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(old_icb:quad32) (old_plain:(seq quad32)) (key:(seq nat32)) (round_keys:(seq quad32))
(keys_b:buffer128) : (va_quickCode unit (va_code_Gctr_blocks128_1way alg)) =
(va_QProc (va_code_Gctr_blocks128_1way alg) ([va_Mod_mem_heaplet 1; va_Mod_cr0; va_Mod_vec 7;
va_Mod_vec 4; va_Mod_vec 3; va_Mod_vec 2; va_Mod_vec 0; va_Mod_reg 10; va_Mod_reg 9; va_Mod_reg
8; va_Mod_mem]) (va_wp_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys
keys_b) (va_wpProof_Gctr_blocks128_1way alg in_b out_b old_icb old_plain key round_keys keys_b))
#pop-options
//--
//-- Store_3blocks128_1
val va_code_Store_3blocks128_1 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_1 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_1 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_1 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 0) (va_op_reg_opr_reg 7) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 1) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 2) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_1 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_1 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 287 column 27 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 0)
(va_op_reg_opr_reg 7) Secret out_b (va_get_reg 8 va_s)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 288 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 1)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 27) Secret out_b (va_get_reg 8 va_s + 1)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 289 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 2)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 28) Secret out_b (va_get_reg 8 va_s + 2)) (va_QEmpty
(()))))))
val va_lemma_Store_3blocks128_1 : va_b0:va_code -> va_s0:va_state -> out_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Store_3blocks128_1 ()) va_s0 /\ va_get_ok va_s0 /\
(va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 8 va_s0) (va_get_reg 6
va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 27 va_s0 == 1
`op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply` 16)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))
[@"opaque_to_smt"]
let va_lemma_Store_3blocks128_1 va_b0 va_s0 out_b =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Store_3blocks128_1 va_mods out_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Store_3blocks128_1 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 282 column 76 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 70 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 284 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 285 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Store_3blocks128_1 (out_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 8 va_s0) (va_get_reg 6 va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0)
Secret /\ va_get_reg 27 va_s0 == 1 `op_Multiply` 16 /\ va_get_reg 28 va_s0 == 2 `op_Multiply`
16) /\ (forall (va_x_mem:vale_heap) (va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1
va_x_heap1 (va_upd_mem va_x_mem va_s0) in va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM) (va_get_reg 8 va_sM + 2) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 0 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 1) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 1 va_sM) /\ Vale.PPC64LE.Decls.buffer128_read
out_b (va_get_reg 8 va_sM + 2) (va_get_mem_heaplet 1 va_sM) ==
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 2 va_sM)) ==> va_k va_sM (())))
val va_wpProof_Store_3blocks128_1 : out_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_Store_3blocks128_1 out_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Store_3blocks128_1 ())
([va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Store_3blocks128_1 out_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Store_3blocks128_1 (va_code_Store_3blocks128_1 ()) va_s0 out_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; 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_Store_3blocks128_1 (out_b:buffer128) : (va_quickCode unit (va_code_Store_3blocks128_1
())) =
(va_QProc (va_code_Store_3blocks128_1 ()) ([va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Store_3blocks128_1 out_b) (va_wpProof_Store_3blocks128_1 out_b))
//--
//-- Store_3blocks128_2
val va_code_Store_3blocks128_2 : va_dummy:unit -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Store_3blocks128_2 () =
(va_Block (va_CCons (va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_CCons
(va_code_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_CNil ())))))
val va_codegen_success_Store_3blocks128_2 : va_dummy:unit -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Store_3blocks128_2 () =
(va_pbool_and (va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 3) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 4) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret) (va_pbool_and
(va_codegen_success_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1)
(va_op_vec_opr_vec 5) (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret) (va_ttrue ()))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Store_3blocks128_2 (va_mods:va_mods_t) (out_b:buffer128) : (va_quickCode unit
(va_code_Store_3blocks128_2 ())) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 313 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 3)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 29) Secret out_b (va_get_reg 8 va_s + 3)) (fun
(va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 314 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 4)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 30) Secret out_b (va_get_reg 8 va_s + 4)) (fun
(va_s:va_state) _ -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 315 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Store128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 5)
(va_op_reg_opr_reg 7) (va_op_reg_opr_reg 31) Secret out_b (va_get_reg 8 va_s + 5)) (va_QEmpty
(()))))))
val va_lemma_Store_3blocks128_2 : va_b0:va_code -> va_s0:va_state -> out_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Store_3blocks128_2 ()) va_s0 /\ va_get_ok va_s0 /\
(va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\ Vale.PPC64LE.Decls.validDstAddrsOffset128
(va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0) out_b (va_get_reg 8 va_s0) (va_get_reg 6
va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg 29 va_s0 == 3
`op_Multiply` 16 /\ va_get_reg 30 va_s0 == 4 `op_Multiply` 16 /\ va_get_reg 31 va_s0 == 5
`op_Multiply` 16)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg 8 va_sM + 5) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)) /\ va_state_eq va_sM
(va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))
[@"opaque_to_smt"]
let va_lemma_Store_3blocks128_2 va_b0 va_s0 out_b =
let (va_mods:va_mods_t) = [va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Store_3blocks128_2 va_mods out_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Store_3blocks128_2 ()) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 292 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 308 column 80 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b (va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg 8 va_sM + 5)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 309 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 310 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 311 column 74 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Store_3blocks128_2 (out_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (va_get_reg 8 va_s0 + 5 < va_get_reg 6 va_s0 /\
Vale.PPC64LE.Decls.validDstAddrsOffset128 (va_get_mem_heaplet 1 va_s0) (va_get_reg 7 va_s0)
out_b (va_get_reg 8 va_s0) (va_get_reg 6 va_s0 - va_get_reg 8 va_s0) (va_get_mem_layout va_s0)
Secret /\ va_get_reg 29 va_s0 == 3 `op_Multiply` 16 /\ va_get_reg 30 va_s0 == 4 `op_Multiply`
16 /\ va_get_reg 31 va_s0 == 5 `op_Multiply` 16) /\ (forall (va_x_mem:vale_heap)
(va_x_heap1:vale_heap) . let va_sM = va_upd_mem_heaplet 1 va_x_heap1 (va_upd_mem va_x_mem
va_s0) in va_get_ok va_sM /\ (Vale.PPC64LE.Decls.modifies_buffer_specific128 out_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) (va_get_reg 8 va_sM + 3) (va_get_reg
8 va_sM + 5) /\ Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 3)
(va_get_mem_heaplet 1 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 3 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 4) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 4 va_sM) /\
Vale.PPC64LE.Decls.buffer128_read out_b (va_get_reg 8 va_sM + 5) (va_get_mem_heaplet 1 va_sM)
== Vale.Def.Types_s.reverse_bytes_quad32 (va_get_vec 5 va_sM)) ==> va_k va_sM (())))
val va_wpProof_Store_3blocks128_2 : out_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_Store_3blocks128_2 out_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Store_3blocks128_2 ())
([va_Mod_mem_heaplet 1; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Store_3blocks128_2 out_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Store_3blocks128_2 (va_code_Store_3blocks128_2 ()) va_s0 out_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_mem_heaplet 1 va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))));
va_lemma_norm_mods ([va_Mod_mem_heaplet 1; 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_Store_3blocks128_2 (out_b:buffer128) : (va_quickCode unit (va_code_Store_3blocks128_2
())) =
(va_QProc (va_code_Store_3blocks128_2 ()) ([va_Mod_mem_heaplet 1; va_Mod_mem])
(va_wp_Store_3blocks128_2 out_b) (va_wpProof_Store_3blocks128_2 out_b))
//--
//-- Gctr_blocks128_6way_body
val va_code_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gctr_blocks128_6way_body alg =
(va_Block (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block
(va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_code_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 8))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 9))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 10))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 11))
(va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 12))
(va_CCons (va_code_AESEncryptBlock_6way alg) (va_CCons (va_code_Load128_byte16_buffer
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 14) (va_op_reg_opr_reg 3) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 15)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 27) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 16)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 28) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 17)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 29) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 18)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 30) Secret) (va_CCons
(va_code_Load128_byte16_buffer_index (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 19)
(va_op_reg_opr_reg 3) (va_op_reg_opr_reg 31) Secret) (va_CCons (va_code_Vxor (va_op_vec_opr_vec
0) (va_op_vec_opr_vec 14) (va_op_vec_opr_vec 0)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 15) (va_op_vec_opr_vec 1)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 16) (va_op_vec_opr_vec 2)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 17) (va_op_vec_opr_vec 3)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 4)
(va_op_vec_opr_vec 18) (va_op_vec_opr_vec 4)) (va_CCons (va_code_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 19) (va_op_vec_opr_vec 5)) (va_CCons (va_code_Store_3blocks128_1 ())
(va_CCons (va_code_Store_3blocks128_2 ()) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 8)
(va_op_reg_opr_reg 8) 6) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 3)
(6 `op_Multiply` 16)) (va_CCons (va_code_AddImm (va_op_reg_opr_reg 7) (va_op_reg_opr_reg 7) (6
`op_Multiply` 16)) (va_CCons (va_code_Vadduwm (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 13)) (va_CNil ())))))))))))))))))))))))))))))))))
val va_codegen_success_Gctr_blocks128_6way_body : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gctr_blocks128_6way_body alg =
(va_pbool_and (va_codegen_success_Vmr (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 7)) (va_pbool_and
(va_codegen_success_Vadduwm (va_op_vec_opr_vec 1) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 8))
(va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 2) (va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 9)) (va_pbool_and (va_codegen_success_Vadduwm (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 10)) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 4) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 11)) (va_pbool_and
(va_codegen_success_Vadduwm (va_op_vec_opr_vec 5) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 12))
(va_pbool_and (va_codegen_success_AESEncryptBlock_6way alg) (va_pbool_and
(va_codegen_success_Load128_byte16_buffer (va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 14)
(va_op_reg_opr_reg 3) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 15) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
27) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 16) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
28) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 17) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
29) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 18) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
30) Secret) (va_pbool_and (va_codegen_success_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet 1) (va_op_vec_opr_vec 19) (va_op_reg_opr_reg 3) (va_op_reg_opr_reg
31) Secret) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 0) (va_op_vec_opr_vec 14)
(va_op_vec_opr_vec 0)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 15) (va_op_vec_opr_vec 1)) (va_pbool_and (va_codegen_success_Vxor
(va_op_vec_opr_vec 2) (va_op_vec_opr_vec 16) (va_op_vec_opr_vec 2)) (va_pbool_and
(va_codegen_success_Vxor (va_op_vec_opr_vec 3) (va_op_vec_opr_vec 17) (va_op_vec_opr_vec 3))
(va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 4) (va_op_vec_opr_vec 18)
(va_op_vec_opr_vec 4)) (va_pbool_and (va_codegen_success_Vxor (va_op_vec_opr_vec 5)
(va_op_vec_opr_vec 19) (va_op_vec_opr_vec 5)) (va_pbool_and
(va_codegen_success_Store_3blocks128_1 ()) (va_pbool_and (va_codegen_success_Store_3blocks128_2
()) (va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 8) (va_op_reg_opr_reg 8) 6)
(va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 3) (va_op_reg_opr_reg 3) (6
`op_Multiply` 16)) (va_pbool_and (va_codegen_success_AddImm (va_op_reg_opr_reg 7)
(va_op_reg_opr_reg 7) (6 `op_Multiply` 16)) (va_pbool_and (va_codegen_success_Vadduwm
(va_op_vec_opr_vec 7) (va_op_vec_opr_vec 7) (va_op_vec_opr_vec 13)) (va_ttrue
())))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.State.fsti.checked",
"Vale.PPC64LE.QuickCodes.fsti.checked",
"Vale.PPC64LE.QuickCode.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.PPC64LE.InsVector.fsti.checked",
"Vale.PPC64LE.InsStack.fsti.checked",
"Vale.PPC64LE.InsMem.fsti.checked",
"Vale.PPC64LE.InsBasic.fsti.checked",
"Vale.PPC64LE.Decls.fsti.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_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.Types_helpers.fsti.checked",
"Vale.AES.PPC64LE.AES.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.GCTR_BE.fsti.checked",
"Vale.AES.GCM_helpers_BE.fsti.checked",
"Vale.AES.AES_common_s.fst.checked",
"Vale.AES.AES_BE_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.PPC64LE.GCTR.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "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_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.Types_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "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_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_mods: Vale.PPC64LE.QuickCode.va_mods_t ->
alg: Vale.AES.AES_common_s.algorithm ->
in_b: Vale.PPC64LE.Memory.buffer128 ->
out_b: Vale.PPC64LE.Memory.buffer128 ->
old_icb: Vale.PPC64LE.Memory.quad32 ->
key: FStar.Seq.Base.seq Vale.PPC64LE.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32 ->
keys_b: Vale.PPC64LE.Memory.buffer128 ->
plain_quads: FStar.Seq.Base.seq Vale.PPC64LE.Memory.quad32
-> Vale.PPC64LE.QuickCode.va_quickCode Prims.unit
(Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_6way_body alg) | Prims.Tot | [
"total"
] | [] | [
"Vale.PPC64LE.QuickCode.va_mods_t",
"Vale.AES.AES_common_s.algorithm",
"Vale.PPC64LE.Memory.buffer128",
"Vale.PPC64LE.Memory.quad32",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat32",
"Vale.PPC64LE.QuickCodes.qblock",
"Prims.unit",
"Prims.Cons",
"Vale.PPC64LE.Decls.va_code",
"Vale.PPC64LE.Machine_s.Block",
"Vale.PPC64LE.Decls.ins",
"Vale.PPC64LE.Decls.ocmp",
"Prims.Nil",
"Vale.PPC64LE.Machine_s.precode",
"Vale.PPC64LE.InsVector.va_code_Vmr",
"Vale.PPC64LE.Decls.va_op_vec_opr_vec",
"Vale.PPC64LE.InsVector.va_code_Vadduwm",
"Vale.AES.PPC64LE.AES.va_code_AESEncryptBlock_6way",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_op_heaplet_mem_heaplet",
"Vale.PPC64LE.Decls.va_op_reg_opr_reg",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.PPC64LE.InsVector.va_code_Load128_byte16_buffer_index",
"Vale.PPC64LE.InsVector.va_code_Vxor",
"Vale.AES.PPC64LE.GCTR.va_code_Store_3blocks128_1",
"Vale.AES.PPC64LE.GCTR.va_code_Store_3blocks128_2",
"Vale.PPC64LE.InsBasic.va_code_AddImm",
"Prims.op_Multiply",
"Vale.PPC64LE.Decls.va_state",
"Vale.PPC64LE.QuickCodes.va_qAssertSquash",
"Vale.PPC64LE.QuickCodes.va_range1",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.squash",
"Vale.PPC64LE.QuickCodes.va_QSeq",
"Vale.PPC64LE.InsVector.va_quick_Vmr",
"Vale.PPC64LE.InsVector.va_quick_Vadduwm",
"Vale.PPC64LE.QuickCodes.va_QBind",
"Vale.AES.PPC64LE.AES.va_quick_AESEncryptBlock_6way",
"Vale.PPC64LE.Decls.va_get_vec",
"Vale.AES.GCTR_BE.inc32lite",
"Vale.PPC64LE.InsVector.va_quick_Load128_byte16_buffer",
"Vale.PPC64LE.Decls.va_get_reg",
"Vale.PPC64LE.InsVector.va_quick_Load128_byte16_buffer_index",
"Prims.op_Addition",
"Vale.PPC64LE.InsVector.va_quick_Vxor",
"Vale.AES.PPC64LE.GCTR.va_quick_Store_3blocks128_1",
"Vale.AES.PPC64LE.GCTR.va_quick_Store_3blocks128_2",
"Vale.PPC64LE.QuickCodes.va_qAssert",
"Prims.eq2",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.PPC64LE.Decls.buffer128_read",
"Vale.PPC64LE.Decls.va_get_mem_heaplet",
"Vale.PPC64LE.QuickCodes.va_qPURE",
"Prims.pure_post",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Seq.Base.length",
"Prims.l_Forall",
"Prims.int",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.l_imp",
"FStar.Seq.Base.index",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.AES.GCTR_BE_s.inc32",
"Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq",
"Vale.PPC64LE.InsBasic.va_quick_AddImm",
"Vale.PPC64LE.QuickCodes.va_QEmpty",
"Vale.Arch.Types.reverse_bytes_quad32_seq",
"Vale.PPC64LE.Decls.s128",
"Prims.nat",
"Vale.Def.Words_s.nat32",
"Vale.PPC64LE.QuickCodes.quickCodes",
"Vale.PPC64LE.Machine_s.state",
"Vale.PPC64LE.QuickCode.va_quickCode",
"Vale.AES.PPC64LE.GCTR.va_code_Gctr_blocks128_6way_body"
] | [] | false | false | false | false | false | let va_qcode_Gctr_blocks128_6way_body
(va_mods: va_mods_t)
(alg: algorithm)
(in_b out_b: buffer128)
(old_icb: quad32)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b: buffer128)
(plain_quads: (seq quad32))
: (va_quickCode unit (va_code_Gctr_blocks128_6way_body alg)) =
| (qblock va_mods
(fun (va_s: va_state) ->
let va_old_s:va_state = va_s in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 383 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s)))
(fun _ ->
let ctr_enc_0:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
in_b
(va_get_reg 8 va_s)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s)))
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 384 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 1)))
(fun _ ->
let ctr_enc_1:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
in_b
(va_get_reg 8 va_s + 1)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 1)))
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 385 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 2)))
(fun _ ->
let ctr_enc_2:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32 (Vale.PPC64LE.Decls.buffer128_read
in_b
(va_get_reg 8 va_s + 2)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 2)))
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 386 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 3)))
(fun _ ->
let ctr_enc_3:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b
(va_get_reg 8 va_s + 3)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 3)))
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 387 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592: (FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592) alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb (va_get_reg 8 va_s + 4)))
(fun _ ->
let ctr_enc_4:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b
(va_get_reg 8 va_s + 4)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 8 va_s + 4)))
in
va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 388 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
((fun
(alg_10591: Vale.AES.AES_common_s.algorithm)
(key_10592:
(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(input_10593: Vale.Def.Types_s.quad32)
->
Vale.AES.AES_BE_s.is_aes_key_word alg_10591 key_10592)
alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 8 va_s + 5)))
(fun _ ->
let ctr_enc_5:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.quad32_xor (Vale.Def.Types_s.reverse_bytes_quad32
(Vale.PPC64LE.Decls.buffer128_read in_b
(va_get_reg 8 va_s + 5)
(va_get_mem_heaplet 1 va_s)))
(Vale.AES.AES_BE_s.aes_encrypt_word alg
key
(Vale.AES.GCTR_BE_s.inc32 old_icb
(va_get_reg 8 va_s + 5)))
in
va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 390 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vmr (va_op_vec_opr_vec 0)
(va_op_vec_opr_vec 7))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 391 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 1)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 392 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 2)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 9))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 393 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 3)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 10))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 394 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec 4
)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 11))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 395 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Vadduwm (va_op_vec_opr_vec
5)
(va_op_vec_opr_vec 7)
(va_op_vec_opr_vec 12))
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 397 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_AESEncryptBlock_6way
alg (va_get_vec 7 va_s)
(Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s)
1)
(Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s)
2)
(Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s)
3)
(Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s)
4)
(Vale.AES.GCTR_BE.inc32lite
(va_get_vec 7 va_s)
5) key round_keys
keys_b)
(fun (va_s: va_state) _ ->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 399 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer
(va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec
14)
(va_op_reg_opr_reg
3)
Secret
in_b
(va_get_reg 8 va_s
))
(fun
(va_s: va_state)
_
->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 400 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec
15)
(va_op_reg_opr_reg
3)
(va_op_reg_opr_reg
27)
Secret
in_b
(va_get_reg 8
va_s +
1))
(fun
(va_s:
va_state)
_
->
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 401 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index
(va_op_heaplet_mem_heaplet
1)
(va_op_vec_opr_vec
16
)
(va_op_reg_opr_reg
3)
(va_op_reg_opr_reg
28
)
Secret
in_b
(va_get_reg
8
va_s
+
2))
(fun
(va_s:
va_state
)
_
->
va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 402 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(va_quick_Load128_byte16_buffer_index
(
va_op_heaplet_mem_heaplet
1
)
(
va_op_vec_opr_vec
17
)
(
va_op_reg_opr_reg
3
)
(
va_op_reg_opr_reg
29
)
Secret
in_b
(
va_get_reg
8
va_s
+
3
)
)
(fun
(
va_s:
va_state
)
_
->
va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 403 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Load128_byte16_buffer_index
(
va_op_heaplet_mem_heaplet
1
)
(
va_op_vec_opr_vec
18
)
(
va_op_reg_opr_reg
3
)
(
va_op_reg_opr_reg
30
)
Secret
in_b
(
va_get_reg
8
va_s
+
4
)
)
(
fun
(
va_s:
va_state
)
_
->
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 404 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Load128_byte16_buffer_index
(
va_op_heaplet_mem_heaplet
1
)
(
va_op_vec_opr_vec
19
)
(
va_op_reg_opr_reg
3
)
(
va_op_reg_opr_reg
31
)
Secret
in_b
(
va_get_reg
8
va_s
+
5
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
0
)
(
va_op_vec_opr_vec
14
)
(
va_op_vec_opr_vec
0
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 407 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
1
)
(
va_op_vec_opr_vec
15
)
(
va_op_vec_opr_vec
1
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
2
)
(
va_op_vec_opr_vec
16
)
(
va_op_vec_opr_vec
2
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
3
)
(
va_op_vec_opr_vec
17
)
(
va_op_vec_opr_vec
3
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 410 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
4
)
(
va_op_vec_opr_vec
18
)
(
va_op_vec_opr_vec
4
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 411 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vxor
(
va_op_vec_opr_vec
5
)
(
va_op_vec_opr_vec
19
)
(
va_op_vec_opr_vec
5
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 413 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Store_3blocks128_1
out_b
)
(
va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 414 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Store_3blocks128_2
out_b
)
(
fun
(
va_s:
va_state
)
_
->
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 415 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_0
)
(
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 416 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
+
1
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_1
)
(
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 417 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
+
2
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_2
)
(
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 418 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
+
3
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_3
)
(
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 419 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
+
4
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_4
)
(
va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 420 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
Vale.Def.Types_s.reverse_bytes_quad32
(
Vale.PPC64LE.Decls.buffer128_read
out_b
(
va_get_reg
8
va_s
+
5
)
(
va_get_mem_heaplet
1
va_s
)
)
==
ctr_enc_5
)
(
let
va_arg64:(
FStar.Seq.Base.seq
Vale.Def.Types_s.nat32
)
=
key
in
let
va_arg63:Vale.AES.AES_common_s.algorithm
=
alg
in
let
va_arg62:Vale.Def.Types_s.quad32
=
old_icb
in
let
va_arg61:Prims.nat
=
va_get_reg
8
va_s
in
let
va_arg60:(
FStar.Seq.Base.seq
Vale.Def.Types_s.quad32
)
=
plain_quads
in
let
va_arg59:(
FStar.Seq.Base.seq
Vale.Def.Types_s.quad32
)
=
Vale.Arch.Types.reverse_bytes_quad32_seq
(
Vale.PPC64LE.Decls.s128
(
va_get_mem_heaplet
1
va_old_s
)
out_b
)
in
let
va_arg58:(
FStar.Seq.Base.seq
Vale.Def.Types_s.quad32
)
=
Vale.Arch.Types.reverse_bytes_quad32_seq
(
Vale.PPC64LE.Decls.s128
(
va_get_mem_heaplet
1
va_s
)
out_b
)
in
va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 422 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
fun
(
_:
unit
)
->
Vale.AES.GCTR_BE.lemma_eq_reverse_bytes_quad32_seq
va_arg58
va_arg59
va_arg60
va_arg61
va_arg62
va_arg63
va_arg64
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 424 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_AddImm
(
va_op_reg_opr_reg
8
)
(
va_op_reg_opr_reg
8
)
6
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 425 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_AddImm
(
va_op_reg_opr_reg
3
)
(
va_op_reg_opr_reg
3
)
(
6
`op_Multiply`
16
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 426 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_AddImm
(
va_op_reg_opr_reg
7
)
(
va_op_reg_opr_reg
7
)
(
6
`op_Multiply`
16
)
)
(
va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 427 column 12 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/ppc64le/Vale.AES.PPC64LE.GCTR.vaf *****"
(
va_quick_Vadduwm
(
va_op_vec_opr_vec
7
)
(
va_op_vec_opr_vec
7
)
(
va_op_vec_opr_vec
13
)
)
(
va_QEmpty
(
()
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))))
))))))))))))))) | false |
Problem01.fst | Problem01.test_prefix | val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat ->
Tot (b:bool{b ==> (exists (i:nat). i <= n /\ prefix (remove_elem_from_list p i) str)}) | val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat ->
Tot (b:bool{b ==> (exists (i:nat). i <= n /\ prefix (remove_elem_from_list p i) str)}) | let rec test_prefix p n str =
match n with
| 0 -> prefix (remove_elem_from_list p n) str
| n -> prefix (remove_elem_from_list p n) str || test_prefix p (n - 1) str | {
"file_name": "examples/verifythis/2015/Problem01.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 76,
"end_line": 37,
"start_col": 0,
"start_line": 34
} | (*
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 Problem01
open FStar.List.Tot
val prefix: p:list nat -> str:list nat -> Tot (b:bool{ b <==> (exists l. append p l = str)})
let rec prefix p str =
match p, str with
| [], _ -> true
| a::q, [] -> false
| a::q, a'::q' -> if a = a' then prefix q q' else false
val remove_elem_from_list: p:list nat -> i:nat{i < length p} -> Tot (list nat)
let rec remove_elem_from_list p i =
match p with
| a::q -> if i = 0 then q else a::remove_elem_from_list q (i-1)
val test_prefix: p:list nat -> n:nat{n < length p} -> str:list nat -> | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "Problem01.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: Prims.list Prims.nat ->
n: Prims.nat{n < FStar.List.Tot.Base.length p} ->
str: Prims.list Prims.nat
-> b:
Prims.bool
{ b ==>
(exists (i: Prims.nat). i <= n /\ Problem01.prefix (Problem01.remove_elem_from_list p i) str
) } | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"Problem01.prefix",
"Problem01.remove_elem_from_list",
"Prims.int",
"Prims.op_BarBar",
"Problem01.test_prefix",
"Prims.op_Subtraction",
"Prims.bool",
"Prims.l_imp",
"Prims.l_Exists",
"Prims.l_and",
"Prims.op_LessThanOrEqual"
] | [
"recursion"
] | false | false | false | false | false | let rec test_prefix p n str =
| match n with
| 0 -> prefix (remove_elem_from_list p n) str
| n -> prefix (remove_elem_from_list p n) str || test_prefix p (n - 1) str | false |
FStar.OrdMapProps.fst | FStar.OrdMapProps.fold | val fold: #k:eqtype -> #v:Type -> #a:Type -> #f:cmp k -> (k -> v -> a -> Tot a)
-> m:ordmap k v f -> a -> Tot a (decreases (size m)) | val fold: #k:eqtype -> #v:Type -> #a:Type -> #f:cmp k -> (k -> v -> a -> Tot a)
-> m:ordmap k v f -> a -> Tot a (decreases (size m)) | let rec fold #k #v #t #f g m a =
if size m = 0 then a
else
let Some (k, v) = choose m in
fold g (remove k m) (g k v a) | {
"file_name": "ulib/experimental/FStar.OrdMapProps.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 26,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.OrdMapProps
open FStar.OrdMap
val fold: #k:eqtype -> #v:Type -> #a:Type -> #f:cmp k -> (k -> v -> a -> Tot a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.OrdMap.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.OrdMapProps.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.OrdMap",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 | g: (_: k -> _: v -> _: a -> a) -> m: FStar.OrdMap.ordmap k v f -> a: a -> Prims.Tot a | Prims.Tot | [
"total",
""
] | [] | [
"Prims.eqtype",
"FStar.OrdMap.cmp",
"FStar.OrdMap.ordmap",
"Prims.op_Equality",
"Prims.int",
"FStar.OrdMap.size",
"Prims.bool",
"FStar.OrdMapProps.fold",
"FStar.OrdMap.remove",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.OrdMap.choose"
] | [
"recursion"
] | false | false | false | false | false | let rec fold #k #v #t #f g m a =
| if size m = 0
then a
else
let Some (k, v) = choose m in
fold g (remove k m) (g k v a) | false |
LowParse.Low.DepLen.fst | LowParse.Low.DepLen.valid_deplen_decomp | val valid_deplen_decomp : min: Prims.nat ->
max: Prims.nat{min <= max /\ max < 4294967296} ->
hp: LowParse.Spec.Base.parser hk ht ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
pp: LowParse.Spec.Base.parser pk pt ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t ->
h: FStar.Monotonic.HyperStack.mem
-> Prims.GTot Prims.logical | let valid_deplen_decomp
(min: nat)
(max: nat { min <= max /\ max < 4294967296 } )
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: ht -> Tot (bounded_int32 min max) )
(#pk: parser_kind)
(#pt: Type)
(pp: parser pk pt)
#rrel #rel
(input: slice rrel rel)
(pos: U32.t)
(h: HS.mem)
= valid hp h input pos /\
(let pos_payload = get_valid_pos hp h input pos in
let len = dlf (contents hp h input pos) in
U32.v pos_payload + U32.v len <= U32.v input.len /\
valid_exact pp h input pos_payload (pos_payload `U32.add` len)) | {
"file_name": "src/lowparse/LowParse.Low.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 67,
"end_line": 60,
"start_col": 0,
"start_line": 42
} | module LowParse.Low.DepLen
include LowParse.Spec.DepLen
include LowParse.Low.Base
include LowParse.Low.Combinators
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64
let valid_exact_valid_pos_equiv
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
#rrel #rel
(input: slice rrel rel)
(pos_begin: U32.t)
(pos_end: U32.t)
: Lemma
(requires live_slice h input)
(ensures
((valid_exact p h input pos_begin pos_end)
<==>
(U32.v pos_begin <= U32.v pos_end /\
U32.v pos_end <= U32.v input.len /\
(let input' = { base = input.base; len = pos_end; } in
valid_pos p h input' pos_begin pos_end))))
= valid_exact_equiv p h input pos_begin pos_end;
if U32.v pos_begin <= U32.v pos_end && U32.v pos_end <= U32.v input.len then
begin
let input' = { base = input.base; len = pos_end; } in
valid_facts p h input' pos_begin
end
(* the validity lemma says it is equivalent to have a valid header followed by a valid payload and
have a valid piece of deplen data *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.DepLen.fst.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.DepLen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 /\ max < 4294967296} ->
hp: LowParse.Spec.Base.parser hk ht ->
dlf: (_: ht -> LowParse.Spec.BoundedInt.bounded_int32 min max) ->
pp: LowParse.Spec.Base.parser pk pt ->
input: LowParse.Slice.slice rrel rel ->
pos: FStar.UInt32.t ->
h: FStar.Monotonic.HyperStack.mem
-> Prims.GTot Prims.logical | Prims.GTot | [
"sometrivial"
] | [] | [
"Prims.nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Low.Base.Spec.valid",
"Prims.op_Addition",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowParse.Low.Base.Spec.valid_exact",
"FStar.UInt32.add",
"LowParse.Low.Base.Spec.contents",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.logical"
] | [] | false | false | false | false | true | let valid_deplen_decomp
(min: nat)
(max: nat{min <= max /\ max < 4294967296})
(#hk: parser_kind)
(#ht: Type)
(hp: parser hk ht)
(dlf: (ht -> Tot (bounded_int32 min max)))
(#pk: parser_kind)
(#pt: Type)
(pp: parser pk pt)
#rrel
#rel
(input: slice rrel rel)
(pos: U32.t)
(h: HS.mem)
=
| valid hp h input pos /\
(let pos_payload = get_valid_pos hp h input pos in
let len = dlf (contents hp h input pos) in
U32.v pos_payload + U32.v len <= U32.v input.len /\
valid_exact pp h input pos_payload (pos_payload `U32.add` len)) | false |
|
LowParse.Low.DepLen.fst | LowParse.Low.DepLen.valid_exact_valid_pos_equiv | val valid_exact_valid_pos_equiv
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos_begin pos_end: U32.t)
: Lemma (requires live_slice h input)
(ensures
((valid_exact p h input pos_begin pos_end) <==>
(U32.v pos_begin <= U32.v pos_end /\ U32.v pos_end <= U32.v input.len /\
(let input' = { base = input.base; len = pos_end } in
valid_pos p h input' pos_begin pos_end)))) | val valid_exact_valid_pos_equiv
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
(#rrel #rel: _)
(input: slice rrel rel)
(pos_begin pos_end: U32.t)
: Lemma (requires live_slice h input)
(ensures
((valid_exact p h input pos_begin pos_end) <==>
(U32.v pos_begin <= U32.v pos_end /\ U32.v pos_end <= U32.v input.len /\
(let input' = { base = input.base; len = pos_end } in
valid_pos p h input' pos_begin pos_end)))) | let valid_exact_valid_pos_equiv
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
#rrel #rel
(input: slice rrel rel)
(pos_begin: U32.t)
(pos_end: U32.t)
: Lemma
(requires live_slice h input)
(ensures
((valid_exact p h input pos_begin pos_end)
<==>
(U32.v pos_begin <= U32.v pos_end /\
U32.v pos_end <= U32.v input.len /\
(let input' = { base = input.base; len = pos_end; } in
valid_pos p h input' pos_begin pos_end))))
= valid_exact_equiv p h input pos_begin pos_end;
if U32.v pos_begin <= U32.v pos_end && U32.v pos_end <= U32.v input.len then
begin
let input' = { base = input.base; len = pos_end; } in
valid_facts p h input' pos_begin
end | {
"file_name": "src/lowparse/LowParse.Low.DepLen.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 37,
"start_col": 0,
"start_line": 14
} | module LowParse.Low.DepLen
include LowParse.Spec.DepLen
include LowParse.Low.Base
include LowParse.Low.Combinators
module B = LowStar.Monotonic.Buffer
module U32 = FStar.UInt32
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module Cast = FStar.Int.Cast
module U64 = FStar.UInt64 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowParse.Spec.DepLen.fst.checked",
"LowParse.Low.Combinators.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.DepLen.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.DepLen",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
p: LowParse.Spec.Base.parser k t ->
h: FStar.Monotonic.HyperStack.mem ->
input: LowParse.Slice.slice rrel rel ->
pos_begin: FStar.UInt32.t ->
pos_end: FStar.UInt32.t
-> FStar.Pervasives.Lemma (requires LowParse.Slice.live_slice h input)
(ensures
LowParse.Low.Base.Spec.valid_exact p h input pos_begin pos_end <==>
FStar.UInt32.v pos_begin <= FStar.UInt32.v pos_end /\
FStar.UInt32.v pos_end <= FStar.UInt32.v (Mkslice?.len input) /\
(let input' = LowParse.Slice.Mkslice (Mkslice?.base input) pos_end in
LowParse.Low.Base.Spec.valid_pos p h input' pos_begin pos_end)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"Prims.op_AmpAmp",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Slice.Mkslice",
"LowParse.Slice.__proj__Mkslice__item__base",
"Prims.bool",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_exact_equiv",
"LowParse.Slice.live_slice",
"Prims.squash",
"Prims.l_iff",
"LowParse.Low.Base.Spec.valid_exact",
"Prims.l_and",
"Prims.b2t",
"LowParse.Low.Base.Spec.valid_pos",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | false | false | true | false | false | let valid_exact_valid_pos_equiv
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(h: HS.mem)
#rrel
#rel
(input: slice rrel rel)
(pos_begin: U32.t)
(pos_end: U32.t)
: Lemma (requires live_slice h input)
(ensures
((valid_exact p h input pos_begin pos_end) <==>
(U32.v pos_begin <= U32.v pos_end /\ U32.v pos_end <= U32.v input.len /\
(let input' = { base = input.base; len = pos_end } in
valid_pos p h input' pos_begin pos_end)))) =
| valid_exact_equiv p h input pos_begin pos_end;
if U32.v pos_begin <= U32.v pos_end && U32.v pos_end <= U32.v input.len
then
let input' = { base = input.base; len = pos_end } in
valid_facts p h input' pos_begin | false |
Steel.Effect.Common.fsti | Steel.Effect.Common.true_p | val true_p:prop | val true_p:prop | let true_p : prop = True | {
"file_name": "lib/steel/Steel.Effect.Common.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 42,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
open Steel.Memory
module Mem = Steel.Memory
module FExt = FStar.FunctionalExtensionality
open FStar.Ghost
/// This module provides various predicates and functions which are common to the
/// different Steel effects.
/// It also contains the tactic responsible for frame inference through a variant of AC-unification
#set-options "--ide_id_info_off"
(* Normalization helpers *)
irreducible let framing_implicit : unit = ()
irreducible let __steel_reduce__ : unit = ()
/// An internal attribute for finer-grained normalization in framing equalities
irreducible let __inner_steel_reduce__ : unit = ()
irreducible let __reduce__ : unit = ()
irreducible let smt_fallback : unit = ()
irreducible let ite_attr : unit = ()
// Needed to avoid some logical vs prop issues during unification with no subtyping
[@@__steel_reduce__] | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.CanonCommMonoidSimple.Equiv.fst.checked",
"FStar.String.fsti.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.Derived.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "Steel.Effect.Common.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": 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.prop | Prims.Tot | [
"total"
] | [] | [
"Prims.l_True"
] | [] | false | false | false | true | true | let true_p:prop =
| True | false |
Steel.Effect.Common.fsti | Steel.Effect.Common.selector' | val selector' : a: Type0 -> hp: Steel.Memory.slprop -> Type | let selector' (a:Type0) (hp:slprop) = hmem hp -> GTot a | {
"file_name": "lib/steel/Steel.Effect.Common.fsti",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 55,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Effect.Common
open Steel.Memory
module Mem = Steel.Memory
module FExt = FStar.FunctionalExtensionality
open FStar.Ghost
/// This module provides various predicates and functions which are common to the
/// different Steel effects.
/// It also contains the tactic responsible for frame inference through a variant of AC-unification
#set-options "--ide_id_info_off"
(* Normalization helpers *)
irreducible let framing_implicit : unit = ()
irreducible let __steel_reduce__ : unit = ()
/// An internal attribute for finer-grained normalization in framing equalities
irreducible let __inner_steel_reduce__ : unit = ()
irreducible let __reduce__ : unit = ()
irreducible let smt_fallback : unit = ()
irreducible let ite_attr : unit = ()
// Needed to avoid some logical vs prop issues during unification with no subtyping
[@@__steel_reduce__]
unfold
let true_p : prop = True
module T = FStar.Tactics.V2
let join_preserves_interp (hp:slprop) (m0:hmem hp) (m1:mem{disjoint m0 m1})
: Lemma
(interp hp (join m0 m1))
[SMTPat (interp hp (join m0 m1))]
= let open Steel.Memory in
intro_emp m1;
intro_star hp emp m0 m1;
affine_star hp emp (join m0 m1)
(* Definition of a selector for a given slprop *)
/// A selector of type `a` for a separation logic predicate hp is a function
/// from a memory where the predicate hp holds, which returns a value of type `a`.
/// The effect GTot indicates that selectors are ghost functions, used for specification | {
"checked_file": "/",
"dependencies": [
"Steel.Memory.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.CanonCommMonoidSimple.Equiv.fst.checked",
"FStar.String.fsti.checked",
"FStar.Squash.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Reflection.V2.Derived.Lemmas.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.Base.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.FunctionalExtensionality.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Algebra.CommMonoid.Equiv.fst.checked"
],
"interface_file": false,
"source_file": "Steel.Effect.Common.fsti"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "FExt"
},
{
"abbrev": true,
"full_module": "Steel.Memory",
"short_module": "Mem"
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": 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: Type0 -> hp: Steel.Memory.slprop -> Type | Prims.Tot | [
"total"
] | [] | [
"Steel.Memory.slprop",
"Steel.Memory.hmem"
] | [] | false | false | false | true | true | let selector' (a: Type0) (hp: slprop) =
| hmem hp -> GTot a | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.