effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_t_512 = state_t SHA2_512 | let state_t_512 = | false | null | false | state_t SHA2_512 | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.state_t",
"Spec.Hash.Definitions.SHA2_512"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_t_512 : Hacl.Streaming.Interface.stateful Prims.unit | [] | Hacl.Streaming.SHA2.state_t_512 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.stateful Prims.unit | {
"end_col": 34,
"end_line": 44,
"start_col": 18,
"start_line": 44
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_t_224 = state_t SHA2_224 | let state_t_224 = | false | null | false | state_t SHA2_224 | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.state_t",
"Spec.Hash.Definitions.SHA2_224"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_t_224 : Hacl.Streaming.Interface.stateful Prims.unit | [] | Hacl.Streaming.SHA2.state_t_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.stateful Prims.unit | {
"end_col": 34,
"end_line": 38,
"start_col": 18,
"start_line": 38
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | let update_384_512 = | false | null | false | F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.update",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_512",
"FStar.Ghost.hide",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_512",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ] | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_384_512 : Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.update_384_512 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 90,
"end_line": 174,
"start_col": 21,
"start_line": 174
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit) | let copy_256 = | false | null | false | F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.copy",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_256",
"FStar.Ghost.hide",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_256",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val copy_256 : Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_256
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_256 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.copy_256 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_256
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_256 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 73,
"end_line": 77,
"start_col": 15,
"start_line": 77
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit) | let alloca_224 = | false | null | false | F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.alloca",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_224",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_224",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// -------- | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val alloca_224 : Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_224
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_224 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.alloca_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.alloca_st Hacl.Streaming.SHA2.hacl_sha2_224
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_224 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 77,
"end_line": 128,
"start_col": 17,
"start_line": 128
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit) | let copy_512 = | false | null | false | F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.copy",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_512",
"FStar.Ghost.hide",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_512",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val copy_512 : Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_512
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.copy_512 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.copy_st Hacl.Streaming.SHA2.hacl_sha2_512
(FStar.Ghost.reveal (FStar.Ghost.hide ()))
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 73,
"end_line": 168,
"start_col": 15,
"start_line": 168
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hacl_sha2_384 = hacl_md SHA2_384 | let hacl_sha2_384 = | false | null | false | hacl_md SHA2_384 | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.hacl_md",
"Spec.Hash.Definitions.SHA2_384"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_sha2_384 : Hacl.Streaming.Interface.block Prims.unit | [] | Hacl.Streaming.SHA2.hacl_sha2_384 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Prims.unit | {
"end_col": 36,
"end_line": 33,
"start_col": 20,
"start_line": 33
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let create_in_384 = F.create_in hacl_sha2_384 () (state_t_384.s ()) (G.erased unit) | let create_in_384 = | false | null | false | F.create_in hacl_sha2_384 () (state_t_384.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.create_in",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_384",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_384",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384.";
]
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 64 bytes. The state remains
valid after a call to `finish_512`, meaning the user may feed more data into
the hash via `update_512`. (The finish_512 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_512 = F.mk_finish hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_512`.
This function is identical to the free function for SHA2_384.";
]
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 64 bytes."]
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-384
// --------
inline_for_extraction noextract | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create_in_384 : Hacl.Streaming.Functor.create_in_st Hacl.Streaming.SHA2.hacl_sha2_384
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_384 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.create_in_384 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.create_in_st Hacl.Streaming.SHA2.hacl_sha2_384
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_384 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 83,
"end_line": 218,
"start_col": 20,
"start_line": 218
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit) | let finish_224 = | false | null | false | F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.mk_finish",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_224",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_224",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val finish_224 : Hacl.Streaming.Functor.finish_st Hacl.Streaming.SHA2.hacl_sha2_224
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_224 ())
(FStar.Ghost.erased Prims.unit) | [] | Hacl.Streaming.SHA2.finish_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.finish_st Hacl.Streaming.SHA2.hacl_sha2_224
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_224 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 80,
"end_line": 138,
"start_col": 17,
"start_line": 138
} |
|
Prims.Tot | val update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len | val update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
let update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = | false | null | false | fun p input input_len -> update_224_256 p input input_len | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_256",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_256",
"FStar.Ghost.erased",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Functor.uint8",
"FStar.UInt32.t",
"Hacl.Streaming.SHA2.update_224_256",
"Hacl.Streaming.Types.error_code"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit) | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_224:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.update_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_256
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_256 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 148,
"end_line": 132,
"start_col": 91,
"start_line": 132
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hacl_sha2_224 = hacl_md SHA2_224 | let hacl_sha2_224 = | false | null | false | hacl_md SHA2_224 | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.hacl_md",
"Spec.Hash.Definitions.SHA2_224"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_sha2_224 : Hacl.Streaming.Interface.block Prims.unit | [] | Hacl.Streaming.SHA2.hacl_sha2_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Prims.unit | {
"end_col": 36,
"end_line": 29,
"start_col": 20,
"start_line": 29
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hacl_sha2_256 = hacl_md SHA2_256 | let hacl_sha2_256 = | false | null | false | hacl_md SHA2_256 | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.hacl_md",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_sha2_256 : Hacl.Streaming.Interface.block Prims.unit | [] | Hacl.Streaming.SHA2.hacl_sha2_256 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Prims.unit | {
"end_col": 36,
"end_line": 31,
"start_col": 20,
"start_line": 31
} |
|
Prims.Tot | val update_256:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len | val update_256:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
let update_256:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = | false | null | false | fun p input input_len -> update_224_256 p input input_len | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_256",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_256",
"FStar.Ghost.erased",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Functor.uint8",
"FStar.UInt32.t",
"Hacl.Streaming.SHA2.update_224_256",
"Hacl.Streaming.Types.error_code"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224."; | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_256:F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.update_256 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_256
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_256 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 148,
"end_line": 94,
"start_col": 91,
"start_line": 94
} |
Prims.Tot | val update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len | val update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
let update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = | false | null | false | fun p input input_len -> update_384_512 p input input_len | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_512",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_512",
"FStar.Ghost.erased",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Functor.uint8",
"FStar.UInt32.t",
"Hacl.Streaming.SHA2.update_384_512",
"Hacl.Streaming.Types.error_code"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384."; | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_512:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.update_512 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 148,
"end_line": 182,
"start_col": 91,
"start_line": 182
} |
Prims.Tot | val free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p | val free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
let free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = | false | null | false | fun p -> free_256 p | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_256",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_256",
"FStar.Ghost.erased",
"Hacl.Streaming.SHA2.free_256"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."] | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free_224:F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.free_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_256
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_256 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 106,
"end_line": 139,
"start_col": 87,
"start_line": 139
} |
Prims.Tot | val free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let free_384: F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p -> free_512 p | val free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
let free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = | false | null | false | fun p -> free_512 p | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_512",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_512",
"FStar.Ghost.erased",
"Hacl.Streaming.SHA2.free_512"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384.";
]
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 64 bytes. The state remains
valid after a call to `finish_512`, meaning the user may feed more data into
the hash via `update_512`. (The finish_512 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_512 = F.mk_finish hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_512`.
This function is identical to the free function for SHA2_384.";
]
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 64 bytes."]
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-384
// --------
inline_for_extraction noextract
let alloca_384 = F.alloca hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let create_in_384 = F.create_in hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let init_384 = F.init hacl_sha2_384 (G.hide ()) (state_t_384.s ()) (G.erased unit)
let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 48 bytes. The state remains
valid after a call to `finish_384`, meaning the user may feed more data into
the hash via `update_384`."]
let finish_384 = F.mk_finish hacl_sha2_384 () (state_t_384.s ()) (G.erased unit) | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val free_384:F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.free_384 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.free_st Hacl.Streaming.SHA2.hacl_sha2_512
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 106,
"end_line": 228,
"start_col": 87,
"start_line": 228
} |
Prims.Tot | val update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len | val update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
let update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = | false | null | false | fun p input input_len -> update_384_512 p input input_len | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state",
"Prims.unit",
"Hacl.Streaming.SHA2.hacl_sha2_512",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.SHA2.state_t_512",
"FStar.Ghost.erased",
"LowStar.Buffer.buffer",
"Hacl.Streaming.Functor.uint8",
"FStar.UInt32.t",
"Hacl.Streaming.SHA2.update_384_512",
"Hacl.Streaming.Types.error_code"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384.";
]
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 64 bytes. The state remains
valid after a call to `finish_512`, meaning the user may feed more data into
the hash via `update_512`. (The finish_512 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_512 = F.mk_finish hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_512`.
This function is identical to the free function for SHA2_384.";
]
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 64 bytes."]
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-384
// --------
inline_for_extraction noextract
let alloca_384 = F.alloca hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let create_in_384 = F.create_in hacl_sha2_384 () (state_t_384.s ()) (G.erased unit) | false | false | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_384:F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) | [] | Hacl.Streaming.SHA2.update_384 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Functor.update_st Hacl.Streaming.SHA2.hacl_sha2_512
()
(Stateful?.s Hacl.Streaming.SHA2.state_t_512 ())
(FStar.Ghost.erased Prims.unit) | {
"end_col": 148,
"end_line": 220,
"start_col": 91,
"start_line": 220
} |
Prims.Tot | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst) | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst = | false | null | false | [@@ inline_let ]let dst:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get () in
loc_multi1 rb;
hash #SHA2_224
#M32
sha224_init
sha224_update_nblocks
sha224_update_last
sha224_finish
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_224",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Hash.Definitions.hash_len",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M32",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Scalar32.sha224_init",
"Hacl.SHA2.Scalar32.sha224_update_nblocks",
"Hacl.SHA2.Scalar32.sha224_update_last",
"Hacl.SHA2.Scalar32.sha224_finish",
"Lib.MultiBuffer.loc_multi1",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.NTuple.ntup1",
"Lib.Buffer.lbuffer"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224 | [] | Hacl.Streaming.SHA2.hash_224 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_224 | {
"end_col": 54,
"end_line": 154,
"start_col": 2,
"start_line": 145
} |
Prims.Tot | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst) | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst = | false | null | false | [@@ inline_let ]let dst:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get () in
loc_multi1 rb;
hash #SHA2_256
#M32
sha256_init
sha256_update_nblocks
sha256_update_last
sha256_finish
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_256",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Hash.Definitions.hash_len",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M32",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Scalar32.sha256_init",
"Hacl.SHA2.Scalar32.sha256_update_nblocks",
"Hacl.SHA2.Scalar32.sha256_update_last",
"Hacl.SHA2.Scalar32.sha256_finish",
"Lib.MultiBuffer.loc_multi1",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.NTuple.ntup1",
"Lib.Buffer.lbuffer"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256 | [] | Hacl.Streaming.SHA2.hash_256 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_256 | {
"end_col": 54,
"end_line": 122,
"start_col": 2,
"start_line": 113
} |
Prims.Tot | val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384 | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_384 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_384) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_384 #M32 sha384_init sha384_update_nblocks sha384_update_last sha384_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_384 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst) | val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384
let hash_384 input input_len dst = | false | null | false | [@@ inline_let ]let dst:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_384) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get () in
loc_multi1 rb;
hash #SHA2_384
#M32
sha384_init
sha384_update_nblocks
sha384_update_last
sha384_finish
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_384 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_384",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Hash.Definitions.hash_len",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M32",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Scalar32.sha384_init",
"Hacl.SHA2.Scalar32.sha384_update_nblocks",
"Hacl.SHA2.Scalar32.sha384_update_last",
"Hacl.SHA2.Scalar32.sha384_finish",
"Lib.MultiBuffer.loc_multi1",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.NTuple.ntup1",
"Lib.Buffer.lbuffer"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384.";
]
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 64 bytes. The state remains
valid after a call to `finish_512`, meaning the user may feed more data into
the hash via `update_512`. (The finish_512 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_512 = F.mk_finish hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_512`.
This function is identical to the free function for SHA2_384.";
]
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 64 bytes."]
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-384
// --------
inline_for_extraction noextract
let alloca_384 = F.alloca hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let create_in_384 = F.create_in hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let init_384 = F.init hacl_sha2_384 (G.hide ()) (state_t_384.s ()) (G.erased unit)
let update_384: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 48 bytes. The state remains
valid after a call to `finish_384`, meaning the user may feed more data into
the hash via `update_384`."]
let finish_384 = F.mk_finish hacl_sha2_384 () (state_t_384.s ()) (G.erased unit)
let free_384: F.free_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p -> free_512 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 48 bytes."]
val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_384: Hacl.Hash.Definitions.hash_st SHA2_384 | [] | Hacl.Streaming.SHA2.hash_384 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_384 | {
"end_col": 54,
"end_line": 243,
"start_col": 2,
"start_line": 234
} |
Prims.Tot | val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.SHA2.Generic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.SHA2.Scalar32",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.SHA2.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.MultiBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.NTuple",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.MD",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hash_512 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_512 #M32 sha512_init sha512_update_nblocks sha512_update_last sha512_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst) | val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512
let hash_512 input input_len dst = | false | null | false | [@@ inline_let ]let dst:lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_512) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get () in
loc_multi1 rb;
hash #SHA2_512
#M32
sha512_init
sha512_update_nblocks
sha512_update_last
sha512_finish
rb
input_len
ib;
let h1 = ST.get () in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_512 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(| 0 |) == as_seq h1 dst) | {
"checked_file": "Hacl.Streaming.SHA2.fst.checked",
"dependencies": [
"Spec.Hash.Definitions.fst.checked",
"prims.fst.checked",
"Lib.NTuple.fsti.checked",
"Lib.MultiBuffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Streaming.MD.fst.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Spec.SHA2.Vec.fst.checked",
"Hacl.Spec.SHA2.Equiv.fst.checked",
"Hacl.SHA2.Scalar32.fst.checked",
"Hacl.Impl.SHA2.Generic.fst.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.SHA2.fst"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.range",
"Lib.IntTypes.U32",
"LowStar.Monotonic.Buffer.length",
"LowStar.Buffer.trivial_preorder",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Hacl.Hash.Definitions.hash_t",
"Spec.Hash.Definitions.SHA2_512",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Hash.Definitions.hash_len",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.MultiBuffer.op_Lens_Access",
"FStar.Seq.Properties.lseq",
"Hacl.Spec.SHA2.Vec.lanes",
"Hacl.Spec.SHA2.Vec.M32",
"Lib.MultiBuffer.as_seq_multi",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Hacl.Spec.SHA2.Equiv.hash_agile_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.SHA2.Generic.hash",
"Hacl.SHA2.Scalar32.sha512_init",
"Hacl.SHA2.Scalar32.sha512_update_nblocks",
"Hacl.SHA2.Scalar32.sha512_update_last",
"Hacl.SHA2.Scalar32.sha512_finish",
"Lib.MultiBuffer.loc_multi1",
"Lib.NTuple.ntuple",
"Lib.Buffer.lbuffer_t",
"Lib.NTuple.ntup1",
"Lib.Buffer.lbuffer"
] | [] | module Hacl.Streaming.SHA2
// NOTE: if you get errors trying to load this file in interactive mode because
// a tactic fails in Hacl.Streaming.MD (even though Hacl.Streaming.MD works
// totally fine in interactive mode!!), run:
// NODEPEND=1 make -j obj/Hacl.Streaming.MD.fst.checked
open FStar.HyperStack.ST
/// A streaming version of MD-based hashes
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module G = FStar.Ghost
module F = Hacl.Streaming.Functor
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Streaming.MD
/// Instantiations of the streaming functor for specialized SHA2 algorithms.
///
/// Some remarks:
///
/// - we don't bother with using the abstraction feature since we verified
/// clients like miTLS go through EverCrypt.Hash.Incremental
inline_for_extraction noextract
let hacl_sha2_224 = hacl_md SHA2_224
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
inline_for_extraction noextract
let hacl_sha2_384 = hacl_md SHA2_384
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512
inline_for_extraction noextract
let state_t_224 = state_t SHA2_224
inline_for_extraction noextract
let state_t_256 = state_t SHA2_256
inline_for_extraction noextract
let state_t_384 = state_t SHA2_384
inline_for_extraction noextract
let state_t_512 = state_t SHA2_512
/// Type abbreviations - for pretty code generation
let state_sha2_224 = Hacl.Streaming.MD.state_32
let state_sha2_256 = Hacl.Streaming.MD.state_32
let state_sha2_384 = Hacl.Streaming.MD.state_64
let state_sha2_512 = Hacl.Streaming.MD.state_64
open Lib.Buffer
open Lib.IntTypes
open Lib.NTuple
open Lib.MultiBuffer
open Hacl.Spec.SHA2.Vec
open Hacl.SHA2.Scalar32
open Hacl.Impl.SHA2.Generic
module ST = FStar.HyperStack.ST
// SHA2-256
// --------
inline_for_extraction noextract
let alloca_256 = F.alloca hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Allocate initial state for the SHA2_256 hash. The state is to be freed by
calling `free_256`."]
let create_in_256 = F.create_in hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_256`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_256 = F.copy hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Reset an existing state to the initial hash state with empty data."]
let init_256 = F.init hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ CInline ]
private
let update_224_256 = F.update hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_256`
(since the last call to `init_256`) exceeds 2^61-1 bytes.
This function is identical to the update function for SHA2_224.";
]
let update_256: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 32 bytes. The state remains
valid after a call to `finish_256`, meaning the user may feed more data into
the hash via `update_256`. (The finish_256 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_256 = F.mk_finish hacl_sha2_256 () (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_256`.
This function is identical to the free function for SHA2_224."]
let free_256 = F.free hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 32 bytes."]
val hash_256: Hacl.Hash.Definitions.hash_st SHA2_256
let hash_256 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_256) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_256 #M32 sha256_init sha256_update_nblocks sha256_update_last sha256_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_256 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-224
// --------
inline_for_extraction noextract
let alloca_224 = F.alloca hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let create_in_224 = F.create_in hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let init_224 = F.init hacl_sha2_224 (G.hide ()) (state_t_224.s ()) (G.erased unit)
// We assume verified clients will rely on Spec.SHA2.Lemmas to prove that update_224 has the same effect as update_256.
let update_224: F.update_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p input input_len -> update_224_256 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 28 bytes. The state remains
valid after a call to `finish_224`, meaning the user may feed more data into
the hash via `update_224`."]
let finish_224 = F.mk_finish hacl_sha2_224 () (state_t_224.s ()) (G.erased unit)
let free_224: F.free_st hacl_sha2_256 (G.hide ()) (state_t_256.s ()) (G.erased unit) = fun p -> free_256 p
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 28 bytes."]
val hash_224: Hacl.Hash.Definitions.hash_st SHA2_224
let hash_224 input input_len dst =
[@inline_let]
let dst: lbuffer uint8 (Hacl.Hash.Definitions.hash_len SHA2_224) = dst in
let ib = ntup1 input in
let rb = ntup1 dst in
let h0 = ST.get() in
loc_multi1 rb;
hash #SHA2_224 #M32 sha224_init sha224_update_nblocks sha224_update_last sha224_finish rb input_len ib;
let h1 = ST.get() in
Hacl.Spec.SHA2.Equiv.hash_agile_lemma #SHA2_224 #M32 (v input_len) (as_seq_multi h0 ib);
assert ((as_seq_multi h1 rb).(|0|) == as_seq h1 dst)
// SHA2-512
// --------
inline_for_extraction noextract
let alloca_512 = F.alloca hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let create_in_512 = F.create_in hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Copies the state passed as argument into a newly allocated state (deep copy).
The state is to be freed by calling `free_512`. Cloning the state this way is
useful, for instance, if your control-flow diverges and you need to feed
more (different) data into the hash in each branch."]
let copy_512 = F.copy hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
let init_512 = F.init hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ CInline ]
private
let update_384_512 = F.update hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Feed an arbitrary amount of data into the hash. This function returns 0 for
success, or 1 if the combined length of all of the data passed to `update_512`
(since the last call to `init_512`) exceeds 2^125-1 bytes.
This function is identical to the update function for SHA2_384.";
]
let update_512: F.update_st hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit) = fun p input input_len -> update_384_512 p input input_len
[@@ Comment
"Write the resulting hash into `dst`, an array of 64 bytes. The state remains
valid after a call to `finish_512`, meaning the user may feed more data into
the hash via `update_512`. (The finish_512 function operates on an internal copy of
the state and therefore does not invalidate the client-held state `p`.)"]
let finish_512 = F.mk_finish hacl_sha2_512 () (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Free a state allocated with `create_in_512`.
This function is identical to the free function for SHA2_384.";
]
let free_512 = F.free hacl_sha2_512 (G.hide ()) (state_t_512.s ()) (G.erased unit)
[@@ Comment
"Hash `input`, of len `input_len`, into `dst`, an array of 64 bytes."]
val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 | false | true | Hacl.Streaming.SHA2.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hash_512: Hacl.Hash.Definitions.hash_st SHA2_512 | [] | Hacl.Streaming.SHA2.hash_512 | {
"file_name": "code/streaming/Hacl.Streaming.SHA2.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Hash.Definitions.hash_st Spec.Hash.Definitions.SHA2_512 | {
"end_col": 54,
"end_line": 211,
"start_col": 2,
"start_line": 202
} |
Prims.Tot | val to_poly (p: poly{poly == D.poly}) : D.poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let to_poly (p:poly{poly == D.poly}) : D.poly = coerce D.poly p | val to_poly (p: poly{poly == D.poly}) : D.poly
let to_poly (p: poly{poly == D.poly}) : D.poly = | false | null | false | coerce D.poly p | {
"checked_file": "Vale.Math.Poly2_s.fsti.checked",
"dependencies": [
"Vale.Math.Poly2.Defs_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Math.Poly2_s.fsti"
} | [
"total"
] | [
"Vale.Math.Poly2_s.poly",
"Prims.eq2",
"Vale.Math.Poly2.Defs_s.poly",
"Vale.Math.Poly2_s.coerce"
] | [] | module Vale.Math.Poly2_s
module D = Vale.Math.Poly2.Defs_s
open FStar.Mul
open FStar.Seq
// Polynomials cn * x^n + ... + c0 * x^0
// where coefficients ck are treated mod 2
// Each coefficient is 0 (false) or 1 (true)
val poly : eqtype
val degree (p:poly) : int // note: degree zero == -1
val zero : poly
val one : poly
val monomial (n:nat) : poly // x^n
val shift (p:poly) (n:int) : poly // x^n * p
val reverse (p:poly) (n:nat) : poly // x^n <--> x^0, x^(n-1) <--> x^1, ...
// Index any coefficient, where all coefficients beyond highest-order term are zero
// (and n < 0 returns zero).
// p.[0] is the coefficient of the lowest-order term (x^0).
val poly_index (p:poly) (n:int) : bool
unfold let ( .[] ) = poly_index
val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
)
val add (a b:poly) : poly
val mul (a b:poly) : poly
val div (a b:poly) : poly
val mod (a b:poly) : poly | false | false | Vale.Math.Poly2_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_poly (p: poly{poly == D.poly}) : D.poly | [] | Vale.Math.Poly2_s.to_poly | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2_s.poly{Vale.Math.Poly2_s.poly == Vale.Math.Poly2.Defs_s.poly}
-> Vale.Math.Poly2.Defs_s.poly | {
"end_col": 70,
"end_line": 52,
"start_col": 55,
"start_line": 52
} |
Prims.Tot | val of_poly (p: D.poly{poly == D.poly}) : poly | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let of_poly (p:D.poly{poly == D.poly}) : poly = coerce poly p | val of_poly (p: D.poly{poly == D.poly}) : poly
let of_poly (p: D.poly{poly == D.poly}) : poly = | false | null | false | coerce poly p | {
"checked_file": "Vale.Math.Poly2_s.fsti.checked",
"dependencies": [
"Vale.Math.Poly2.Defs_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Math.Poly2_s.fsti"
} | [
"total"
] | [
"Vale.Math.Poly2.Defs_s.poly",
"Prims.eq2",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2_s.coerce"
] | [] | module Vale.Math.Poly2_s
module D = Vale.Math.Poly2.Defs_s
open FStar.Mul
open FStar.Seq
// Polynomials cn * x^n + ... + c0 * x^0
// where coefficients ck are treated mod 2
// Each coefficient is 0 (false) or 1 (true)
val poly : eqtype
val degree (p:poly) : int // note: degree zero == -1
val zero : poly
val one : poly
val monomial (n:nat) : poly // x^n
val shift (p:poly) (n:int) : poly // x^n * p
val reverse (p:poly) (n:nat) : poly // x^n <--> x^0, x^(n-1) <--> x^1, ...
// Index any coefficient, where all coefficients beyond highest-order term are zero
// (and n < 0 returns zero).
// p.[0] is the coefficient of the lowest-order term (x^0).
val poly_index (p:poly) (n:int) : bool
unfold let ( .[] ) = poly_index
val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
)
val add (a b:poly) : poly
val mul (a b:poly) : poly
val div (a b:poly) : poly
val mod (a b:poly) : poly
unfold let coerce (#a:Type0) (b:Type0) (x:a{a == b}) : b = x | false | false | Vale.Math.Poly2_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val of_poly (p: D.poly{poly == D.poly}) : poly | [] | Vale.Math.Poly2_s.of_poly | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Vale.Math.Poly2.Defs_s.poly{Vale.Math.Poly2_s.poly == Vale.Math.Poly2.Defs_s.poly}
-> Vale.Math.Poly2_s.poly | {
"end_col": 68,
"end_line": 53,
"start_col": 55,
"start_line": 53
} |
Prims.Tot | val coerce (#a b: Type0) (x: a{a == b}) : b | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Math.Poly2.Defs_s",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let coerce (#a:Type0) (b:Type0) (x:a{a == b}) : b = x | val coerce (#a b: Type0) (x: a{a == b}) : b
let coerce (#a b: Type0) (x: a{a == b}) : b = | false | null | false | x | {
"checked_file": "Vale.Math.Poly2_s.fsti.checked",
"dependencies": [
"Vale.Math.Poly2.Defs_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Math.Poly2_s.fsti"
} | [
"total"
] | [
"Prims.eq2"
] | [] | module Vale.Math.Poly2_s
module D = Vale.Math.Poly2.Defs_s
open FStar.Mul
open FStar.Seq
// Polynomials cn * x^n + ... + c0 * x^0
// where coefficients ck are treated mod 2
// Each coefficient is 0 (false) or 1 (true)
val poly : eqtype
val degree (p:poly) : int // note: degree zero == -1
val zero : poly
val one : poly
val monomial (n:nat) : poly // x^n
val shift (p:poly) (n:int) : poly // x^n * p
val reverse (p:poly) (n:nat) : poly // x^n <--> x^0, x^(n-1) <--> x^1, ...
// Index any coefficient, where all coefficients beyond highest-order term are zero
// (and n < 0 returns zero).
// p.[0] is the coefficient of the lowest-order term (x^0).
val poly_index (p:poly) (n:int) : bool
unfold let ( .[] ) = poly_index
val to_seq (p:poly) (n:nat) : Pure (seq bool)
(requires True)
(ensures fun s ->
length s == n /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_seq (s:seq bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < length s /\
(forall (i:nat).{:pattern (p.[i]) \/ (index s i)} i < length s ==> p.[i] == index s i)
)
val of_fun (len:nat) (f:nat -> bool) : Pure poly
(requires True)
(ensures fun p ->
degree p < len /\
(forall (i:nat).{:pattern p.[i] \/ (f i)} i < len ==> p.[i] == f i) /\
(forall (i:int).{:pattern p.[i]} p.[i] ==> 0 <= i /\ i < len)
)
val add (a b:poly) : poly
val mul (a b:poly) : poly
val div (a b:poly) : poly
val mod (a b:poly) : poly | false | false | Vale.Math.Poly2_s.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val coerce (#a b: Type0) (x: a{a == b}) : b | [] | Vale.Math.Poly2_s.coerce | {
"file_name": "vale/specs/math/Vale.Math.Poly2_s.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Type0 -> x: a{a == b} -> b | {
"end_col": 60,
"end_line": 51,
"start_col": 59,
"start_line": 51
} |
Prims.GTot | val loc_region_only (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_region_only
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (Set.singleton r) | val loc_region_only (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c)
let loc_region_only (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) = | false | null | false | loc_regions preserve_liveness (Set.singleton r) | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"sometrivial"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"Prims.bool",
"FStar.Monotonic.HyperHeap.rid",
"FStar.ModifiesGen.loc_regions",
"FStar.Set.singleton",
"FStar.ModifiesGen.loc"
] | [] | (*
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.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_region_only
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_region_only (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) | [] | FStar.ModifiesGen.loc_region_only | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | preserve_liveness: Prims.bool -> r: FStar.Monotonic.HyperHeap.rid
-> Prims.GTot (FStar.ModifiesGen.loc c) | {
"end_col": 49,
"end_line": 217,
"start_col": 2,
"start_line": 217
} |
FStar.Pervasives.Lemma | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_disjoint_addresses #aloc #c = loc_disjoint_addresses_intro #aloc #c | let loc_disjoint_addresses #aloc #c = | false | null | true | loc_disjoint_addresses_intro #aloc #c | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"lemma"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"FStar.ModifiesGen.loc_disjoint_addresses_intro",
"Prims.bool",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Set.set",
"Prims.nat",
"Prims.unit",
"Prims.l_or",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Set.subset",
"FStar.Set.intersect",
"FStar.Set.empty",
"Prims.squash",
"FStar.ModifiesGen.loc_disjoint",
"FStar.ModifiesGen.loc_addresses",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_region_only
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (Set.singleton r)
let loc_all_regions_from
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
(* Inclusion of memory locations *)
val loc_includes
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot Type0
val loc_includes_refl
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_includes s s)
val loc_includes_trans
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
val loc_includes_union_r
(#aloc: aloc_t) (#c: cls aloc)
(s s1 s2: loc c)
: Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
val loc_includes_union_l
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s: loc c)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
val loc_includes_none
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_includes s loc_none)
val loc_includes_none_elim
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(requires (loc_includes loc_none s))
(ensures (s == loc_none))
val loc_includes_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b1 b2: aloc r n)
: Lemma
(requires (c.aloc_includes b1 b2))
(ensures (loc_includes (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
val loc_includes_aloc_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r1 #r2: HS.rid)
(#n1 #n2: nat)
(b1: aloc r1 n1)
(b2: aloc r2 n2)
: Lemma
(requires (loc_includes (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
(ensures (r1 == r2 /\ n1 == n2 /\ c.aloc_includes b1 b2))
val loc_includes_addresses_aloc
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(s: Set.set nat)
(#a: nat)
(p: aloc r a)
: Lemma
(requires (Set.mem a s))
(ensures (loc_includes (loc_addresses preserve_liveness r s) (loc_of_aloc #_ #c p)))
val loc_includes_region_aloc
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(s: Set.set HS.rid)
(#r: HS.rid)
(#a: nat)
(b: aloc r a)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions preserve_liveness s) (loc_of_aloc #_ #c b)))
val loc_includes_region_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(s: Set.set HS.rid)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions #_ #c preserve_liveness1 s) (loc_addresses preserve_liveness2 r a)))
val loc_includes_region_region
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(s1 s2: Set.set HS.rid)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_regions #_ #c preserve_liveness1 s1) (loc_regions preserve_liveness2 s2)))
val loc_includes_region_union_l
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(l: loc c)
(s1 s2: Set.set HS.rid)
: Lemma
(requires (loc_includes l (loc_regions preserve_liveness (Set.intersect s2 (Set.complement s1)))))
(ensures (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2)))
val loc_includes_addresses_addresses
(#aloc: aloc_t) (c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(r: HS.rid)
(a1 a2: Set.set nat)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset a2 a1))
(ensures (loc_includes #_ #c (loc_addresses preserve_liveness1 r a1) (loc_addresses preserve_liveness2 r a2)))
(* Disjointness of two memory locations *)
val loc_disjoint
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot Type0
val loc_disjoint_sym
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(requires (loc_disjoint s1 s2))
(ensures (loc_disjoint s2 s1))
val loc_disjoint_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(ensures (loc_disjoint s loc_none))
val loc_disjoint_union_r
(#aloc: aloc_t) (#c: cls aloc)
(s s1 s2: loc c)
: Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
val loc_disjoint_includes
(#aloc: aloc_t) (#c: cls aloc)
(p1 p2 p1' p2' : loc c)
: Lemma
(requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2))
(ensures (loc_disjoint p1' p2'))
val loc_disjoint_aloc_intro
(#aloc: aloc_t) (#c: cls aloc)
(#r1: HS.rid)
(#a1: nat)
(#r2: HS.rid)
(#a2: nat)
(b1: aloc r1 a1)
(b2: aloc r2 a2)
: Lemma
(requires ((r1 == r2 /\ a1 == a2) ==> c.aloc_disjoint b1 b2))
(ensures (loc_disjoint (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
val loc_disjoint_aloc_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r1: HS.rid)
(#a1: nat)
(#r2: HS.rid)
(#a2: nat)
(b1: aloc r1 a1)
(b2: aloc r2 a2)
: Lemma
(requires (loc_disjoint (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
(ensures ((r1 == r2 /\ a1 == a2) ==> c.aloc_disjoint b1 b2))
val loc_disjoint_addresses_intro
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(n1 n2: Set.set nat)
: Lemma
(requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty))
(ensures (loc_disjoint (loc_addresses #_ #c preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2))) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_disjoint_addresses : preserve_liveness1: Prims.bool ->
preserve_liveness2: Prims.bool ->
r1: FStar.Monotonic.HyperHeap.rid ->
r2: FStar.Monotonic.HyperHeap.rid ->
n1: FStar.Set.set Prims.nat ->
n2: FStar.Set.set Prims.nat
-> FStar.Pervasives.Lemma
(requires r1 <> r2 \/ FStar.Set.subset (FStar.Set.intersect n1 n2) FStar.Set.empty)
(ensures
FStar.ModifiesGen.loc_disjoint (FStar.ModifiesGen.loc_addresses preserve_liveness1 r1 n1)
(FStar.ModifiesGen.loc_addresses preserve_liveness2 r2 n2)) | [] | FStar.ModifiesGen.loc_disjoint_addresses | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
preserve_liveness1: Prims.bool ->
preserve_liveness2: Prims.bool ->
r1: FStar.Monotonic.HyperHeap.rid ->
r2: FStar.Monotonic.HyperHeap.rid ->
n1: FStar.Set.set Prims.nat ->
n2: FStar.Set.set Prims.nat
-> FStar.Pervasives.Lemma
(requires r1 <> r2 \/ FStar.Set.subset (FStar.Set.intersect n1 n2) FStar.Set.empty)
(ensures
FStar.ModifiesGen.loc_disjoint (FStar.ModifiesGen.loc_addresses preserve_liveness1 r1 n1)
(FStar.ModifiesGen.loc_addresses preserve_liveness2 r2 n2)) | {
"end_col": 75,
"end_line": 420,
"start_col": 38,
"start_line": 420
} |
|
Prims.GTot | val loc_all_regions_from (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_all_regions_from
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r)) | val loc_all_regions_from (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c)
let loc_all_regions_from (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) = | false | null | false | loc_regions preserve_liveness (HS.mod_set (Set.singleton r)) | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"sometrivial"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"Prims.bool",
"FStar.Monotonic.HyperHeap.rid",
"FStar.ModifiesGen.loc_regions",
"FStar.Monotonic.HyperHeap.mod_set",
"FStar.Set.singleton",
"FStar.ModifiesGen.loc"
] | [] | (*
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.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_region_only
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (Set.singleton r)
let loc_all_regions_from
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_all_regions_from (#aloc: aloc_t) (#c: cls aloc) (preserve_liveness: bool) (r: HS.rid)
: GTot (loc c) | [] | FStar.ModifiesGen.loc_all_regions_from | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | preserve_liveness: Prims.bool -> r: FStar.Monotonic.HyperHeap.rid
-> Prims.GTot (FStar.ModifiesGen.loc c) | {
"end_col": 62,
"end_line": 224,
"start_col": 2,
"start_line": 224
} |
Prims.GTot | val loc_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b)) | val loc_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) = | false | null | false | loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b)) | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"sometrivial"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.ModifiesGen.loc_addresses",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Set.singleton",
"Prims.nat",
"FStar.Monotonic.HyperStack.as_addr",
"FStar.ModifiesGen.loc"
] | [] | (*
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.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) | [] | FStar.ModifiesGen.loc_mreference | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Monotonic.HyperStack.mreference a p -> Prims.GTot (FStar.ModifiesGen.loc c) | {
"end_col": 66,
"end_line": 202,
"start_col": 2,
"start_line": 202
} |
Prims.GTot | val loc_freed_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b)) | val loc_freed_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
let loc_freed_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) = | false | null | false | loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b)) | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"sometrivial"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"FStar.Preorder.preorder",
"FStar.Monotonic.HyperStack.mreference",
"FStar.ModifiesGen.loc_addresses",
"FStar.Monotonic.HyperStack.frameOf",
"FStar.Set.singleton",
"Prims.nat",
"FStar.Monotonic.HyperStack.as_addr",
"FStar.ModifiesGen.loc"
] | [] | (*
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.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val loc_freed_mreference
(#aloc: aloc_t)
(#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c) | [] | FStar.ModifiesGen.loc_freed_mreference | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.Monotonic.HyperStack.mreference a p -> Prims.GTot (FStar.ModifiesGen.loc c) | {
"end_col": 67,
"end_line": 210,
"start_col": 2,
"start_line": 210
} |
FStar.Pervasives.Lemma | val modifies_only_live_addresses
(#aloc: aloc_t)
(#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h': HS.mem)
: Lemma
(requires
(modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x. Set.mem x a ==> h `does_not_contain_addr` (r, x)))) (ensures (modifies l h h')) | [
{
"abbrev": true,
"full_module": "FStar.FunctionalExtensionality",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_only_live_addresses
(#aloc: aloc_t) (#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x))
))
(ensures (modifies l h h'))
= loc_addresses_unused_in c r a h;
loc_includes_refl l;
loc_includes_union_l (loc_unused_in c h) l l;
loc_includes_union_l (loc_unused_in c h) l (loc_addresses false r a);
loc_includes_union_r (loc_union (loc_unused_in c h) l) (loc_addresses false r a) l;
modifies_loc_includes (loc_union (loc_unused_in c h) l) h h' (loc_union (loc_addresses false r a) l);
modifies_only_not_unused_in l h h' | val modifies_only_live_addresses
(#aloc: aloc_t)
(#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h': HS.mem)
: Lemma
(requires
(modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x. Set.mem x a ==> h `does_not_contain_addr` (r, x)))) (ensures (modifies l h h'))
let modifies_only_live_addresses
(#aloc: aloc_t)
(#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h': HS.mem)
: Lemma
(requires
(modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x. Set.mem x a ==> h `does_not_contain_addr` (r, x)))) (ensures (modifies l h h')) = | false | null | true | loc_addresses_unused_in c r a h;
loc_includes_refl l;
loc_includes_union_l (loc_unused_in c h) l l;
loc_includes_union_l (loc_unused_in c h) l (loc_addresses false r a);
loc_includes_union_r (loc_union (loc_unused_in c h) l) (loc_addresses false r a) l;
modifies_loc_includes (loc_union (loc_unused_in c h) l) h h' (loc_union (loc_addresses false r a) l);
modifies_only_not_unused_in l h h' | {
"checked_file": "FStar.ModifiesGen.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Map.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked"
],
"interface_file": false,
"source_file": "FStar.ModifiesGen.fsti"
} | [
"lemma"
] | [
"FStar.ModifiesGen.aloc_t",
"FStar.ModifiesGen.cls",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Set.set",
"Prims.nat",
"FStar.ModifiesGen.loc",
"FStar.Monotonic.HyperStack.mem",
"FStar.ModifiesGen.modifies_only_not_unused_in",
"Prims.unit",
"FStar.ModifiesGen.modifies_loc_includes",
"FStar.ModifiesGen.loc_union",
"FStar.ModifiesGen.loc_unused_in",
"FStar.ModifiesGen.loc_addresses",
"FStar.ModifiesGen.loc_includes_union_r",
"FStar.ModifiesGen.loc_includes_union_l",
"FStar.ModifiesGen.loc_includes_refl",
"FStar.ModifiesGen.loc_addresses_unused_in",
"Prims.l_and",
"FStar.ModifiesGen.modifies",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"FStar.Set.mem",
"FStar.ModifiesGen.does_not_contain_addr",
"FStar.Pervasives.Native.Mktuple2",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.ModifiesGen
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
(*** The modifies clause *)
(* NOTE: aloc cannot be a member of the class, because of OCaml
extraction. So it must be a parameter of the class instead. *)
type aloc_t = HS.rid -> nat -> Tot Type
noeq
type cls (aloc: aloc_t) : Type = | Cls:
(aloc_includes: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
aloc r a ->
GTot Type0
)) ->
(aloc_includes_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
Lemma
(aloc_includes x x)
)) ->
(aloc_includes_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
(x3: aloc r a) ->
Lemma
(requires (aloc_includes x1 x2 /\ aloc_includes x2 x3))
(ensures (aloc_includes x1 x3))
)) ->
(aloc_disjoint: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
GTot Type0
)) ->
(aloc_disjoint_sym: (
(#r: HS.rid) ->
(#a: nat) ->
(x1: aloc r a) ->
(x2: aloc r a) ->
Lemma
(aloc_disjoint x1 x2 <==> aloc_disjoint x2 x1)
)) ->
(aloc_disjoint_includes: (
(#r: HS.rid) ->
(#a: nat) ->
(larger1: aloc r a) ->
(larger2: aloc r a) ->
(smaller1: aloc r a) ->
(smaller2: aloc r a) ->
Lemma
(requires (aloc_disjoint larger1 larger2 /\ larger1 `aloc_includes` smaller1 /\ larger2 `aloc_includes` smaller2))
(ensures (aloc_disjoint smaller1 smaller2))
)) ->
(aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
aloc r a ->
HS.mem ->
HS.mem ->
GTot Type0
)) ->
(aloc_preserved_refl: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h: HS.mem) ->
Lemma
(aloc_preserved x h h)
)) ->
(aloc_preserved_trans: (
(#r: HS.rid) ->
(#a: nat) ->
(x: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(h3: HS.mem) ->
Lemma
(requires (aloc_preserved x h1 h2 /\ aloc_preserved x h2 h3))
(ensures (aloc_preserved x h1 h3))
)) ->
(* if any reference at this address is preserved, then any location at this address is preserved *)
(same_mreference_aloc_preserved: (
(#r: HS.rid) ->
(#a: nat) ->
(b: aloc r a) ->
(h1: HS.mem) ->
(h2: HS.mem) ->
(f: (
(a' : Type0) ->
(pre: Preorder.preorder a') ->
(r': HS.mreference a' pre) ->
Lemma
(requires (h1 `HS.contains` r' /\ r == HS.frameOf r' /\ a == HS.as_addr r'))
(ensures (h2 `HS.contains` r' /\ h1 `HS.sel` r' == h2 `HS.sel` r'))
)) ->
Lemma
(aloc_preserved b h1 h2)
)) ->
cls aloc
val loc (#aloc: aloc_t u#x) (c: cls aloc) : Tot (Type u#x)
val loc_none (#aloc: aloc_t) (#c: cls aloc): Tot (loc c)
val loc_union
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot (loc c)
(** The following is useful to make Z3 cut matching loops with
modifies_trans and modifies_refl *)
val loc_union_idem
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s s == s)
val loc_union_comm
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(loc_union s1 s2 == loc_union s2 s1)
val loc_union_assoc
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(loc_union s1 (loc_union s2 s3) == loc_union (loc_union s1 s2) s3)
val loc_union_loc_none_l
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union loc_none s == s)
val loc_union_loc_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_union s loc_none == s)
val loc_of_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: GTot (loc c)
val loc_of_aloc_not_none
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b: aloc r n)
: Lemma (loc_of_aloc #_ #c b == loc_none ==> False)
val loc_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: GTot (loc c)
val loc_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: Set.set HS.rid)
: GTot (loc c)
let loc_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses true (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_freed_mreference
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#p: Preorder.preorder a)
(b: HS.mreference a p)
: GTot (loc c)
= loc_addresses false (HS.frameOf b) (Set.singleton (HS.as_addr b))
let loc_region_only
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (Set.singleton r)
let loc_all_regions_from
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
: GTot (loc c)
= loc_regions preserve_liveness (HS.mod_set (Set.singleton r))
(* Inclusion of memory locations *)
val loc_includes
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot Type0
val loc_includes_refl
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_includes s s)
val loc_includes_trans
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s3: loc c)
: Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
val loc_includes_union_r
(#aloc: aloc_t) (#c: cls aloc)
(s s1 s2: loc c)
: Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
val loc_includes_union_l
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2 s: loc c)
: Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
val loc_includes_none
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(loc_includes s loc_none)
val loc_includes_none_elim
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(requires (loc_includes loc_none s))
(ensures (s == loc_none))
val loc_includes_aloc
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#n: nat)
(b1 b2: aloc r n)
: Lemma
(requires (c.aloc_includes b1 b2))
(ensures (loc_includes (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
val loc_includes_aloc_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r1 #r2: HS.rid)
(#n1 #n2: nat)
(b1: aloc r1 n1)
(b2: aloc r2 n2)
: Lemma
(requires (loc_includes (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
(ensures (r1 == r2 /\ n1 == n2 /\ c.aloc_includes b1 b2))
val loc_includes_addresses_aloc
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(r: HS.rid)
(s: Set.set nat)
(#a: nat)
(p: aloc r a)
: Lemma
(requires (Set.mem a s))
(ensures (loc_includes (loc_addresses preserve_liveness r s) (loc_of_aloc #_ #c p)))
val loc_includes_region_aloc
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(s: Set.set HS.rid)
(#r: HS.rid)
(#a: nat)
(b: aloc r a)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions preserve_liveness s) (loc_of_aloc #_ #c b)))
val loc_includes_region_addresses
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(s: Set.set HS.rid)
(r: HS.rid)
(a: Set.set nat)
: Lemma
(requires (Set.mem r s))
(ensures (loc_includes (loc_regions #_ #c preserve_liveness1 s) (loc_addresses preserve_liveness2 r a)))
val loc_includes_region_region
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(s1 s2: Set.set HS.rid)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset s2 s1))
(ensures (loc_includes (loc_regions #_ #c preserve_liveness1 s1) (loc_regions preserve_liveness2 s2)))
val loc_includes_region_union_l
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness: bool)
(l: loc c)
(s1 s2: Set.set HS.rid)
: Lemma
(requires (loc_includes l (loc_regions preserve_liveness (Set.intersect s2 (Set.complement s1)))))
(ensures (loc_includes (loc_union (loc_regions preserve_liveness s1) l) (loc_regions preserve_liveness s2)))
val loc_includes_addresses_addresses
(#aloc: aloc_t) (c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(r: HS.rid)
(a1 a2: Set.set nat)
: Lemma
(requires ((preserve_liveness1 ==> preserve_liveness2) /\ Set.subset a2 a1))
(ensures (loc_includes #_ #c (loc_addresses preserve_liveness1 r a1) (loc_addresses preserve_liveness2 r a2)))
(* Disjointness of two memory locations *)
val loc_disjoint
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: GTot Type0
val loc_disjoint_sym
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
: Lemma
(requires (loc_disjoint s1 s2))
(ensures (loc_disjoint s2 s1))
val loc_disjoint_none_r
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
: Lemma
(ensures (loc_disjoint s loc_none))
val loc_disjoint_union_r
(#aloc: aloc_t) (#c: cls aloc)
(s s1 s2: loc c)
: Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
val loc_disjoint_includes
(#aloc: aloc_t) (#c: cls aloc)
(p1 p2 p1' p2' : loc c)
: Lemma
(requires (loc_includes p1 p1' /\ loc_includes p2 p2' /\ loc_disjoint p1 p2))
(ensures (loc_disjoint p1' p2'))
val loc_disjoint_aloc_intro
(#aloc: aloc_t) (#c: cls aloc)
(#r1: HS.rid)
(#a1: nat)
(#r2: HS.rid)
(#a2: nat)
(b1: aloc r1 a1)
(b2: aloc r2 a2)
: Lemma
(requires ((r1 == r2 /\ a1 == a2) ==> c.aloc_disjoint b1 b2))
(ensures (loc_disjoint (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
val loc_disjoint_aloc_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r1: HS.rid)
(#a1: nat)
(#r2: HS.rid)
(#a2: nat)
(b1: aloc r1 a1)
(b2: aloc r2 a2)
: Lemma
(requires (loc_disjoint (loc_of_aloc b1) (loc_of_aloc #_ #c b2)))
(ensures ((r1 == r2 /\ a1 == a2) ==> c.aloc_disjoint b1 b2))
val loc_disjoint_addresses_intro
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(n1 n2: Set.set nat)
: Lemma
(requires (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty))
(ensures (loc_disjoint (loc_addresses #_ #c preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2)))
let loc_disjoint_addresses #aloc #c = loc_disjoint_addresses_intro #aloc #c
val loc_disjoint_addresses_elim
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(r1 r2: HS.rid)
(n1 n2: Set.set nat)
: Lemma
(requires (loc_disjoint (loc_addresses #_ #c preserve_liveness1 r1 n1) (loc_addresses preserve_liveness2 r2 n2)))
(ensures (r1 <> r2 \/ Set.subset (Set.intersect n1 n2) Set.empty))
val loc_disjoint_aloc_addresses_intro
(#aloc: aloc_t) (#c: cls aloc)
(#r' : HS.rid)
(#a' : nat)
(p: aloc r' a')
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: Lemma
(requires (r == r' ==> (~ (Set.mem a' n))))
(ensures (loc_disjoint (loc_of_aloc p) (loc_addresses #_ #c preserve_liveness r n)))
val loc_disjoint_aloc_addresses_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r' : HS.rid)
(#a' : nat)
(p: aloc r' a')
(preserve_liveness: bool)
(r: HS.rid)
(n: Set.set nat)
: Lemma
(requires (loc_disjoint (loc_of_aloc p) (loc_addresses #_ #c preserve_liveness r n)))
(ensures (r == r' ==> (~ (Set.mem a' n))))
val loc_disjoint_regions
(#aloc: aloc_t) (#c: cls aloc)
(preserve_liveness1 preserve_liveness2: bool)
(rs1 rs2: Set.set HS.rid)
: Lemma
(requires (Set.subset (Set.intersect rs1 rs2) Set.empty))
(ensures (loc_disjoint (loc_regions #_ #c preserve_liveness1 rs1) (loc_regions preserve_liveness2 rs2)))
(** Liveness-insensitive memory locations *)
val address_liveness_insensitive_locs (#aloc: aloc_t) (c: cls aloc) : Tot (loc c)
val loc_includes_address_liveness_insensitive_locs_aloc (#aloc: aloc_t) (#c: cls aloc) (#r: HS.rid) (#n: nat) (a: aloc r n) : Lemma
(loc_includes (address_liveness_insensitive_locs c) (loc_of_aloc a))
val loc_includes_address_liveness_insensitive_locs_addresses (#aloc: aloc_t) (c: cls aloc) (r: HS.rid) (a: Set.set nat) : Lemma
(loc_includes (address_liveness_insensitive_locs c) (loc_addresses true r a))
val region_liveness_insensitive_locs (#al: aloc_t) (c: cls al) : Tot (loc c)
val loc_includes_region_liveness_insensitive_locs_address_liveness_insensitive_locs (#al: aloc_t) (c: cls al) : Lemma
(loc_includes (region_liveness_insensitive_locs c) (address_liveness_insensitive_locs c))
val loc_includes_region_liveness_insensitive_locs_loc_regions
(#al: aloc_t) (c: cls al) (r: Set.set HS.rid)
: Lemma
(region_liveness_insensitive_locs c `loc_includes` loc_regions #_ #c true r)
val loc_includes_region_liveness_insensitive_locs_loc_addresses
(#al: aloc_t) (c: cls al) (preserve_liveness: bool) (r: HS.rid) (a: Set.set nat)
: Lemma
(region_liveness_insensitive_locs c `loc_includes` loc_addresses #_ #c preserve_liveness r a)
val loc_includes_region_liveness_insensitive_locs_loc_of_aloc
(#al: aloc_t) (c: cls al) (#r: HS.rid) (#a: nat) (x: al r a)
: Lemma
(region_liveness_insensitive_locs c `loc_includes` loc_of_aloc #_ #c x)
(** The modifies clause proper *)
val modifies
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
(h1 h2: HS.mem)
: GTot Type0
val modifies_intro
(#al: aloc_t) (#c: cls al) (l: loc c) (h h' : HS.mem)
(regions: (
(r: HS.rid) ->
Lemma
(requires (HS.live_region h r))
(ensures (HS.live_region h' r))
))
(mrefs: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires ((loc_disjoint (loc_mreference b) l) /\ HS.contains h b))
(ensures (HS.contains h' b /\ HS.sel h' b == HS.sel h b))
))
(livenesses: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires (HS.contains h b))
(ensures (HS.contains h' b))
))
(addr_unused_in: (
(r: HS.rid) ->
(n: nat) ->
Lemma
(requires (
HS.live_region h r /\
HS.live_region h' r /\ n `Heap.addr_unused_in` (HS.get_hmap h' `Map.sel` r)
))
(ensures (n `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` r)))
))
(alocs: (
(r: HS.rid) ->
(a: nat) ->
(x: al r a) ->
Lemma
(requires (loc_disjoint (loc_of_aloc x) l))
(ensures (c.aloc_preserved x h h'))
))
: Lemma
(modifies l h h')
val modifies_none_intro
(#al: aloc_t) (#c: cls al) (h h' : HS.mem)
(regions: (
(r: HS.rid) ->
Lemma
(requires (HS.live_region h r))
(ensures (HS.live_region h' r))
))
(mrefs: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires (HS.contains h b))
(ensures (HS.contains h' b /\ HS.sel h' b == HS.sel h b))
))
(addr_unused_in: (
(r: HS.rid) ->
(n: nat) ->
Lemma
(requires (HS.live_region h r /\ HS.live_region h' r /\ n `Heap.addr_unused_in` (HS.get_hmap h' `Map.sel` r)))
(ensures (n `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` r)))
))
: Lemma
(modifies (loc_none #_ #c) h h')
val modifies_address_intro
(#al: aloc_t) (#c: cls al) (r: HS.rid) (n: nat) (h h' : HS.mem)
(regions: (
(r: HS.rid) ->
Lemma
(requires (HS.live_region h r))
(ensures (HS.live_region h' r))
))
(mrefs: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires ((r <> HS.frameOf b \/ n <> HS.as_addr b) /\ HS.contains h b))
(ensures (HS.contains h' b /\ HS.sel h' b == HS.sel h b))
))
(addr_unused_in: (
(r': HS.rid) ->
(n' : nat) ->
Lemma
(requires ((r' <> r \/ n' <> n) /\ HS.live_region h r' /\ HS.live_region h' r' /\ n' `Heap.addr_unused_in` (HS.get_hmap h' `Map.sel` r')))
(ensures (n' `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` r')))
))
: Lemma
(modifies (loc_addresses #_ #c false r (Set.singleton n)) h h')
val modifies_aloc_intro
(#al: aloc_t) (#c: cls al) (#r: HS.rid) (#n: nat) (z: al r n) (h h' : HS.mem)
(regions: (
(r: HS.rid) ->
Lemma
(requires (HS.live_region h r))
(ensures (HS.live_region h' r))
))
(mrefs: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires ((r <> HS.frameOf b \/ n <> HS.as_addr b) /\ HS.contains h b))
(ensures (HS.contains h' b /\ HS.sel h' b == HS.sel h b))
))
(livenesses: (
(t: Type0) ->
(pre: Preorder.preorder t) ->
(b: HS.mreference t pre) ->
Lemma
(requires (HS.contains h b))
(ensures (HS.contains h' b))
))
(addr_unused_in: (
(r: HS.rid) ->
(n: nat) ->
Lemma
(requires (HS.live_region h r /\ HS.live_region h' r /\ n `Heap.addr_unused_in` (HS.get_hmap h' `Map.sel` r)))
(ensures (n `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` r)))
))
(alocs: (
(x: al r n) ->
Lemma
(requires (c.aloc_disjoint x z))
(ensures (c.aloc_preserved x h h'))
))
: Lemma
(modifies (loc_of_aloc #_ #c z) h h')
val modifies_live_region
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
(h1 h2: HS.mem)
(r: HS.rid)
: Lemma
(requires (modifies s h1 h2 /\ loc_disjoint s (loc_region_only false r) /\ HS.live_region h1 r))
(ensures (HS.live_region h2 r))
val modifies_mreference_elim
(#aloc: aloc_t) (#c: cls aloc)
(#t: Type)
(#pre: Preorder.preorder t)
(b: HS.mreference t pre)
(p: loc c)
(h h': HS.mem)
: Lemma
(requires (
loc_disjoint (loc_mreference b) p /\
HS.contains h b /\
modifies p h h'
))
(ensures (
HS.contains h' b /\
HS.sel h b == HS.sel h' b
))
val modifies_aloc_elim
(#aloc: aloc_t) (#c: cls aloc)
(#r: HS.rid)
(#a: nat)
(b: aloc r a)
(p: loc c)
(h h': HS.mem)
: Lemma
(requires (
loc_disjoint (loc_of_aloc b) p /\
modifies p h h'
))
(ensures (
c.aloc_preserved b h h'
))
val modifies_refl
(#aloc: aloc_t) (#c: cls aloc)
(s: loc c)
(h: HS.mem)
: Lemma
(modifies s h h)
val modifies_loc_includes
(#aloc: aloc_t) (#c: cls aloc)
(s1: loc c)
(h h': HS.mem)
(s2: loc c)
: Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h'))
val modifies_preserves_liveness
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(r: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union s1 s2) h h' /\ loc_disjoint s1 (loc_mreference r) /\ loc_includes (address_liveness_insensitive_locs c) s2 /\ h `HS.contains` r))
(ensures (h' `HS.contains` r))
val modifies_preserves_liveness_strong
(#aloc: aloc_t) (#c: cls aloc)
(s1 s2: loc c)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(r: HS.mreference t pre)
(x: aloc (HS.frameOf r) (HS.as_addr r))
: Lemma
(requires (modifies (loc_union s1 s2) h h' /\ loc_disjoint s1 (loc_of_aloc #_ #c #(HS.frameOf r) #(HS.as_addr r) x) /\ loc_includes (address_liveness_insensitive_locs c) s2 /\ h `HS.contains` r))
(ensures (h' `HS.contains` r))
val modifies_preserves_region_liveness
(#al: aloc_t) (#c: cls al)
(l1 l2: loc c)
(h h' : HS.mem)
(r: HS.rid)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ region_liveness_insensitive_locs c `loc_includes` l2 /\ loc_disjoint (loc_region_only false r) l1 /\ HS.live_region h r))
(ensures (HS.live_region h' r))
val modifies_preserves_region_liveness_reference
(#al: aloc_t) (#c: cls al)
(l1 l2: loc c)
(h h' : HS.mem)
(#t: Type)
(#pre: Preorder.preorder t)
(r: HS.mreference t pre)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ region_liveness_insensitive_locs c `loc_includes` l2 /\ loc_disjoint (loc_mreference r) l1 /\ HS.live_region h (HS.frameOf r)))
(ensures (HS.live_region h' (HS.frameOf r)))
val modifies_preserves_region_liveness_aloc
(#al: aloc_t) (#c: cls al)
(l1 l2: loc c)
(h h' : HS.mem)
(#r: HS.rid)
(#n: nat)
(x: al r n)
: Lemma
(requires (modifies (loc_union l1 l2) h h' /\ region_liveness_insensitive_locs c `loc_includes` l2 /\ loc_disjoint (loc_of_aloc x) l1 /\ HS.live_region h r))
(ensures (HS.live_region h' r))
val modifies_trans
(#aloc: aloc_t) (#c: cls aloc)
(s12: loc c)
(h1 h2: HS.mem)
(s23: loc c)
(h3: HS.mem)
: Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3))
val modifies_only_live_regions
(#aloc: aloc_t) (#c: cls aloc)
(rs: Set.set HS.rid)
(l: loc c)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_regions false rs) l) h h' /\
(forall r . Set.mem r rs ==> (~ (HS.live_region h r)))
))
(ensures (modifies l h h'))
val no_upd_fresh_region
(#aloc: aloc_t) (#c: cls aloc)
(r:HS.rid)
(l:loc c)
(h0:HS.mem)
(h1:HS.mem)
: Lemma
(requires (HS.fresh_region r h0 h1 /\ modifies (loc_union (loc_all_regions_from false r) l) h0 h1))
(ensures (modifies l h0 h1))
val fresh_frame_modifies
(#aloc: aloc_t) (c: cls aloc)
(h0 h1: HS.mem)
: Lemma
(requires (HS.fresh_frame h0 h1))
(ensures (modifies #_ #c loc_none h0 h1))
val new_region_modifies
(#al: aloc_t)
(c: cls al)
(m0: HS.mem)
(r0: HS.rid)
(col: option int)
: Lemma
(requires (HST.is_eternal_region r0 /\ HS.live_region m0 r0 /\ (None? col \/ HS.is_heap_color (Some?.v col))))
(ensures (
let (_, m1) = HS.new_eternal_region m0 r0 col in
modifies (loc_none #_ #c) m0 m1
))
val popped_modifies
(#aloc: aloc_t) (c: cls aloc)
(h0 h1: HS.mem) : Lemma
(requires (HS.popped h0 h1))
(ensures (modifies #_ #c (loc_region_only false (HS.get_tip h0)) h0 h1))
val modifies_fresh_frame_popped
(#aloc: aloc_t) (#c: cls aloc)
(h0 h1: HS.mem)
(s: loc c)
(h2 h3: HS.mem)
: Lemma
(requires (
HS.fresh_frame h0 h1 /\
modifies (loc_union (loc_all_regions_from false (HS.get_tip h1)) s) h1 h2 /\
HS.get_tip h2 == HS.get_tip h1 /\
HS.popped h2 h3
))
(ensures (
modifies s h0 h3 /\
HS.get_tip h3 == HS.get_tip h0
))
val modifies_loc_regions_intro
(#aloc: aloc_t) (#c: cls aloc)
(rs: Set.set HS.rid)
(h1 h2: HS.mem)
: Lemma
(requires (HS.modifies rs h1 h2))
(ensures (modifies (loc_regions #_ #c true rs) h1 h2))
val modifies_loc_addresses_intro
(#aloc: aloc_t) (#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h1 h2: HS.mem)
: Lemma
(requires (
HS.live_region h2 r /\
modifies (loc_union (loc_region_only false r) l) h1 h2 /\
HS.modifies_ref r a h1 h2
))
(ensures (modifies (loc_union (loc_addresses true r a) l) h1 h2))
val modifies_ralloc_post
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#rel: Preorder.preorder a)
(i: HS.rid)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel)
(h' : HS.mem)
: Lemma
(requires (HST.ralloc_post i init h x h'))
(ensures (modifies (loc_none #_ #c) h h'))
val modifies_salloc_post
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#rel: Preorder.preorder a)
(init: a)
(h: HS.mem)
(x: HST.mreference a rel { HS.is_stack_region (HS.frameOf x) } )
(h' : HS.mem)
: Lemma
(requires (HST.salloc_post init h x h'))
(ensures (modifies (loc_none #_ #c) h h'))
val modifies_free
(#aloc: aloc_t) (#c: cls aloc)
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel { HS.is_mm r } )
(m: HS.mem { m `HS.contains` r } )
: Lemma
(modifies (loc_freed_mreference #_ #c r) m (HS.free r m))
val modifies_none_modifies
(#aloc: aloc_t) (#c: cls aloc)
(h1 h2: HS.mem)
: Lemma
(requires (HST.modifies_none h1 h2))
(ensures (modifies (loc_none #_ #c) h1 h2))
val modifies_upd
(#aloc: aloc_t) (#c: cls aloc)
(#t: Type) (#pre: Preorder.preorder t)
(r: HS.mreference t pre)
(v: t)
(h: HS.mem)
: Lemma
(requires (HS.contains h r))
(ensures (modifies #_ #c (loc_mreference r) h (HS.upd h r v)))
val modifies_strengthen
(#al: aloc_t) (#c: cls al) (l: loc c) (#r0: HS.rid) (#a0: nat) (al0: al r0 a0) (h h' : HS.mem)
(alocs: (
(f: ((t: Type) -> (pre: Preorder.preorder t) -> (m: HS.mreference t pre) -> Lemma
(requires (HS.frameOf m == r0 /\ HS.as_addr m == a0 /\ HS.contains h m))
(ensures (HS.contains h' m))
)) ->
(x: al r0 a0) ->
Lemma
(requires (c.aloc_disjoint x al0 /\ loc_disjoint (loc_of_aloc x) l))
(ensures (c.aloc_preserved x h h'))
))
: Lemma
(requires (modifies (loc_union l (loc_addresses true r0 (Set.singleton a0))) h h'))
(ensures (modifies (loc_union l (loc_of_aloc al0)) h h'))
(** BEGIN TODO: move to FStar.Monotonic.HyperStack *)
val does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: GTot Type0
val not_live_region_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (~ (HS.live_region h (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val unused_in_does_not_contain_addr
(h: HS.mem)
(#a: Type)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
: Lemma
(requires (r `HS.unused_in` h))
(ensures (h `does_not_contain_addr` (HS.frameOf r, HS.as_addr r)))
val addr_unused_in_does_not_contain_addr
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` (fst ra))))
(ensures (h `does_not_contain_addr` ra))
val does_not_contain_addr_addr_unused_in
(h: HS.mem)
(ra: HS.rid * nat)
: Lemma
(requires (h `does_not_contain_addr` ra))
(ensures (HS.live_region h (fst ra) ==> snd ra `Heap.addr_unused_in` (HS.get_hmap h `Map.sel` (fst ra))))
val free_does_not_contain_addr
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
HS.is_mm r /\
m `HS.contains` r /\
fst x == HS.frameOf r /\
snd x == HS.as_addr r
))
(ensures (
HS.free r m `does_not_contain_addr` x
))
val does_not_contain_addr_elim
(#a: Type0)
(#rel: Preorder.preorder a)
(r: HS.mreference a rel)
(m: HS.mem)
(x: HS.rid * nat)
: Lemma
(requires (
m `does_not_contain_addr` x /\
HS.frameOf r == fst x /\
HS.as_addr r == snd x
))
(ensures (~ (m `HS.contains` r)))
(** END TODO *)
val loc_not_unused_in (#al: aloc_t) (c: cls al) (h: HS.mem) : GTot (loc c)
val loc_unused_in (#al: aloc_t) (c: cls al) (h: HS.mem) : GTot (loc c)
val loc_regions_unused_in (#al: aloc_t) (c: cls al) (h: HS.mem) (rs: Set.set HS.rid) : Lemma
(requires (forall r . Set.mem r rs ==> (~ (HS.live_region h r))))
(ensures (loc_unused_in c h `loc_includes` loc_regions false rs))
val loc_addresses_unused_in (#al: aloc_t) (c: cls al) (r: HS.rid) (a: Set.set nat) (h: HS.mem) : Lemma
(requires (forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x)))
(ensures (loc_unused_in c h `loc_includes` loc_addresses false r a))
val loc_addresses_not_unused_in (#al: aloc_t) (c: cls al) (r: HS.rid) (a: Set.set nat) (h: HS.mem) : Lemma
(requires (forall x . Set.mem x a ==> ~ (h `does_not_contain_addr` (r, x))))
(ensures (loc_not_unused_in c h `loc_includes` loc_addresses false r a))
val loc_unused_in_not_unused_in_disjoint (#al: aloc_t) (c: cls al) (h: HS.mem) : Lemma
(loc_unused_in c h `loc_disjoint` loc_not_unused_in c h)
val not_live_region_loc_not_unused_in_disjoint
(#al: aloc_t)
(c: cls al)
(h0: HS.mem)
(r: HS.rid)
: Lemma
(requires (~ (HS.live_region h0 r)))
(ensures (loc_disjoint (loc_region_only false r) (loc_not_unused_in c h0)))
val modifies_address_liveness_insensitive_unused_in
(#al: aloc_t)
(c: cls al)
(h h' : HS.mem)
: Lemma
(requires (modifies (address_liveness_insensitive_locs c) h h'))
(ensures (loc_not_unused_in c h' `loc_includes` loc_not_unused_in c h /\ loc_unused_in c h `loc_includes` loc_unused_in c h'))
val modifies_only_not_unused_in
(#al: aloc_t)
(#c: cls al)
(l: loc c)
(h h' : HS.mem)
: Lemma
(requires (modifies (loc_unused_in c h `loc_union` l) h h'))
(ensures (modifies l h h'))
let modifies_only_live_addresses
(#aloc: aloc_t) (#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h' : HS.mem)
: Lemma
(requires (
modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x . Set.mem x a ==> h `does_not_contain_addr` (r, x))
)) | false | false | FStar.ModifiesGen.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_only_live_addresses
(#aloc: aloc_t)
(#c: cls aloc)
(r: HS.rid)
(a: Set.set nat)
(l: loc c)
(h h': HS.mem)
: Lemma
(requires
(modifies (loc_union (loc_addresses false r a) l) h h' /\
(forall x. Set.mem x a ==> h `does_not_contain_addr` (r, x)))) (ensures (modifies l h h')) | [] | FStar.ModifiesGen.modifies_only_live_addresses | {
"file_name": "ulib/FStar.ModifiesGen.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
r: FStar.Monotonic.HyperHeap.rid ->
a: FStar.Set.set Prims.nat ->
l: FStar.ModifiesGen.loc c ->
h: FStar.Monotonic.HyperStack.mem ->
h': FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.ModifiesGen.modifies (FStar.ModifiesGen.loc_union (FStar.ModifiesGen.loc_addresses false
r
a)
l)
h
h' /\
(forall (x: Prims.nat).
FStar.Set.mem x a ==> FStar.ModifiesGen.does_not_contain_addr h (r, x)))
(ensures FStar.ModifiesGen.modifies l h h') | {
"end_col": 36,
"end_line": 1050,
"start_col": 2,
"start_line": 1044
} |
Prims.Pure | val subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f | val subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
let subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) = | false | null | false | f | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.MST.pre_t",
"FStar.MST.post_t",
"FStar.NMST.repr",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_True"
] | [] | (*
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 FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | [] | FStar.NMST.subcomp | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req_f: FStar.MST.pre_t state ->
ens_f: FStar.MST.post_t state a ->
req_g: FStar.MST.pre_t state ->
ens_g: FStar.MST.post_t state a ->
f: FStar.NMST.repr a state rel req_f ens_f
-> Prims.Pure (FStar.NMST.repr a state rel req_g ens_g) | {
"end_col": 3,
"end_line": 80,
"start_col": 2,
"start_line": 80
} |
FStar.NMST.NMSTATE | val nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nmst_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
=
assert p | val nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
let nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) = | true | null | false | assert p | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims._assert",
"Prims.unit",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (t, n) -> t n, n+1)
let lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1))))
=
fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n
sub_effect PURE ~> NMSTATE = lift_pure_nmst
(*
* A polymonadic bind between DIV and NMSTATE
*
* This is ultimately used when defining par and frame in Steel.Effect.fst
* par and frame try to compose reified Steel with Steel, since Steel is non total, its reification
* incurs a Div effect, and so, we need a way to compose Div and Steel
*
* To do so, we have to go all the way down and have a story for MST and NMST too
*
* This polymonadic bind gives us bare minimum to realize that
* It is quite imprecise, in that it doesn't say anything about the post of the Div computation
* That's because, the as_ensures combinator is not encoded for Div effect in the SMT,
* the way it is done for PURE and GHOST
*
* However, since the reification use case gives us Dv anyway, this is fine for now
*)
let bind_div_nmst (a:Type) (b:Type)
(wp:pure_wp a)
(state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b)
(f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x)))
: repr b state rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1)
= elim_pure_wp_monotonicity wp;
fun s0 ->
let x = f () in
(g x) s0
polymonadic_bind (DIV, NMSTATE) |> NMSTATE = bind_div_nmst
let nmst_assume (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATE unit state rel (fun _ -> True) (fun m0 _ m1 -> p /\ m0 == m1)
=
assume p
let nmst_admit (#state:Type u#2) (#rel:P.preorder state) (#a:Type) ()
: NMSTATE a state rel (fun _ -> True) (fun _ _ _ -> False)
=
admit ()
let nmst_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nmst_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | [] | FStar.NMST.nmst_assert | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: Type0 -> FStar.NMST.NMSTATE Prims.unit | {
"end_col": 10,
"end_line": 216,
"start_col": 2,
"start_line": 216
} |
FStar.NMST.NMSTATE | val put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n) | val put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s)
let put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = | true | null | false | NMSTATE?.reflect (fun (_, n) -> MST.put s, n) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"FStar.MST.put",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATE unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) | [] | FStar.NMST.put | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: state -> FStar.NMST.NMSTATE Prims.unit | {
"end_col": 47,
"end_line": 124,
"start_col": 2,
"start_line": 124
} |
FStar.NMST.NMSTATE | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATE (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATE (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
let witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATE (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) = | true | null | false | NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Witnessed.Core.s_predicate",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Witnessed.Core.witnessed",
"FStar.MST.witness",
"Prims.l_and",
"FStar.Witnessed.Core.stable",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATE (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | [] | FStar.NMST.witness | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state
-> FStar.NMST.NMSTATE (FStar.Witnessed.Core.witnessed state rel p) | {
"end_col": 59,
"end_line": 133,
"start_col": 2,
"start_line": 133
} |
FStar.NMST.NMSTATE | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n) | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1)
let recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = | true | null | false | NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Witnessed.Core.s_predicate",
"FStar.Witnessed.Core.witnessed",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"FStar.MST.recall",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATE unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) | [] | FStar.NMST.recall | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
state: Type ->
rel: FStar.Preorder.preorder state ->
p: FStar.Witnessed.Core.s_predicate state ->
w: FStar.Witnessed.Core.witnessed state rel p
-> FStar.NMST.NMSTATE Prims.unit | {
"end_col": 60,
"end_line": 144,
"start_col": 2,
"start_line": 144
} |
Prims.Tot | val bind_div_nmst
(a b: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(req: (a -> M.pre_t state))
(ens: (a -> M.post_t state b))
(f: (eqtype_as_type unit -> DIV a wp))
(g: (x: a -> repr b state rel (req x) (ens x)))
: repr b
state
rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind_div_nmst (a:Type) (b:Type)
(wp:pure_wp a)
(state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b)
(f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x)))
: repr b state rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1)
= elim_pure_wp_monotonicity wp;
fun s0 ->
let x = f () in
(g x) s0 | val bind_div_nmst
(a b: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(req: (a -> M.pre_t state))
(ens: (a -> M.post_t state b))
(f: (eqtype_as_type unit -> DIV a wp))
(g: (x: a -> repr b state rel (req x) (ens x)))
: repr b
state
rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1)
let bind_div_nmst
(a b: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(req: (a -> M.pre_t state))
(ens: (a -> M.post_t state b))
(f: (eqtype_as_type unit -> DIV a wp))
(g: (x: a -> repr b state rel (req x) (ens x)))
: repr b
state
rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1) = | false | null | false | elim_pure_wp_monotonicity wp;
fun s0 ->
let x = f () in
(g x) s0 | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"FStar.Preorder.preorder",
"FStar.MST.pre_t",
"FStar.MST.post_t",
"FStar.Pervasives.eqtype_as_type",
"Prims.unit",
"FStar.NMST.repr",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"Prims.l_and",
"Prims.l_True",
"Prims.l_Forall",
"Prims.l_Exists"
] | [] | (*
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 FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (t, n) -> t n, n+1)
let lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1))))
=
fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n
sub_effect PURE ~> NMSTATE = lift_pure_nmst
(*
* A polymonadic bind between DIV and NMSTATE
*
* This is ultimately used when defining par and frame in Steel.Effect.fst
* par and frame try to compose reified Steel with Steel, since Steel is non total, its reification
* incurs a Div effect, and so, we need a way to compose Div and Steel
*
* To do so, we have to go all the way down and have a story for MST and NMST too
*
* This polymonadic bind gives us bare minimum to realize that
* It is quite imprecise, in that it doesn't say anything about the post of the Div computation
* That's because, the as_ensures combinator is not encoded for Div effect in the SMT,
* the way it is done for PURE and GHOST
*
* However, since the reification use case gives us Dv anyway, this is fine for now
*)
let bind_div_nmst (a:Type) (b:Type)
(wp:pure_wp a)
(state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b)
(f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x)))
: repr b state rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0)) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind_div_nmst
(a b: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(req: (a -> M.pre_t state))
(ens: (a -> M.post_t state b))
(f: (eqtype_as_type unit -> DIV a wp))
(g: (x: a -> repr b state rel (req x) (ens x)))
: repr b
state
rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1) | [] | FStar.NMST.bind_div_nmst | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
b: Type ->
wp: Prims.pure_wp a ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req: (_: a -> FStar.MST.pre_t state) ->
ens: (_: a -> FStar.MST.post_t state b) ->
f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> FStar.Pervasives.DIV a) ->
g: (x: a -> FStar.NMST.repr b state rel (req x) (ens x))
-> FStar.NMST.repr b
state
rel
(fun s0 -> wp (fun _ -> Prims.l_True) /\ (forall (x: a). req x s0))
(fun s0 y s1 -> exists (x: a). ens x s0 y s1) | {
"end_col": 10,
"end_line": 198,
"start_col": 2,
"start_line": 195
} |
FStar.NMST.NMSTATE | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n) | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
let get (#state: Type u#2) (#rel: P.preorder state) ()
: NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = | true | null | false | NMSTATE?.reflect (fun (_, n) -> MST.get (), n) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.MST.get",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) | [] | FStar.NMST.get | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.NMST.NMSTATE state | {
"end_col": 48,
"end_line": 116,
"start_col": 2,
"start_line": 116
} |
Prims.Tot | val lift_nmst_total_nmst
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req: M.pre_t state)
(ens: M.post_t state a)
(f: NMSTTotal.repr a state rel req ens)
: repr a state rel req ens | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lift_nmst_total_nmst (a:Type) (state:Type u#2) (rel:P.preorder state)
(req:M.pre_t state) (ens:M.post_t state a)
(f:NMSTTotal.repr a state rel req ens)
: repr a state rel req ens
= fun (t, n) -> f (t, n) | val lift_nmst_total_nmst
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req: M.pre_t state)
(ens: M.post_t state a)
(f: NMSTTotal.repr a state rel req ens)
: repr a state rel req ens
let lift_nmst_total_nmst
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req: M.pre_t state)
(ens: M.post_t state a)
(f: NMSTTotal.repr a state rel req ens)
: repr a state rel req ens = | false | null | false | fun (t, n) -> f (t, n) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.MST.pre_t",
"FStar.MST.post_t",
"FStar.NMSTTotal.repr",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.NMSTTotal.tape",
"FStar.NMST.repr"
] | [] | (*
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 FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (t, n) -> t n, n+1)
let lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1))))
=
fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n
sub_effect PURE ~> NMSTATE = lift_pure_nmst
(*
* A polymonadic bind between DIV and NMSTATE
*
* This is ultimately used when defining par and frame in Steel.Effect.fst
* par and frame try to compose reified Steel with Steel, since Steel is non total, its reification
* incurs a Div effect, and so, we need a way to compose Div and Steel
*
* To do so, we have to go all the way down and have a story for MST and NMST too
*
* This polymonadic bind gives us bare minimum to realize that
* It is quite imprecise, in that it doesn't say anything about the post of the Div computation
* That's because, the as_ensures combinator is not encoded for Div effect in the SMT,
* the way it is done for PURE and GHOST
*
* However, since the reification use case gives us Dv anyway, this is fine for now
*)
let bind_div_nmst (a:Type) (b:Type)
(wp:pure_wp a)
(state:Type u#2) (rel:P.preorder state) (req:a -> M.pre_t state) (ens:a -> M.post_t state b)
(f:eqtype_as_type unit -> DIV a wp) (g:(x:a -> repr b state rel (req x) (ens x)))
: repr b state rel
(fun s0 -> wp (fun _ -> True) /\ (forall x. req x s0))
(fun s0 y s1 -> exists x. (ens x) s0 y s1)
= elim_pure_wp_monotonicity wp;
fun s0 ->
let x = f () in
(g x) s0
polymonadic_bind (DIV, NMSTATE) |> NMSTATE = bind_div_nmst
let nmst_assume (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATE unit state rel (fun _ -> True) (fun m0 _ m1 -> p /\ m0 == m1)
=
assume p
let nmst_admit (#state:Type u#2) (#rel:P.preorder state) (#a:Type) ()
: NMSTATE a state rel (fun _ -> True) (fun _ _ _ -> False)
=
admit ()
let nmst_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATE unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
=
assert p
let lift_nmst_total_nmst (a:Type) (state:Type u#2) (rel:P.preorder state)
(req:M.pre_t state) (ens:M.post_t state a)
(f:NMSTTotal.repr a state rel req ens) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lift_nmst_total_nmst
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req: M.pre_t state)
(ens: M.post_t state a)
(f: NMSTTotal.repr a state rel req ens)
: repr a state rel req ens | [] | FStar.NMST.lift_nmst_total_nmst | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req: FStar.MST.pre_t state ->
ens: FStar.MST.post_t state a ->
f: FStar.NMSTTotal.repr a state rel req ens
-> FStar.NMST.repr a state rel req ens | {
"end_col": 24,
"end_line": 222,
"start_col": 2,
"start_line": 222
} |
Prims.Tot | val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n | val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
let return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = | false | null | false | fun (_, n) -> x, n | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.NMST.repr",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | [] | FStar.NMST.return | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> x: a -> state: Type -> rel: FStar.Preorder.preorder state
-> FStar.NMST.repr a state rel (fun _ -> Prims.l_True) (fun s0 r s1 -> r == x /\ s0 == s1) | {
"end_col": 20,
"end_line": 44,
"start_col": 2,
"start_line": 44
} |
Prims.Tot | val bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1) | val bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
let bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = | false | null | false | fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.MST.pre_t",
"FStar.MST.post_t",
"FStar.NMST.repr",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_Exists"
] | [] | (*
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 FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | [] | FStar.NMST.bind | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
b: Type ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req_f: FStar.MST.pre_t state ->
ens_f: FStar.MST.post_t state a ->
req_g: (_: a -> FStar.MST.pre_t state) ->
ens_g: (_: a -> FStar.MST.post_t state b) ->
f: FStar.NMST.repr a state rel req_f ens_f ->
g: (x: a -> FStar.NMST.repr b state rel (req_g x) (ens_g x))
-> FStar.NMST.repr b
state
rel
(fun s0 -> req_f s0 /\ (forall (x: a) (s1: state). ens_f s0 x s1 ==> req_g x s1))
(fun s0 r s2 ->
req_f s0 /\ (exists (x: a) (s1: state). ens_f s0 x s1 /\ req_g x s1 /\ ens_g x s1 r s2)) | {
"end_col": 17,
"end_line": 63,
"start_col": 2,
"start_line": 61
} |
FStar.NMST.NMSTATE | val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MST",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (t, n) -> t n, n+1) | val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1)
let sample (#state: Type u#2) (#rel: P.preorder state) ()
: NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = | true | null | false | NMSTATE?.reflect (fun (t, n) -> t n, n + 1) | {
"checked_file": "FStar.NMST.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.NMSTTotal.fst.checked",
"FStar.MST.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMST.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.NMST.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Addition",
"Prims.l_True",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.NMST
#set-options "--compat_pre_typed_indexed_effects"
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MST
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATE (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
reflectable
effect {
NMSTATE (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATE?.reflect (fun (_, n) -> MST.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATE unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATE?.reflect (fun (_, n) -> MST.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATE (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATE?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATE unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATE?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATE bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1) | false | false | FStar.NMST.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATE bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) | [] | FStar.NMST.sample | {
"file_name": "ulib/experimental/FStar.NMST.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.NMST.NMSTATE Prims.bool | {
"end_col": 43,
"end_line": 152,
"start_col": 2,
"start_line": 152
} |
Prims.Tot | val while_body_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body) | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let while_body_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body)
= Metatheory.admit_comp_typing g (comp_while_body x inv_body) | val while_body_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body)
let while_body_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body) = | false | null | false | Metatheory.admit_comp_typing g (comp_while_body x inv_body) | {
"checked_file": "Pulse.Checker.While.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.While.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_exists_sl",
"Pulse.Typing.as_binder",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.Metatheory.Base.admit_comp_typing",
"Pulse.Typing.comp_while_body",
"Pulse.Typing.Metatheory.Base.comp_typing_u"
] | [] | module Pulse.Checker.While
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Metatheory = Pulse.Typing.Metatheory
let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body)
= Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
let while_body_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) | false | false | Pulse.Checker.While.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val while_body_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body) | [] | Pulse.Checker.While.while_body_comp_typing | {
"file_name": "lib/steel/pulse/Pulse.Checker.While.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u13: Pulse.Syntax.Base.universe ->
x: Pulse.Syntax.Base.ppname ->
ty: Pulse.Syntax.Base.term ->
inv_body: Pulse.Syntax.Base.term ->
inv_typing:
Pulse.Typing.tot_typing g
(Pulse.Syntax.Base.tm_exists_sl u13 (Pulse.Typing.as_binder ty) inv_body)
Pulse.Syntax.Base.tm_vprop
-> Pulse.Typing.Metatheory.Base.comp_typing_u g (Pulse.Typing.comp_while_body x inv_body) | {
"end_col": 63,
"end_line": 21,
"start_col": 4,
"start_line": 21
} |
Prims.Tot | val while_cond_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body) | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body)
= Metatheory.admit_comp_typing g (comp_while_cond x inv_body) | val while_cond_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body)
let while_cond_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body) = | false | null | false | Metatheory.admit_comp_typing g (comp_while_cond x inv_body) | {
"checked_file": "Pulse.Checker.While.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.While.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_exists_sl",
"Pulse.Typing.as_binder",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.Metatheory.Base.admit_comp_typing",
"Pulse.Typing.comp_while_cond",
"Pulse.Typing.Metatheory.Base.comp_typing_u"
] | [] | module Pulse.Checker.While
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Metatheory = Pulse.Typing.Metatheory
let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop) | false | false | Pulse.Checker.While.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val while_cond_comp_typing
(#g: env)
(u: universe)
(x: ppname)
(ty inv_body: term)
(inv_typing: tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body) | [] | Pulse.Checker.While.while_cond_comp_typing | {
"file_name": "lib/steel/pulse/Pulse.Checker.While.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
u7: Pulse.Syntax.Base.universe ->
x: Pulse.Syntax.Base.ppname ->
ty: Pulse.Syntax.Base.term ->
inv_body: Pulse.Syntax.Base.term ->
inv_typing:
Pulse.Typing.tot_typing g
(Pulse.Syntax.Base.tm_exists_sl u7 (Pulse.Typing.as_binder ty) inv_body)
Pulse.Syntax.Base.tm_vprop
-> Pulse.Typing.Metatheory.Base.comp_typing_u g (Pulse.Typing.comp_while_cond x inv_body) | {
"end_col": 63,
"end_line": 16,
"start_col": 4,
"start_line": 16
} |
FStar.Tactics.Effect.Tac | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) | [
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) =
let g = push_context "while loop" t.range g in
let Tm_While { invariant=inv; condition=cond; body; condition_var } = t.term in
let (| ex_inv, inv_typing |) =
check_vprop (push_context "invariant" (term_range inv) g)
(tm_exists_sl u0 { binder_ppname=condition_var; binder_ty=tm_bool } inv)
in
if not (Tm_ExistsSL? ex_inv.t)
then fail g (Some t.range)
(Printf.sprintf "check_while: typechecked invariant %s is not an existential"
(P.term_to_string ex_inv));
let Tm_ExistsSL u {binder_ppname=nm; binder_ty=ty} inv = ex_inv.t in
if not (eq_tm ty tm_bool) ||
not (eq_univ u u0)
then fail g (Some nm.range)
(Printf.sprintf "While loop invariant exists but its witness type is %s, expected bool"
(P.term_to_string ty));
let while_cond_comp_typing = while_cond_comp_typing u nm ty inv inv_typing in
let (| res_typing, cond_pre_typing, x, post_typing |) =
Metatheory.(st_comp_typing_inversion (comp_typing_inversion while_cond_comp_typing))
in
let while_cond_hint : post_hint_for_env g =
post_hint_from_comp_typing while_cond_comp_typing
in
let (| cond, cond_comp, cond_typing |) =
let ppname = mk_ppname_no_range "_while_c" in
let r = check
(push_context "check_while_condition" cond.range g)
(comp_pre (comp_while_cond nm inv))
cond_pre_typing
(Some while_cond_hint)
ppname
cond in
apply_checker_result_k r ppname
in
if eq_comp cond_comp (comp_while_cond nm inv)
then begin
let while_body_comp_typing = while_body_comp_typing u nm ty inv inv_typing in
let (| res_typing, body_pre_typing, x, post_typing |) =
Metatheory.(st_comp_typing_inversion (comp_typing_inversion while_body_comp_typing))
in
let while_post_hint : post_hint_for_env g =
post_hint_from_comp_typing while_body_comp_typing
in
let (| body, body_comp, body_typing |) =
let ppname = mk_ppname_no_range "_while_b" in
let r = check
(push_context "check_while_body" body.range g)
(comp_pre (comp_while_body nm inv))
body_pre_typing
(Some while_post_hint)
ppname
body in
apply_checker_result_k r ppname in
if eq_comp body_comp (comp_while_body nm inv)
then
let d = T_While g inv cond body inv_typing cond_typing body_typing in
prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint t.range
else fail g None
(Printf.sprintf "Could not prove the inferred type of the while body matches the annotation\n\
Inferred type = %s\n\
Annotated type = %s\n"
(P.comp_to_string body_comp)
(P.comp_to_string (comp_while_body nm inv)))
end
else fail g None
(Printf.sprintf "Could not prove that the inferred type of the while condition matches the annotation\n\
Inferred type = %s\n\
Annotated type = %s\n"
(P.comp_to_string cond_comp)
(P.comp_to_string (comp_while_cond nm inv))) | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint)
let check
(g: env)
(pre: term)
(pre_typing: tot_typing g pre tm_vprop)
(post_hint: post_hint_opt g)
(res_ppname: ppname)
(t: st_term{Tm_While? t.term})
(check: check_t)
: T.Tac (checker_result_t g pre post_hint) = | true | null | false | let g = push_context "while loop" t.range g in
let Tm_While { invariant = inv ; condition = cond ; body = body ; condition_var = condition_var } =
t.term
in
let (| ex_inv , inv_typing |) =
check_vprop (push_context "invariant" (term_range inv) g)
(tm_exists_sl u0 ({ binder_ppname = condition_var; binder_ty = tm_bool }) inv)
in
if not (Tm_ExistsSL? ex_inv.t)
then
fail g
(Some t.range)
(Printf.sprintf "check_while: typechecked invariant %s is not an existential"
(P.term_to_string ex_inv));
let Tm_ExistsSL u { binder_ppname = nm ; binder_ty = ty } inv = ex_inv.t in
if not (eq_tm ty tm_bool) || not (eq_univ u u0)
then
fail g
(Some nm.range)
(Printf.sprintf "While loop invariant exists but its witness type is %s, expected bool"
(P.term_to_string ty));
let while_cond_comp_typing = while_cond_comp_typing u nm ty inv inv_typing in
let (| res_typing , cond_pre_typing , x , post_typing |) =
let open Metatheory in st_comp_typing_inversion (comp_typing_inversion while_cond_comp_typing)
in
let while_cond_hint:post_hint_for_env g = post_hint_from_comp_typing while_cond_comp_typing in
let (| cond , cond_comp , cond_typing |) =
let ppname = mk_ppname_no_range "_while_c" in
let r =
check (push_context "check_while_condition" cond.range g)
(comp_pre (comp_while_cond nm inv))
cond_pre_typing
(Some while_cond_hint)
ppname
cond
in
apply_checker_result_k r ppname
in
if eq_comp cond_comp (comp_while_cond nm inv)
then
let while_body_comp_typing = while_body_comp_typing u nm ty inv inv_typing in
let (| res_typing , body_pre_typing , x , post_typing |) =
let open Metatheory in st_comp_typing_inversion (comp_typing_inversion while_body_comp_typing)
in
let while_post_hint:post_hint_for_env g = post_hint_from_comp_typing while_body_comp_typing in
let (| body , body_comp , body_typing |) =
let ppname = mk_ppname_no_range "_while_b" in
let r =
check (push_context "check_while_body" body.range g)
(comp_pre (comp_while_body nm inv))
body_pre_typing
(Some while_post_hint)
ppname
body
in
apply_checker_result_k r ppname
in
if eq_comp body_comp (comp_while_body nm inv)
then
let d = T_While g inv cond body inv_typing cond_typing body_typing in
prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname
)
post_hint
t.range
else
fail g
None
(Printf.sprintf "Could not prove the inferred type of the while body matches the annotation\nInferred type = %s\nAnnotated type = %s\n"
(P.comp_to_string body_comp)
(P.comp_to_string (comp_while_body nm inv)))
else
fail g
None
(Printf.sprintf "Could not prove that the inferred type of the while condition matches the annotation\nInferred type = %s\nAnnotated type = %s\n"
(P.comp_to_string cond_comp)
(P.comp_to_string (comp_while_cond nm inv))) | {
"checked_file": "Pulse.Checker.While.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.While.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.post_hint_opt",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_While",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Checker.Base.check_t",
"Pulse.Checker.Pure.push_context",
"Pulse.Syntax.Base.term_range",
"Pulse.Syntax.Base.universe",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"Pulse.Syntax.Base.st_comp_of_comp",
"Pulse.Typing.comp_while_cond",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Syntax.Base.var",
"Pulse.Typing.fresh_wrt",
"Pulse.Syntax.Naming.freevars",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Syntax.Naming.open_term",
"Pulse.Syntax.Base.comp_st",
"Prims.l_and",
"Prims.eq2",
"Pulse.Syntax.Base.vprop",
"Pulse.Syntax.Base.comp_pre",
"Pulse.Typing.comp_post_matches_hint",
"FStar.Pervasives.Native.Some",
"Pulse.Typing.post_hint_t",
"Pulse.Typing.st_typing",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Syntax.Base.eq_comp",
"Pulse.Typing.comp_while_body",
"Pulse.Checker.Prover.prove_post_hint",
"Pulse.Checker.Base.checker_result_t",
"FStar.Pervasives.Native.None",
"Pulse.Checker.Prover.try_frame_pre",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Base.match_comp_res_with_post_hint",
"Pulse.Typing.wtag",
"Pulse.Syntax.Base.ctag",
"Pulse.Syntax.Base.STT",
"Pulse.Syntax.Base.Tm_While",
"Pulse.Syntax.Base.Mkst_term'__Tm_While__payload",
"Pulse.Typing.comp_while",
"Pulse.Typing.T_While",
"Prims.bool",
"Pulse.Typing.Env.fail",
"Pulse.Syntax.Base.range",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.comp_to_string",
"Pulse.Typing.Combinators.st_typing_in_ctxt",
"Pulse.Checker.Base.apply_checker_result_k",
"Pulse.Syntax.Base.mk_ppname_no_range",
"Pulse.Typing.post_hint_for_env",
"Pulse.Checker.Base.post_hint_from_comp_typing",
"FStar.Pervasives.dtuple4",
"Pulse.Typing.Metatheory.Base.st_comp_typing_inversion",
"Pulse.Typing.Metatheory.Base.comp_typing_inversion",
"Pulse.Typing.Metatheory.Base.comp_typing_u",
"Pulse.Checker.While.while_body_comp_typing",
"Pulse.Checker.While.while_cond_comp_typing",
"Prims.unit",
"Prims.op_BarBar",
"Prims.op_Negation",
"Pulse.Syntax.Base.eq_tm",
"Pulse.Typing.tm_bool",
"Pulse.Syntax.Base.eq_univ",
"Pulse.Syntax.Pure.u0",
"Pulse.Syntax.Base.__proj__Mkppname__item__range",
"Pulse.Syntax.Printer.term_to_string",
"Pulse.Syntax.Base.term'",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Syntax.Base.uu___is_Tm_ExistsSL",
"Prims.dtuple2",
"Pulse.Checker.Pure.check_vprop",
"Pulse.Syntax.Base.tm_exists_sl",
"Pulse.Syntax.Base.Mkbinder",
"Pulse.Syntax.Base.st_term'"
] | [] | module Pulse.Checker.While
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module T = FStar.Tactics.V2
module P = Pulse.Syntax.Printer
module Metatheory = Pulse.Typing.Metatheory
let while_cond_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_cond x inv_body)
= Metatheory.admit_comp_typing g (comp_while_cond x inv_body)
let while_body_comp_typing (#g:env) (u:universe) (x:ppname) (ty:term) (inv_body:term)
(inv_typing:tot_typing g (tm_exists_sl u (as_binder ty) inv_body) tm_vprop)
: Metatheory.comp_typing_u g (comp_while_body x inv_body)
= Metatheory.admit_comp_typing g (comp_while_body x inv_body)
#push-options "--fuel 0 --ifuel 1 --z3rlimit_factor 4"
let check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term}) | false | false | Pulse.Checker.While.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term{Tm_While? t.term})
(check:check_t)
: T.Tac (checker_result_t g pre post_hint) | [] | Pulse.Checker.While.check | {
"file_name": "lib/steel/pulse/Pulse.Checker.While.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
g: Pulse.Typing.Env.env ->
pre: Pulse.Syntax.Base.term ->
pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop ->
post_hint: Pulse.Typing.post_hint_opt g ->
res_ppname: Pulse.Syntax.Base.ppname ->
t: Pulse.Syntax.Base.st_term{Tm_While? (Mkst_term?.term t)} ->
check: Pulse.Checker.Base.check_t
-> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint) | {
"end_col": 70,
"end_line": 108,
"start_col": 46,
"start_line": 32
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Meta.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let chacha20_encrypt_256 = vec_chacha20_encrypt_higher #8 True chacha20_init_256 chacha20_core_256 | let chacha20_encrypt_256 = | false | null | false | vec_chacha20_encrypt_higher #8 True chacha20_init_256 chacha20_core_256 | {
"checked_file": "Hacl.Chacha20.Vec256.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Core32xN.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.Vec256.fst"
} | [
"total"
] | [
"Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher",
"Prims.l_True",
"Hacl.Chacha20.Vec256.chacha20_init_256",
"Hacl.Chacha20.Vec256.chacha20_core_256"
] | [] | module Hacl.Chacha20.Vec256
open Hacl.Meta.Chacha20.Vec
[@CInline]
private
let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8
[@CInline]
private
let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256
[@CInline]
private
let chacha20_init_256 = Hacl.Impl.Chacha20.Vec.chacha20_init #8 | false | false | Hacl.Chacha20.Vec256.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val chacha20_encrypt_256 : Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher_t Prims.l_True | [] | Hacl.Chacha20.Vec256.chacha20_encrypt_256 | {
"file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Meta.Chacha20.Vec.vec_chacha20_encrypt_higher_t Prims.l_True | {
"end_col": 98,
"end_line": 15,
"start_col": 27,
"start_line": 15
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": false,
"full_module": "Hacl.Meta.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8 | let double_round_256 = | true | null | false | Hacl.Impl.Chacha20.Core32xN.double_round #8 | {
"checked_file": "Hacl.Chacha20.Vec256.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Core32xN.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.Vec256.fst"
} | [] | [
"Hacl.Impl.Chacha20.Core32xN.double_round"
] | [] | module Hacl.Chacha20.Vec256
open Hacl.Meta.Chacha20.Vec
[@CInline] | false | false | Hacl.Chacha20.Vec256.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val double_round_256 : st: Hacl.Impl.Chacha20.Core32xN.state 8 -> FStar.HyperStack.ST.Stack Prims.unit | [] | Hacl.Chacha20.Vec256.double_round_256 | {
"file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | st: Hacl.Impl.Chacha20.Core32xN.state 8 -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 66,
"end_line": 7,
"start_col": 23,
"start_line": 7
} |
|
FStar.HyperStack.ST.Stack | [
{
"abbrev": false,
"full_module": "Hacl.Meta.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let chacha20_init_256 = Hacl.Impl.Chacha20.Vec.chacha20_init #8 | let chacha20_init_256 = | true | null | false | Hacl.Impl.Chacha20.Vec.chacha20_init #8 | {
"checked_file": "Hacl.Chacha20.Vec256.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Core32xN.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.Vec256.fst"
} | [] | [
"Hacl.Impl.Chacha20.Vec.chacha20_init"
] | [] | module Hacl.Chacha20.Vec256
open Hacl.Meta.Chacha20.Vec
[@CInline]
private
let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8
[@CInline]
private
let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256
[@CInline] | false | false | Hacl.Chacha20.Vec256.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val chacha20_init_256 : ctx: Hacl.Impl.Chacha20.Core32xN.state 8 ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul ->
ctr0: Lib.IntTypes.size_t
-> FStar.HyperStack.ST.Stack Prims.unit | [] | Hacl.Chacha20.Vec256.chacha20_init_256 | {
"file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ctx: Hacl.Impl.Chacha20.Core32xN.state 8 ->
k: Lib.Buffer.lbuffer Lib.IntTypes.uint8 32ul ->
n: Lib.Buffer.lbuffer Lib.IntTypes.uint8 12ul ->
ctr0: Lib.IntTypes.size_t
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 63,
"end_line": 13,
"start_col": 24,
"start_line": 13
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Meta.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256 | let chacha20_core_256 = | false | null | false | vec_chacha20_core_higher #8 True double_round_256 | {
"checked_file": "Hacl.Chacha20.Vec256.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Core32xN.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.Vec256.fst"
} | [
"total"
] | [
"Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher",
"Prims.l_True",
"Hacl.Chacha20.Vec256.double_round_256"
] | [] | module Hacl.Chacha20.Vec256
open Hacl.Meta.Chacha20.Vec
[@CInline]
private
let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8
[@CInline] | false | false | Hacl.Chacha20.Vec256.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val chacha20_core_256 : Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher_t Prims.l_True | [] | Hacl.Chacha20.Vec256.chacha20_core_256 | {
"file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Meta.Chacha20.Vec.vec_chacha20_core_higher_t Prims.l_True | {
"end_col": 73,
"end_line": 10,
"start_col": 24,
"start_line": 10
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Hacl.Meta.Chacha20.Vec",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Chacha20",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let chacha20_decrypt_256 = vec_chacha20_decrypt_higher #8 True chacha20_init_256 chacha20_core_256 | let chacha20_decrypt_256 = | false | null | false | vec_chacha20_decrypt_higher #8 True chacha20_init_256 chacha20_core_256 | {
"checked_file": "Hacl.Chacha20.Vec256.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Vec.fst.checked",
"Hacl.Impl.Chacha20.Core32xN.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Chacha20.Vec256.fst"
} | [
"total"
] | [
"Hacl.Meta.Chacha20.Vec.vec_chacha20_decrypt_higher",
"Prims.l_True",
"Hacl.Chacha20.Vec256.chacha20_init_256",
"Hacl.Chacha20.Vec256.chacha20_core_256"
] | [] | module Hacl.Chacha20.Vec256
open Hacl.Meta.Chacha20.Vec
[@CInline]
private
let double_round_256 = Hacl.Impl.Chacha20.Core32xN.double_round #8
[@CInline]
private
let chacha20_core_256 = vec_chacha20_core_higher #8 True double_round_256
[@CInline]
private
let chacha20_init_256 = Hacl.Impl.Chacha20.Vec.chacha20_init #8 | false | false | Hacl.Chacha20.Vec256.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val chacha20_decrypt_256 : Hacl.Meta.Chacha20.Vec.vec_chacha20_decrypt_higher_t Prims.l_True | [] | Hacl.Chacha20.Vec256.chacha20_decrypt_256 | {
"file_name": "code/chacha20/Hacl.Chacha20.Vec256.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Meta.Chacha20.Vec.vec_chacha20_decrypt_higher_t Prims.l_True | {
"end_col": 98,
"end_line": 16,
"start_col": 27,
"start_line": 16
} |
|
Prims.Tot | val openBase: openBase_st cs vale_p | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let openBase = hpke_openBase_higher #cs vale_p IAEAD.aead_decrypt_cp128 setupBaseR | val openBase: openBase_st cs vale_p
let openBase = | false | null | false | hpke_openBase_higher #cs vale_p IAEAD.aead_decrypt_cp128 setupBaseR | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_openBase_higher",
"Hacl.HPKE.Curve64_CP128_SHA512.cs",
"Hacl.HPKE.Curve64_CP128_SHA512.vale_p",
"Hacl.HPKE.Interface.AEAD.aead_decrypt_cp128",
"Hacl.HPKE.Curve64_CP128_SHA512.setupBaseR"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256
let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64
let sealBase = hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp128 setupBaseS | false | true | Hacl.HPKE.Curve64_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val openBase: openBase_st cs vale_p | [] | Hacl.HPKE.Curve64_CP128_SHA512.openBase | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.openBase_st Hacl.HPKE.Curve64_CP128_SHA512.cs Hacl.HPKE.Curve64_CP128_SHA512.vale_p | {
"end_col": 82,
"end_line": 20,
"start_col": 15,
"start_line": 20
} |
Prims.Tot | val sealBase: sealBase_st cs vale_p | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sealBase = hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp128 setupBaseS | val sealBase: sealBase_st cs vale_p
let sealBase = | false | null | false | hpke_sealBase_higher #cs vale_p IAEAD.aead_encrypt_cp128 setupBaseS | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_sealBase_higher",
"Hacl.HPKE.Curve64_CP128_SHA512.cs",
"Hacl.HPKE.Curve64_CP128_SHA512.vale_p",
"Hacl.HPKE.Interface.AEAD.aead_encrypt_cp128",
"Hacl.HPKE.Curve64_CP128_SHA512.setupBaseS"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256
let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 | false | true | Hacl.HPKE.Curve64_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sealBase: sealBase_st cs vale_p | [] | Hacl.HPKE.Curve64_CP128_SHA512.sealBase | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.sealBase_st Hacl.HPKE.Curve64_CP128_SHA512.cs Hacl.HPKE.Curve64_CP128_SHA512.vale_p | {
"end_col": 82,
"end_line": 18,
"start_col": 15,
"start_line": 18
} |
Prims.Tot | val setupBaseS: setupBaseS_st cs vale_p | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 | val setupBaseS: setupBaseS_st cs vale_p
let setupBaseS = | false | null | false | hpke_setupBaseS_higher #cs
vale_p
IHK.hkdf_expand512
IHK.hkdf_extract512
IDH.secret_to_public_c64
IDH.dh_c64
IHK.hkdf_expand256
IHK.hkdf_extract256 | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_setupBaseS_higher",
"Hacl.HPKE.Curve64_CP128_SHA512.cs",
"Hacl.HPKE.Curve64_CP128_SHA512.vale_p",
"Hacl.HPKE.Interface.HKDF.hkdf_expand512",
"Hacl.HPKE.Interface.HKDF.hkdf_extract512",
"Hacl.HPKE.Interface.DH.secret_to_public_c64",
"Hacl.HPKE.Interface.DH.dh_c64",
"Hacl.HPKE.Interface.HKDF.hkdf_expand256",
"Hacl.HPKE.Interface.HKDF.hkdf_extract256"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0" | false | true | Hacl.HPKE.Curve64_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val setupBaseS: setupBaseS_st cs vale_p | [] | Hacl.HPKE.Curve64_CP128_SHA512.setupBaseS | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.setupBaseS_st Hacl.HPKE.Curve64_CP128_SHA512.cs Hacl.HPKE.Curve64_CP128_SHA512.vale_p | {
"end_col": 164,
"end_line": 14,
"start_col": 17,
"start_line": 14
} |
Prims.Tot | val setupBaseR: setupBaseR_st cs vale_p | [
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.AEAD",
"short_module": "IAEAD"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.Hash",
"short_module": "IHash"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.HKDF",
"short_module": "IHK"
},
{
"abbrev": true,
"full_module": "Hacl.HPKE.Interface.DH",
"short_module": "IDH"
},
{
"abbrev": false,
"full_module": "Hacl.Meta.HPKE",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Spec.Agile.AEAD",
"short_module": "AEAD"
},
{
"abbrev": true,
"full_module": "Spec.Agile.DH",
"short_module": "DH"
},
{
"abbrev": true,
"full_module": "Spec.Agile.HPKE",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.HPKE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let setupBaseR = hpke_setupBaseR_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 IDH.secret_to_public_c64 | val setupBaseR: setupBaseR_st cs vale_p
let setupBaseR = | false | null | false | hpke_setupBaseR_higher #cs
vale_p
IHK.hkdf_expand512
IHK.hkdf_extract512
IDH.dh_c64
IHK.hkdf_expand256
IHK.hkdf_extract256
IDH.secret_to_public_c64 | {
"checked_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.Meta.HPKE.fst.checked",
"Hacl.HPKE.Interface.HKDF.fst.checked",
"Hacl.HPKE.Interface.Hash.fst.checked",
"Hacl.HPKE.Interface.DH.fst.checked",
"Hacl.HPKE.Interface.AEAD.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.HPKE.Curve64_CP128_SHA512.fst"
} | [
"total"
] | [
"Hacl.Meta.HPKE.hpke_setupBaseR_higher",
"Hacl.HPKE.Curve64_CP128_SHA512.cs",
"Hacl.HPKE.Curve64_CP128_SHA512.vale_p",
"Hacl.HPKE.Interface.HKDF.hkdf_expand512",
"Hacl.HPKE.Interface.HKDF.hkdf_extract512",
"Hacl.HPKE.Interface.DH.dh_c64",
"Hacl.HPKE.Interface.HKDF.hkdf_expand256",
"Hacl.HPKE.Interface.HKDF.hkdf_extract256",
"Hacl.HPKE.Interface.DH.secret_to_public_c64"
] | [] | module Hacl.HPKE.Curve64_CP128_SHA512
open Hacl.Meta.HPKE
module IDH = Hacl.HPKE.Interface.DH
module IHK = Hacl.HPKE.Interface.HKDF
module IHash = Hacl.HPKE.Interface.Hash
module IAEAD = Hacl.HPKE.Interface.AEAD
friend Hacl.Meta.HPKE
#set-options "--fuel 0 --ifuel 0"
let setupBaseS = hpke_setupBaseS_higher #cs vale_p IHK.hkdf_expand512 IHK.hkdf_extract512 IDH.secret_to_public_c64 IDH.dh_c64 IHK.hkdf_expand256 IHK.hkdf_extract256 | false | true | Hacl.HPKE.Curve64_CP128_SHA512.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val setupBaseR: setupBaseR_st cs vale_p | [] | Hacl.HPKE.Curve64_CP128_SHA512.setupBaseR | {
"file_name": "code/hpke/Hacl.HPKE.Curve64_CP128_SHA512.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Impl.HPKE.setupBaseR_st Hacl.HPKE.Curve64_CP128_SHA512.cs Hacl.HPKE.Curve64_CP128_SHA512.vale_p | {
"end_col": 164,
"end_line": 16,
"start_col": 17,
"start_line": 16
} |
Prims.Tot | val field_get_len: MA.bn_field_get_len_st t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let field_get_len k =
MA.bn_field_get_len k | val field_get_len: MA.bn_field_get_len_st t_limbs
let field_get_len k = | false | null | false | MA.bn_field_get_len k | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.bn_field_get_len",
"Hacl.Bignum.meta_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k | false | true | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val field_get_len: MA.bn_field_get_len_st t_limbs | [] | Hacl.GenericField32.field_get_len | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.MontArithmetic.bn_field_get_len_st Hacl.GenericField32.t_limbs | {
"end_col": 23,
"end_line": 25,
"start_col": 2,
"start_line": 25
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len | let km (len: BN.meta_len t_limbs) = | false | null | false | BM.mk_runtime_mont len | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.Montgomery.mk_runtime_mont",
"Hacl.Bignum.Montgomery.mont"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract | false | true | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val km : len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs
-> Hacl.Bignum.Montgomery.mont Hacl.GenericField32.t_limbs | [] | Hacl.GenericField32.km | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs
-> Hacl.Bignum.Montgomery.mont Hacl.GenericField32.t_limbs | {
"end_col": 24,
"end_line": 13,
"start_col": 2,
"start_line": 13
} |
|
Prims.Tot | val field_free: MA.bn_field_free_st t_limbs | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let field_free k =
MA.bn_field_free k | val field_free: MA.bn_field_free_st t_limbs
let field_free k = | false | null | false | MA.bn_field_free k | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.bn_field_free",
"Prims.unit"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n | false | true | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val field_free: MA.bn_field_free_st t_limbs | [] | Hacl.GenericField32.field_free | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.MontArithmetic.bn_field_free_st Hacl.GenericField32.t_limbs | {
"end_col": 20,
"end_line": 22,
"start_col": 2,
"start_line": 22
} |
Prims.Tot | val inverse: len:Ghost.erased _ -> MA.bn_field_inv_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let inverse len k aM aInvM =
MA.bn_field_inv len (exp_vartime len) k aM aInvM | val inverse: len:Ghost.erased _ -> MA.bn_field_inv_st t_limbs len
let inverse len k aM aInvM = | false | null | false | MA.bn_field_inv len (exp_vartime len) k aM aInvM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_inv",
"Hacl.GenericField32.exp_vartime",
"Prims.unit"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM
let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM
let sqr len k aM cM =
let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM
let one len k oneM =
let len = field_get_len k in
MA.bn_field_one (km len) k oneM
let exp_consttime len k aM bBits b resM =
let len = field_get_len k in
MA.bn_field_exp_consttime (km len) k aM bBits b resM
let exp_vartime len k aM bBits b resM =
let len = field_get_len k in
MA.bn_field_exp_vartime (km len) k aM bBits b resM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inverse: len:Ghost.erased _ -> MA.bn_field_inv_st t_limbs len | [] | Hacl.GenericField32.inverse | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_inv_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 50,
"end_line": 64,
"start_col": 2,
"start_line": 64
} |
Prims.Tot | val field_modulus_check: len:BN.meta_len t_limbs -> MA.bn_field_check_modulus_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n | val field_modulus_check: len:BN.meta_len t_limbs -> MA.bn_field_check_modulus_st t_limbs len
let field_modulus_check len n = | false | null | false | MA.bn_field_check_modulus (km len) n | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.MontArithmetic.bn_field_check_modulus",
"Hacl.GenericField32.km",
"Prims.bool"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val field_modulus_check: len:BN.meta_len t_limbs -> MA.bn_field_check_modulus_st t_limbs len | [] | Hacl.GenericField32.field_modulus_check | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs
-> Hacl.Bignum.MontArithmetic.bn_field_check_modulus_st Hacl.GenericField32.t_limbs len | {
"end_col": 38,
"end_line": 16,
"start_col": 2,
"start_line": 16
} |
Prims.Tot | val field_init: len:BN.meta_len t_limbs -> MA.bn_field_init_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n | val field_init: len:BN.meta_len t_limbs -> MA.bn_field_init_st t_limbs len
let field_init len r n = | false | null | false | MA.bn_field_init len (km len).BM.precomp r n | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"FStar.Monotonic.HyperHeap.rid",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.MontArithmetic.bn_field_init",
"Hacl.Bignum.Montgomery.__proj__Mkmont__item__precomp",
"Hacl.GenericField32.km",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val field_init: len:BN.meta_len t_limbs -> MA.bn_field_init_st t_limbs len | [] | Hacl.GenericField32.field_init | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs
-> Hacl.Bignum.MontArithmetic.bn_field_init_st Hacl.GenericField32.t_limbs len | {
"end_col": 46,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
Prims.Tot | val to_field: len:Ghost.erased _ -> MA.bn_to_field_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM | val to_field: len:Ghost.erased _ -> MA.bn_to_field_st t_limbs len
let to_field len k a aM = | false | null | false | let len = field_get_len k in
MA.bn_to_field (km len) k a aM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_to_field",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val to_field: len:Ghost.erased _ -> MA.bn_to_field_st t_limbs len | [] | Hacl.GenericField32.to_field | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_to_field_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 32,
"end_line": 29,
"start_col": 25,
"start_line": 27
} |
Prims.Tot | val one: len:Ghost.erased _ -> MA.bn_field_one_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let one len k oneM =
let len = field_get_len k in
MA.bn_field_one (km len) k oneM | val one: len:Ghost.erased _ -> MA.bn_field_one_st t_limbs len
let one len k oneM = | false | null | false | let len = field_get_len k in
MA.bn_field_one (km len) k oneM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_one",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM
let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM
let sqr len k aM cM =
let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val one: len:Ghost.erased _ -> MA.bn_field_one_st t_limbs len | [] | Hacl.GenericField32.one | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_one_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 33,
"end_line": 53,
"start_col": 20,
"start_line": 51
} |
Prims.Tot | val from_field: len:Ghost.erased _ -> MA.bn_from_field_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a | val from_field: len:Ghost.erased _ -> MA.bn_from_field_st t_limbs len
let from_field len k aM a = | false | null | false | let len = field_get_len k in
MA.bn_from_field (km len) k aM a | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_from_field",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val from_field: len:Ghost.erased _ -> MA.bn_from_field_st t_limbs len | [] | Hacl.GenericField32.from_field | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_from_field_st Hacl.GenericField32.t_limbs
(FStar.Ghost.reveal len) | {
"end_col": 34,
"end_line": 33,
"start_col": 27,
"start_line": 31
} |
Prims.Tot | val sqr: len:Ghost.erased _ -> MA.bn_field_sqr_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let sqr len k aM cM =
let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM | val sqr: len:Ghost.erased _ -> MA.bn_field_sqr_st t_limbs len
let sqr len k aM cM = | false | null | false | let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_sqr",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM
let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sqr: len:Ghost.erased _ -> MA.bn_field_sqr_st t_limbs len | [] | Hacl.GenericField32.sqr | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_sqr_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 34,
"end_line": 49,
"start_col": 21,
"start_line": 47
} |
Prims.Tot | val sub: len:Ghost.erased _ -> MA.bn_field_sub_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM | val sub: len:Ghost.erased _ -> MA.bn_field_sub_st t_limbs len
let sub len k aM bM cM = | false | null | false | let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_sub",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub: len:Ghost.erased _ -> MA.bn_field_sub_st t_limbs len | [] | Hacl.GenericField32.sub | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_sub_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 37,
"end_line": 41,
"start_col": 24,
"start_line": 39
} |
Prims.Tot | val add: len:Ghost.erased _ -> MA.bn_field_add_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM | val add: len:Ghost.erased _ -> MA.bn_field_add_st t_limbs len
let add len k aM bM cM = | false | null | false | let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_add",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add: len:Ghost.erased _ -> MA.bn_field_add_st t_limbs len | [] | Hacl.GenericField32.add | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_add_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 37,
"end_line": 37,
"start_col": 24,
"start_line": 35
} |
Prims.Tot | val mul: len:Ghost.erased _ -> MA.bn_field_mul_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM | val mul: len:Ghost.erased _ -> MA.bn_field_mul_st t_limbs len
let mul len k aM bM cM = | false | null | false | let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Hacl.Bignum.MontArithmetic.bn_field_mul",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul: len:Ghost.erased _ -> MA.bn_field_mul_st t_limbs len | [] | Hacl.GenericField32.mul | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_mul_st Hacl.GenericField32.t_limbs (FStar.Ghost.reveal len) | {
"end_col": 37,
"end_line": 45,
"start_col": 24,
"start_line": 43
} |
Prims.Tot | val exp_vartime: len:Ghost.erased _ -> MA.bn_field_exp_vartime_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let exp_vartime len k aM bBits b resM =
let len = field_get_len k in
MA.bn_field_exp_vartime (km len) k aM bBits b resM | val exp_vartime: len:Ghost.erased _ -> MA.bn_field_exp_vartime_st t_limbs len
let exp_vartime len k aM bBits b resM = | false | null | false | let len = field_get_len k in
MA.bn_field_exp_vartime (km len) k aM bBits b resM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.blocks0",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Bignum.MontArithmetic.bn_field_exp_vartime",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM
let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM
let sqr len k aM cM =
let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM
let one len k oneM =
let len = field_get_len k in
MA.bn_field_one (km len) k oneM
let exp_consttime len k aM bBits b resM =
let len = field_get_len k in
MA.bn_field_exp_consttime (km len) k aM bBits b resM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_vartime: len:Ghost.erased _ -> MA.bn_field_exp_vartime_st t_limbs len | [] | Hacl.GenericField32.exp_vartime | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_exp_vartime_st Hacl.GenericField32.t_limbs
(FStar.Ghost.reveal len) | {
"end_col": 52,
"end_line": 61,
"start_col": 39,
"start_line": 59
} |
Prims.Tot | val exp_consttime: len:Ghost.erased _ -> MA.bn_field_exp_consttime_st t_limbs len | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.MontArithmetic",
"short_module": "MA"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"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
}
] | false | let exp_consttime len k aM bBits b resM =
let len = field_get_len k in
MA.bn_field_exp_consttime (km len) k aM bBits b resM | val exp_consttime: len:Ghost.erased _ -> MA.bn_field_exp_consttime_st t_limbs len
let exp_consttime len k aM bBits b resM = | false | null | false | let len = field_get_len k in
MA.bn_field_exp_consttime (km len) k aM bBits b resM | {
"checked_file": "Hacl.GenericField32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.MontArithmetic.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.GenericField32.fst"
} | [
"total"
] | [
"FStar.Ghost.erased",
"Hacl.Bignum.meta_len",
"Hacl.GenericField32.t_limbs",
"Hacl.Bignum.MontArithmetic.pbn_mont_ctx",
"Hacl.Bignum.Definitions.lbignum",
"FStar.Ghost.reveal",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.blocks0",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Bignum.MontArithmetic.bn_field_exp_consttime",
"Hacl.GenericField32.km",
"Prims.unit",
"Hacl.GenericField32.field_get_len"
] | [] | module Hacl.GenericField32
open FStar.Mul
module BN = Hacl.Bignum
module MA = Hacl.Bignum.MontArithmetic
module BM = Hacl.Bignum.Montgomery
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let km (len:BN.meta_len t_limbs) =
BM.mk_runtime_mont len
let field_modulus_check len n =
MA.bn_field_check_modulus (km len) n
let field_init len r n =
MA.bn_field_init len (km len).BM.precomp r n
let field_free k =
MA.bn_field_free k
let field_get_len k =
MA.bn_field_get_len k
let to_field len k a aM =
let len = field_get_len k in
MA.bn_to_field (km len) k a aM
let from_field len k aM a =
let len = field_get_len k in
MA.bn_from_field (km len) k aM a
let add len k aM bM cM =
let len = field_get_len k in
MA.bn_field_add (km len) k aM bM cM
let sub len k aM bM cM =
let len = field_get_len k in
MA.bn_field_sub (km len) k aM bM cM
let mul len k aM bM cM =
let len = field_get_len k in
MA.bn_field_mul (km len) k aM bM cM
let sqr len k aM cM =
let len = field_get_len k in
MA.bn_field_sqr (km len) k aM cM
let one len k oneM =
let len = field_get_len k in
MA.bn_field_one (km len) k oneM | false | false | Hacl.GenericField32.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val exp_consttime: len:Ghost.erased _ -> MA.bn_field_exp_consttime_st t_limbs len | [] | Hacl.GenericField32.exp_consttime | {
"file_name": "code/bignum/Hacl.GenericField32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | len: FStar.Ghost.erased (Hacl.Bignum.meta_len Hacl.GenericField32.t_limbs)
-> Hacl.Bignum.MontArithmetic.bn_field_exp_consttime_st Hacl.GenericField32.t_limbs
(FStar.Ghost.reveal len) | {
"end_col": 54,
"end_line": 57,
"start_col": 41,
"start_line": 55
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let both (x: locations & locations) =
let a, b = x in
a `L.append` b | let both (x: locations & locations) = | false | null | false | let a, b = x in
a `L.append` b | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Vale.Transformers.Locations.locations",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"Prims.list"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf] | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val both : x: (Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations)
-> Prims.list Vale.Transformers.Locations.location | [] | Vale.Transformers.BoundedInstructionEffects.both | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: (Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations)
-> Prims.list Vale.Transformers.Locations.location | {
"end_col": 16,
"end_line": 54,
"start_col": 37,
"start_line": 52
} |
|
Prims.Tot | val read_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs | val read_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : locations
let read_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : locations = | false | null | false | aux_read_set1 i.outs i.args oprs | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"Vale.Transformers.Locations.locations"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val read_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : locations | [] | Vale.Transformers.BoundedInstructionEffects.read_set | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs i) (InstrTypeRecord?.args i)
-> Vale.Transformers.Locations.locations | {
"end_col": 34,
"end_line": 81,
"start_col": 2,
"start_line": 81
} |
Prims.Tot | val sym_difference (#t: eqtype) (l1 l2: list t) : list t | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1 | val sym_difference (#t: eqtype) (l1 l2: list t) : list t
let sym_difference (#t: eqtype) (l1 l2: list t) : list t = | false | null | false | (difference l1 l2) `L.append` (difference l2 l1) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"FStar.List.Tot.Base.append",
"Vale.Transformers.BoundedInstructionEffects.difference"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2 | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sym_difference (#t: eqtype) (l1 l2: list t) : list t | [] | Vale.Transformers.BoundedInstructionEffects.sym_difference | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l1: Prims.list t -> l2: Prims.list t -> Prims.list t | {
"end_col": 46,
"end_line": 855,
"start_col": 2,
"start_line": 855
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_ins_st_bounded_effects :
(i:ins) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) | [
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i)) | val lemma_machine_eval_ins_st_bounded_effects :
(i:ins) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i))))
let lemma_machine_eval_ins_st_bounded_effects i = | false | null | true | match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_bounded_effects_Instr",
"Vale.X64.Bytes_Code_s.instruction_t",
"FStar.Pervasives.assert_norm",
"Prims.b2t",
"Prims.op_Negation",
"Vale.Transformers.BoundedInstructionEffects.safely_bounded",
"Prims.unit"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_ins_st_bounded_effects :
(i:ins) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_bounded_effects | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Vale.X64.Machine_Semantics_s.ins
-> FStar.Pervasives.Lemma (requires Vale.Transformers.BoundedInstructionEffects.safely_bounded i)
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins
i)
(Vale.X64.Machine_Semantics_s.machine_eval_ins_st i)) | {
"end_col": 45,
"end_line": 723,
"start_col": 2,
"start_line": 721
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_ins_st_only_affects_write (i: ins{Instr? i}) (s: machine_state)
: Lemma
(ensures
((let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s)) | val lemma_machine_eval_ins_st_only_affects_write (i: ins{Instr? i}) (s: machine_state)
: Lemma
(ensures
((let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s)))))
let lemma_machine_eval_ins_st_only_affects_write (i: ins{Instr? i}) (s: machine_state)
: Lemma
(ensures
((let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) = | false | null | true | FStar.Classical.forall_intro (FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux
i
s)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.b2t",
"Vale.X64.Bytes_Code_s.uu___is_Instr",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Classical.forall_intro",
"Vale.Transformers.Locations.location",
"Prims.l_imp",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"FStar.Classical.move_requires",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_only_affects_write_aux",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.list",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_ins_st_only_affects_write (i: ins{Instr? i}) (s: machine_state)
: Lemma
(ensures
((let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_only_affects_write | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Vale.X64.Machine_Semantics_s.ins{Instr? i} -> s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(ensures
(let w = Mkrw_set?.loc_writes (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i) in
Vale.Transformers.BoundedInstructionEffects.unchanged_except w
s
(Vale.X64.Machine_Semantics_s.run (Vale.X64.Machine_Semantics_s.machine_eval_ins_st i) s))
) | {
"end_col": 89,
"end_line": 230,
"start_col": 2,
"start_line": 229
} |
FStar.Pervasives.Lemma | val lemma_instr_apply_eval_same_read
(outs: list instr_out)
(args: list instr_operand)
(f: instr_eval_t outs args)
(oprs: instr_operands_t outs args)
(s1 s2: machine_state)
: Lemma (requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures ((instr_apply_eval outs args f oprs s1) == (instr_apply_eval outs args f oprs s2))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2 | val lemma_instr_apply_eval_same_read
(outs: list instr_out)
(args: list instr_operand)
(f: instr_eval_t outs args)
(oprs: instr_operands_t outs args)
(s1 s2: machine_state)
: Lemma (requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures ((instr_apply_eval outs args f oprs s1) == (instr_apply_eval outs args f oprs s2)))
let lemma_instr_apply_eval_same_read
(outs: list instr_out)
(args: list instr_operand)
(f: instr_eval_t outs args)
(oprs: instr_operands_t outs args)
(s1 s2: machine_state)
: Lemma (requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures ((instr_apply_eval outs args f oprs s1) == (instr_apply_eval outs args f oprs s2))) = | false | null | true | lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_eval_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_inouts_same_read",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Machine_Semantics_s.instr_apply_eval",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) == | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_instr_apply_eval_same_read
(outs: list instr_out)
(args: list instr_operand)
(f: instr_eval_t outs args)
(oprs: instr_operands_t outs args)
(s1 s2: machine_state)
: Lemma (requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures ((instr_apply_eval outs args f oprs s1) == (instr_apply_eval outs args f oprs s2))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_same_read | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
f: Vale.X64.Instruction_s.instr_eval_t outs args ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Vale.Transformers.BoundedInstructionEffects.aux_read_set1
outs
args
oprs)
s1
s2)
(ensures
Vale.X64.Machine_Semantics_s.instr_apply_eval outs args f oprs s1 ==
Vale.X64.Machine_Semantics_s.instr_apply_eval outs args f oprs s2) | {
"end_col": 69,
"end_line": 359,
"start_col": 2,
"start_line": 359
} |
FStar.Pervasives.Lemma | val lemma_unchanged_except_extend (ls_extend ls: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux) | val lemma_unchanged_except_extend (ls_extend ls: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2))
let lemma_unchanged_except_extend (ls_extend ls: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) = | false | null | true | let aux a
: Lemma (requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Classical.forall_intro",
"Vale.Transformers.Locations.location",
"Prims.l_imp",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"FStar.List.Tot.Base.append",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"FStar.Classical.move_requires",
"Prims.unit",
"Vale.Def.PossiblyMonad.uu___is_Ok",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_append",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_except_extend (ls_extend ls: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_extend | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
ls_extend: Vale.Transformers.Locations.locations ->
ls: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires Vale.Transformers.BoundedInstructionEffects.unchanged_except ls s1 s2)
(ensures Vale.Transformers.BoundedInstructionEffects.unchanged_except (ls_extend @ ls) s1 s2) | {
"end_col": 66,
"end_line": 469,
"start_col": 66,
"start_line": 462
} |
FStar.Pervasives.Lemma | val lemma_unchanged_at_sym_diff_implies_difference (l1 l2: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) =
lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2 | val lemma_unchanged_at_sym_diff_implies_difference (l1 l2: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2))
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) = | false | null | true | lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Vale.Transformers.Locations.location",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.sym_difference",
"Prims.squash",
"Prims.l_and",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_at_difference_elim (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at l2 s1 s2))
(ensures (unchanged_at l1 s1 s2)) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1 s2;
lemma_unchanged_at_difference_elim xs l2 s1 s2
) else (
lemma_unchanged_at_difference_elim xs l2 s1 s2
)
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2)) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_at_sym_diff_implies_difference (l1 l2: locations) (s1 s2: machine_state)
: Lemma (requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_sym_diff_implies_difference | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
l1: Vale.Transformers.Locations.locations ->
l2: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Vale.Transformers.BoundedInstructionEffects.sym_difference
l1
l2)
s1
s2)
(ensures
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Vale.Transformers.BoundedInstructionEffects.difference
l1
l2)
s1
s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Vale.Transformers.BoundedInstructionEffects.difference
l2
l1)
s1
s2) | {
"end_col": 75,
"end_line": 959,
"start_col": 2,
"start_line": 959
} |
Prims.Tot | val locations_of_ocmp : o:ocmp -> locations | [
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2) | val locations_of_ocmp : o:ocmp -> locations
let locations_of_ocmp o = | false | null | false | match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 -> (both (locations_of_operand64 o1)) `L.append` (both (locations_of_operand64 o2)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Machine_Semantics_s.ocmp",
"Vale.X64.Machine_s.operand64",
"Prims.b2t",
"Prims.op_Negation",
"Prims.op_BarBar",
"Vale.X64.Machine_s.uu___is_OMem",
"Vale.X64.Machine_s.nat64",
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Machine_s.uu___is_OStack",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand64",
"Vale.Transformers.Locations.locations"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *) | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val locations_of_ocmp : o:ocmp -> locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_ocmp | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Machine_Semantics_s.ocmp -> Vale.Transformers.Locations.locations | {
"end_col": 80,
"end_line": 155,
"start_col": 2,
"start_line": 148
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_ins_st_unchanged_behavior (i: ins{Instr? i}) (s1 s2: machine_state)
: Lemma
(requires
(let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\ (unchanged_at r s1 s2) /\ (run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2 | val lemma_machine_eval_ins_st_unchanged_behavior (i: ins{Instr? i}) (s1 s2: machine_state)
: Lemma
(requires
(let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\ (unchanged_at r s1 s2) /\ (run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2))))
let lemma_machine_eval_ins_st_unchanged_behavior (i: ins{Instr? i}) (s1 s2: machine_state)
: Lemma
(requires
(let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\ (unchanged_at r s1 s2) /\ (run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) = | false | null | true | let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.b2t",
"Vale.X64.Bytes_Code_s.uu___is_Instr",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.Transformers.BoundedInstructionEffects.lemma_eval_instr_unchanged_at'",
"Prims.unit",
"Prims.l_and",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.st",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"Prims.list",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_ins_st_unchanged_behavior (i: ins{Instr? i}) (s1 s2: machine_state)
: Lemma
(requires
(let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\ (unchanged_at r s1 s2) /\ (run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_unchanged_behavior | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Machine_Semantics_s.ins{Instr? i} ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
(let r =
Mkrw_set?.loc_reads (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i)
in
let f = Vale.X64.Machine_Semantics_s.machine_eval_ins_st i in
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at r s1 s2 /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s1) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s2)))
(ensures
(let w =
Mkrw_set?.loc_writes (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i)
in
let f = Vale.X64.Machine_Semantics_s.machine_eval_ins_st i in
Vale.Transformers.BoundedInstructionEffects.unchanged_at w
(Vale.X64.Machine_Semantics_s.run f s1)
(Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 50,
"end_line": 660,
"start_col": 50,
"start_line": 658
} |
Prims.Tot | val aux_read_set1
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs) | val aux_read_set1
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations
let rec aux_read_set1
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations = | false | null | false | match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
(fst (locations_of_explicit i l)) `L.append` (aux_read_set1 outs args r)
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
(both (locations_of_explicit i l)) `L.append` (aux_read_set1 outs args r)
| (Out, IOpIm i) :: outs ->
(fst (locations_of_implicit i))
`L.append`
(aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs))
| (InOut, IOpIm i) :: outs ->
(both (locations_of_implicit i))
`L.append`
(aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set0",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"FStar.Pervasives.Native.fst",
"Vale.Transformers.Locations.locations",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.coerce",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.Transformers.BoundedInstructionEffects.locations_of_implicit"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1 | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aux_read_set1
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.aux_read_set1 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args
-> Vale.Transformers.Locations.locations | {
"end_col": 113,
"end_line": 78,
"start_col": 2,
"start_line": 67
} |
Prims.Tot | val locations_of_maddr (m: maddr) (mem: location) : locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
) | val locations_of_maddr (m: maddr) (mem: location) : locations
let locations_of_maddr (m: maddr) (mem: location) : locations = | false | null | false | mem ::
(match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.maddr",
"Vale.Transformers.Locations.location",
"Prims.Cons",
"Prims.int",
"Prims.Nil",
"Vale.X64.Machine_s.reg",
"Vale.Transformers.Locations.ALocReg",
"Prims.list",
"Vale.Transformers.Locations.locations"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val locations_of_maddr (m: maddr) (mem: location) : locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_maddr | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | m: Vale.X64.Machine_s.maddr -> mem: Vale.Transformers.Locations.location
-> Vale.Transformers.Locations.locations | {
"end_col": 3,
"end_line": 24,
"start_col": 2,
"start_line": 19
} |
FStar.Pervasives.Lemma | val lemma_unchanged_at_mem (as0: list location) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2 | val lemma_unchanged_at_mem (as0: list location) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2)))
let rec lemma_unchanged_at_mem (as0: list location) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2))) = | false | null | true | match as0 with
| [_] -> ()
| x :: xs -> if a = x then () else lemma_unchanged_at_mem xs a s1 s2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Prims.list",
"Vale.Transformers.Locations.location",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.op_Equality",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_mem",
"Prims.unit",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.squash",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures ( | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_at_mem (as0: list location) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_mem | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
as0: Prims.list Vale.Transformers.Locations.location ->
a: Vale.Transformers.Locations.location ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.unchanged_at as0 s1 s2 /\
FStar.List.Tot.Base.mem a as0)
(ensures
Vale.Transformers.Locations.eval_location a s1 ==
Vale.Transformers.Locations.eval_location a s2) | {
"end_col": 37,
"end_line": 938,
"start_col": 2,
"start_line": 934
} |
Prims.Tot | val locations_of_operand128 (o: operand128) : locations & locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | val locations_of_operand128 (o: operand128) : locations & locations
let locations_of_operand128 (o: operand128) : locations & locations = | false | null | false | match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.operand128",
"Vale.X64.Machine_s.quad32",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Transformers.Locations.locations",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Vale.X64.Machine_s.reg_xmm",
"Prims.Cons",
"Vale.Transformers.Locations.ALocReg",
"Vale.X64.Machine_s.Reg",
"Vale.X64.Machine_s.maddr",
"Vale.Arch.HeapTypes_s.taint",
"Vale.Transformers.BoundedInstructionEffects.locations_of_maddr",
"Vale.Transformers.Locations.ALocMem",
"Vale.X64.Machine_s.rRsp",
"Vale.Transformers.Locations.ALocStack",
"FStar.Pervasives.Native.tuple2"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val locations_of_operand128 (o: operand128) : locations & locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_operand128 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Machine_s.operand128
-> Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations | {
"end_col": 90,
"end_line": 38,
"start_col": 2,
"start_line": 34
} |
FStar.Pervasives.Lemma | val lemma_bounded_effects_parallel_aux2 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\ (run f2 s2).ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures
(let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw2.loc_reads s1 s2);
assert (unchanged_at rw2.loc_writes (run f2 s1) (run f2 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw1.loc_writes `difference` rw2.loc_writes) rw2.loc_writes s1 (run f2 s1) s2 (run f2 s2);
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) (run f2 s1) (run f2 s2));
lemma_unchanged_at_difference_elim rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw1.loc_writes (run f2 s1) (run f2 s2)) | val lemma_bounded_effects_parallel_aux2 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\ (run f2 s2).ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures
(let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2))))
let lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2
: Lemma
(requires
(let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\ (run f2 s2).ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures
(let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) = | false | null | true | lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes)
(rw1.loc_reads `L.append` rw2.loc_reads)
s1
s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw2.loc_reads s1 s2);
assert (unchanged_at rw2.loc_writes (run f2 s1) (run f2 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw1.loc_writes `difference` rw2.loc_writes)
rw2.loc_writes
s1
(run f2 s1)
s2
(run f2 s2);
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) (run f2 s1) (run f2 s2));
lemma_unchanged_at_difference_elim rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw1.loc_writes (run f2 s1) (run f2 s2)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims._assert",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_difference_elim",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_maintained",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_sym_diff_implies_difference",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.sym_difference",
"FStar.List.Tot.Base.append",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_at_difference_elim (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at l2 s1 s2))
(ensures (unchanged_at l1 s1 s2)) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1 s2;
lemma_unchanged_at_difference_elim xs l2 s1 s2
) else (
lemma_unchanged_at_difference_elim xs l2 s1 s2
)
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) =
lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2
let rec lemma_disjoint_location_from_locations_not_mem (locs:locations) (l:location) :
Lemma
(ensures (
!!(disjoint_location_from_locations l locs) <==>
not (L.mem l locs))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem xs l
let rec lemma_difference_disjoint (l1 l2:locations) :
Lemma
(ensures (
!!(disjoint_locations (l1 `difference` l2) l2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem l2 x;
lemma_difference_disjoint xs l2
let rec lemma_unchanged_except_to_at_difference (locs locs_change:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except locs_change s1 s2))
(ensures (unchanged_at (locs `difference` locs_change) s1 s2)) =
match locs with
| [] -> ()
| x :: xs ->
lemma_difference_disjoint locs locs_change;
lemma_unchanged_except_to_at_difference xs locs_change s1 s2
let rec lemma_unchanged_at_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(unchanged_at locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at locs_change s1' s2')))
(ensures (
(unchanged_at locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let lemma_bounded_effects_parallel_aux1 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f1 s1).ms_ok /\
(run f1 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f1 s1) (run f1 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw1.loc_reads s1 s2);
assert (unchanged_at rw1.loc_writes (run f1 s1) (run f1 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw2.loc_writes `difference` rw1.loc_writes) rw1.loc_writes s1 (run f1 s1) s2 (run f1 s2);
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) (run f1 s1) (run f1 s2));
lemma_unchanged_at_difference_elim rw2.loc_writes rw1.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw2.loc_writes (run f1 s1) (run f1 s2))
let lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_bounded_effects_parallel_aux2 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\ (run f2 s2).ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures
(let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_parallel_aux2 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
rw1: Vale.Transformers.BoundedInstructionEffects.rw_set ->
rw2: Vale.Transformers.BoundedInstructionEffects.rw_set ->
f1: Vale.X64.Machine_Semantics_s.st Prims.unit ->
f2: Vale.X64.Machine_Semantics_s.st Prims.unit ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
(let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel rw1 rw2 in
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw1 f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw2 f2 /\
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f2 s1) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f2 s2) /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_reads rw) s1 s2))
(ensures
(let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel rw1 rw2 in
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_writes rw)
(Vale.X64.Machine_Semantics_s.run f2 s1)
(Vale.X64.Machine_Semantics_s.run f2 s2))) | {
"end_col": 62,
"end_line": 1058,
"start_col": 2,
"start_line": 1048
} |
Prims.Tot | val write_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : list location | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws | val write_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : list location
let write_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : list location = | false | null | false | let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"Prims.Cons",
"Vale.Transformers.Locations.location",
"Vale.Transformers.Locations.ALocCf",
"Vale.Transformers.Locations.ALocOf",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_set (i: instr_t_record) (oprs: instr_operands_t i.outs i.args) : list location | [] | Vale.Transformers.BoundedInstructionEffects.write_set | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs i) (InstrTypeRecord?.args i)
-> Prims.list Vale.Transformers.Locations.location | {
"end_col": 23,
"end_line": 98,
"start_col": 88,
"start_line": 93
} |
FStar.Pervasives.Lemma | val lemma_bounded_effects_series_aux1 (rw1 rw2 f1 f2 s a: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (let* _ = f1 in
f2)
s)
.ms_ok))
(ensures
(let open Vale.X64.Machine_Semantics_s in
eval_location a s ==
eval_location a
(run (let* _ = f1 in
f2)
s))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s a :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (f1 ;* f2) s).ms_ok))
(ensures (
let open Vale.X64.Machine_Semantics_s in
eval_location a s == eval_location a (run (f1;*f2) s))) =
let open Vale.X64.Machine_Semantics_s in
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw1.loc_writes s (run f1 s));
assert (eval_location a s == eval_location a (run f1 s));
assert (unchanged_except rw2.loc_writes (run f1 s) (run f2 (run f1 s)));
assert (eval_location a s == eval_location a (run (f1;*f2) s)) | val lemma_bounded_effects_series_aux1 (rw1 rw2 f1 f2 s a: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (let* _ = f1 in
f2)
s)
.ms_ok))
(ensures
(let open Vale.X64.Machine_Semantics_s in
eval_location a s ==
eval_location a
(run (let* _ = f1 in
f2)
s)))
let lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s a
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (let* _ = f1 in
f2)
s)
.ms_ok))
(ensures
(let open Vale.X64.Machine_Semantics_s in
eval_location a s ==
eval_location a
(run (let* _ = f1 in
f2)
s))) = | false | null | true | let open Vale.X64.Machine_Semantics_s in
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw1.loc_writes s (run f1 s));
assert (eval_location a s == eval_location a (run f1 s));
assert (unchanged_except rw2.loc_writes (run f1 s) (run f2 (run f1 s)));
assert (eval_location a s ==
eval_location a
(run (let* _ = f1 in
f2)
s)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.location",
"Prims._assert",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.op_let_Star",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_append",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.rw_set_in_series",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_at_difference_elim (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at l2 s1 s2))
(ensures (unchanged_at l1 s1 s2)) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1 s2;
lemma_unchanged_at_difference_elim xs l2 s1 s2
) else (
lemma_unchanged_at_difference_elim xs l2 s1 s2
)
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) =
lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2
let rec lemma_disjoint_location_from_locations_not_mem (locs:locations) (l:location) :
Lemma
(ensures (
!!(disjoint_location_from_locations l locs) <==>
not (L.mem l locs))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem xs l
let rec lemma_difference_disjoint (l1 l2:locations) :
Lemma
(ensures (
!!(disjoint_locations (l1 `difference` l2) l2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem l2 x;
lemma_difference_disjoint xs l2
let rec lemma_unchanged_except_to_at_difference (locs locs_change:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except locs_change s1 s2))
(ensures (unchanged_at (locs `difference` locs_change) s1 s2)) =
match locs with
| [] -> ()
| x :: xs ->
lemma_difference_disjoint locs locs_change;
lemma_unchanged_except_to_at_difference xs locs_change s1 s2
let rec lemma_unchanged_at_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(unchanged_at locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at locs_change s1' s2')))
(ensures (
(unchanged_at locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let lemma_bounded_effects_parallel_aux1 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f1 s1).ms_ok /\
(run f1 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f1 s1) (run f1 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw1.loc_reads s1 s2);
assert (unchanged_at rw1.loc_writes (run f1 s1) (run f1 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw2.loc_writes `difference` rw1.loc_writes) rw1.loc_writes s1 (run f1 s1) s2 (run f1 s2);
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) (run f1 s1) (run f1 s2));
lemma_unchanged_at_difference_elim rw2.loc_writes rw1.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw2.loc_writes (run f1 s1) (run f1 s2))
let lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw2.loc_reads s1 s2);
assert (unchanged_at rw2.loc_writes (run f2 s1) (run f2 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw1.loc_writes `difference` rw2.loc_writes) rw2.loc_writes s1 (run f2 s1) s2 (run f2 s2);
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) (run f2 s1) (run f2 s2));
lemma_unchanged_at_difference_elim rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw1.loc_writes (run f2 s1) (run f2 s2))
(* See fsti *)
let lemma_bounded_effects_parallel rw1 rw2 f1 f2 =
let rw = rw_set_in_parallel rw1 rw2 in
let aux s a :
Lemma
(requires (
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run f1 s).ms_ok))
(ensures (eval_location a s == eval_location a (run f1 s))) =
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw1.loc_writes s (run f1 s)) (* OBSERVE *)
in
let aux s = FStar.Classical.move_requires (aux s) in
FStar.Classical.forall_intro_2 aux;
let aux s a :
Lemma
(requires (
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run f2 s).ms_ok))
(ensures (eval_location a s == eval_location a (run f2 s))) =
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw2.loc_writes s (run f2 s)) (* OBSERVE *)
in
let aux s = FStar.Classical.move_requires (aux s) in
FStar.Classical.forall_intro_2 aux;
assert (only_affects rw.loc_writes f1);
assert (only_affects rw.loc_writes f2);
let rec aux c1 c2 s :
Lemma
(requires (constant_on_execution c1 f1 s /\ constant_on_execution c2 f2 s))
(ensures (constant_on_execution (c1 `intersect` c2) f1 s)) =
match c1 with
| [] -> ()
| x :: xs ->
aux xs c2 s
in
let aux = FStar.Classical.move_requires (aux rw1.loc_constant_writes rw2.loc_constant_writes) in
FStar.Classical.forall_intro aux;
let rec aux c1 c2 s :
Lemma
(requires (constant_on_execution c1 f1 s /\ constant_on_execution c2 f2 s))
(ensures (constant_on_execution (c1 `intersect` c2) f2 s)) =
match c1 with
| [] -> ()
| x :: xs ->
aux xs c2 s;
if (run f2 s).ms_ok && x `L.mem` c2 then (
lemma_constant_on_execution_mem c2 f2 s (dfst x) (dsnd x)
) else ()
in
let aux = FStar.Classical.move_requires (aux rw1.loc_constant_writes rw2.loc_constant_writes) in
FStar.Classical.forall_intro aux;
assert (forall s. constant_on_execution rw.loc_constant_writes f1 s);
assert (forall s. constant_on_execution rw.loc_constant_writes f2 s);
let aux l v :
Lemma
(L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes) =
FStar.Classical.arrow_to_impl #(L.mem (|l,v|) rw.loc_constant_writes) #(L.mem l rw.loc_writes)
(fun _ -> lemma_constant_intersect_belongs_to_writes_union
rw1.loc_constant_writes rw2.loc_constant_writes rw1.loc_writes rw2.loc_writes l v)
in
FStar.Classical.forall_intro_2 aux;
assert (forall l v. L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes);
let aux s1 s2 :
Lemma
(requires (s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures (
((run f1 s1).ms_ok = (run f1 s2).ms_ok) /\
((run f2 s1).ms_ok = (run f2 s2).ms_ok))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 s2 :
Lemma
(requires ((s1.ms_ok = s2.ms_ok) /\
(run f1 s1).ms_ok /\
(run f1 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
(unchanged_at rw.loc_writes (run f1 s1) (run f1 s2)))) =
lemma_bounded_effects_parallel_aux1 rw1 rw2 f1 f2 s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 s2 :
Lemma
(requires ((s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) =
lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
assert (
forall s1 s2. (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f1 s1).ms_ok = (run f1 s2).ms_ok) /\
((run f1 s1).ms_ok ==>
unchanged_at rw.loc_writes (run f1 s1) (run f1 s2))
)
)
);
assert (
forall s1 s2. (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f2 s1).ms_ok = (run f2 s2).ms_ok) /\
((run f2 s1).ms_ok ==>
unchanged_at rw.loc_writes (run f2 s1) (run f2 s2))
)
)
)
let lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s a :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (f1 ;* f2) s).ms_ok))
(ensures (
let open Vale.X64.Machine_Semantics_s in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_bounded_effects_series_aux1 (rw1 rw2 f1 f2 s a: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (let* _ = f1 in
f2)
s)
.ms_ok))
(ensures
(let open Vale.X64.Machine_Semantics_s in
eval_location a s ==
eval_location a
(run (let* _ = f1 in
f2)
s))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux1 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
rw1: Vale.Transformers.BoundedInstructionEffects.rw_set ->
rw2: Vale.Transformers.BoundedInstructionEffects.rw_set ->
f1: Vale.X64.Machine_Semantics_s.st Prims.unit ->
f2: Vale.X64.Machine_Semantics_s.st Prims.unit ->
s: Vale.X64.Machine_Semantics_s.machine_state ->
a: Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(requires
(let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_in_series rw1 rw2 in
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw1 f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw2 f2 /\
!!(Vale.Transformers.Locations.disjoint_location_from_locations a
(Mkrw_set?.loc_writes rw)) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run (( op_let_Star* ) f1
(fun _ -> f2))
s)))
(ensures
Vale.Transformers.Locations.eval_location a s ==
Vale.Transformers.Locations.eval_location a
(Vale.X64.Machine_Semantics_s.run (( op_let_Star* ) f1 (fun _ -> f2)) s)) | {
"end_col": 64,
"end_line": 1198,
"start_col": 2,
"start_line": 1193
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_ins_st_bounded_effects_Instr (i: ins{Instr? i})
: Lemma (ensures ((bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1)) | val lemma_machine_eval_ins_st_bounded_effects_Instr (i: ins{Instr? i})
: Lemma (ensures ((bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i))))
let lemma_machine_eval_ins_st_bounded_effects_Instr (i: ins{Instr? i})
: Lemma (ensures ((bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) = | false | null | true | FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.b2t",
"Vale.X64.Bytes_Code_s.uu___is_Instr",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"FStar.Classical.forall_intro_2",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_imp",
"Prims.l_and",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"FStar.Classical.move_requires",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_unchanged_behavior",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_ok",
"FStar.Classical.forall_intro",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_constant_on_execution",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_only_affects_write",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures ( | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 3,
"initial_ifuel": 1,
"max_fuel": 3,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_ins_st_bounded_effects_Instr (i: ins{Instr? i})
: Lemma (ensures ((bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_bounded_effects_Instr | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Vale.X64.Machine_Semantics_s.ins{Instr? i}
-> FStar.Pervasives.Lemma
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins
i)
(Vale.X64.Machine_Semantics_s.machine_eval_ins_st i)) | {
"end_col": 88,
"end_line": 716,
"start_col": 2,
"start_line": 711
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_code_Ins_bounded_effects_aux1 (i: ins) (fuel: nat) (s: _)
: Lemma (requires (safely_bounded i))
(ensures
(let filt s = { s with ms_trace = [] } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) | val lemma_machine_eval_code_Ins_bounded_effects_aux1 (i: ins) (fuel: nat) (s: _)
: Lemma (requires (safely_bounded i))
(ensures
(let filt s = { s with ms_trace = [] } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i: ins) (fuel: nat) s
: Lemma (requires (safely_bounded i))
(ensures
(let filt s = { s with ms_trace = [] } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) = | false | null | true | let filt s = { s with ms_trace = [] } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes (run (machine_eval_ins_st i) (filt s)) (run f s)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims._assert",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_only_affects_write",
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Machine_Semantics_s.st",
"Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Prims.b2t",
"Vale.Transformers.BoundedInstructionEffects.safely_bounded",
"Prims.squash",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_code_Ins_bounded_effects_aux1 (i: ins) (fuel: nat) (s: _)
: Lemma (requires (safely_bounded i))
(ensures
(let filt s = { s with ms_trace = [] } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects_aux1 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Machine_Semantics_s.ins ->
fuel: Prims.nat ->
s: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma (requires Vale.Transformers.BoundedInstructionEffects.safely_bounded i)
(ensures
(let filt s =
Vale.X64.Machine_Semantics_s.Mkmachine_state (Mkmachine_state?.ms_ok s)
(Mkmachine_state?.ms_regs s)
(Mkmachine_state?.ms_flags s)
(Mkmachine_state?.ms_heap s)
(Mkmachine_state?.ms_stack s)
(Mkmachine_state?.ms_stackTaint s)
[]
in
let f = Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins i fuel in
let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i in
Vale.Transformers.BoundedInstructionEffects.unchanged_except (Mkrw_set?.loc_writes rw)
s
(Vale.X64.Machine_Semantics_s.run f s))) | {
"end_col": 22,
"end_line": 751,
"start_col": 54,
"start_line": 744
} |
Prims.Tot | val aux_read_set0 (args: list instr_operand) (oprs: instr_operands_t_args args) : locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs) | val aux_read_set0 (args: list instr_operand) (oprs: instr_operands_t_args args) : locations
let rec aux_read_set0 (args: list instr_operand) (oprs: instr_operands_t_args args) : locations = | false | null | false | match args with
| [] -> []
| IOpEx i :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
(both (locations_of_explicit i l)) `L.append` (aux_read_set0 args r)
| IOpIm i :: args ->
(both (locations_of_implicit i))
`L.append`
(aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.List.Tot.Base.append",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set0",
"Vale.Transformers.Locations.locations",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.Transformers.BoundedInstructionEffects.locations_of_implicit"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aux_read_set0 (args: list instr_operand) (oprs: instr_operands_t_args args) : locations | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.aux_read_set0 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
oprs: Vale.X64.Instruction_s.instr_operands_t_args args
-> Vale.Transformers.Locations.locations | {
"end_col": 108,
"end_line": 63,
"start_col": 2,
"start_line": 57
} |
FStar.Pervasives.Lemma | val lemma_bounded_effects_series_aux4 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run (let* _ = f1 in
f2)
s1)
.ms_ok /\
(run (let* _ = f1 in
f2)
s2)
.ms_ok /\ (unchanged_at rw.loc_reads s1 s2)))
(ensures
(let open Vale.X64.Machine_Semantics_s in
let f =
let* _ = f1 in
f2
in
let rw = rw_set_in_series rw1 rw2 in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_bounded_effects_series_aux4 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run (f1;*f2) s1).ms_ok /\
(run (f1;*f2) s2).ms_ok /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
let f = f1;*f2 in
let rw = rw_set_in_series rw1 rw2 in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
let f = (f1;*f2) in
let s1_1, s2_1 = run f1 s1, run f1 s2 in
let s1_1_2, s2_1_2 = run f2 s1_1, run f2 s2_1 in
lemma_unchanged_at_append rw1.loc_reads (rw2.loc_reads `difference` rw1.loc_writes) s1 s2;
assert (s1_1.ms_ok /\ s2_1.ms_ok);
assert (s1_1_2.ms_ok /\ s2_1_2.ms_ok);
assert (unchanged_except rw1.loc_writes s1 s1_1);
assert (unchanged_except rw1.loc_writes s2 s2_1);
assert (unchanged_at (rw2.loc_reads `difference` rw1.loc_writes) s1 s2);
lemma_difference_disjoint rw2.loc_reads rw1.loc_writes;
lemma_unchanged_at_except_disjoint (rw2.loc_reads `difference` rw1.loc_writes) rw1.loc_writes s1 s2 s1_1 s2_1;
lemma_unchanged_at_difference_elim rw2.loc_reads rw1.loc_writes s1_1 s2_1;
assert (unchanged_at rw1.loc_writes s1_1 s2_1);
assert (unchanged_except rw2.loc_writes s1_1 s1_1_2);
assert (unchanged_except rw2.loc_writes s2_1 s2_1_2);
assert (unchanged_at rw2.loc_writes s1_1_2 s2_1_2);
lemma_unchanged_at_extend_append rw1.loc_writes rw2.loc_writes s1_1 s2_1 s1_1_2 s2_1_2 | val lemma_bounded_effects_series_aux4 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run (let* _ = f1 in
f2)
s1)
.ms_ok /\
(run (let* _ = f1 in
f2)
s2)
.ms_ok /\ (unchanged_at rw.loc_reads s1 s2)))
(ensures
(let open Vale.X64.Machine_Semantics_s in
let f =
let* _ = f1 in
f2
in
let rw = rw_set_in_series rw1 rw2 in
(unchanged_at rw.loc_writes (run f s1) (run f s2))))
let lemma_bounded_effects_series_aux4 rw1 rw2 f1 f2 s1 s2
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run (let* _ = f1 in
f2)
s1)
.ms_ok /\
(run (let* _ = f1 in
f2)
s2)
.ms_ok /\ (unchanged_at rw.loc_reads s1 s2)))
(ensures
(let open Vale.X64.Machine_Semantics_s in
let f =
let* _ = f1 in
f2
in
let rw = rw_set_in_series rw1 rw2 in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) = | false | null | true | let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
let f =
(let* _ = f1 in
f2)
in
let s1_1, s2_1 = run f1 s1, run f1 s2 in
let s1_1_2, s2_1_2 = run f2 s1_1, run f2 s2_1 in
lemma_unchanged_at_append rw1.loc_reads (rw2.loc_reads `difference` rw1.loc_writes) s1 s2;
assert (s1_1.ms_ok /\ s2_1.ms_ok);
assert (s1_1_2.ms_ok /\ s2_1_2.ms_ok);
assert (unchanged_except rw1.loc_writes s1 s1_1);
assert (unchanged_except rw1.loc_writes s2 s2_1);
assert (unchanged_at (rw2.loc_reads `difference` rw1.loc_writes) s1 s2);
lemma_difference_disjoint rw2.loc_reads rw1.loc_writes;
lemma_unchanged_at_except_disjoint (rw2.loc_reads `difference` rw1.loc_writes)
rw1.loc_writes
s1
s2
s1_1
s2_1;
lemma_unchanged_at_difference_elim rw2.loc_reads rw1.loc_writes s1_1 s2_1;
assert (unchanged_at rw1.loc_writes s1_1 s2_1);
assert (unchanged_except rw2.loc_writes s1_1 s1_1_2);
assert (unchanged_except rw2.loc_writes s2_1 s2_1_2);
assert (unchanged_at rw2.loc_writes s1_1_2 s2_1_2);
lemma_unchanged_at_extend_append rw1.loc_writes rw2.loc_writes s1_1 s2_1 s1_1_2 s2_1_2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_extend_append",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Prims._assert",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_difference_elim",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_except_disjoint",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.lemma_difference_disjoint",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.op_let_Star",
"Vale.Transformers.BoundedInstructionEffects.rw_set_in_series",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects",
"Prims.op_Equality",
"Prims.bool",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_at_difference_elim (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at l2 s1 s2))
(ensures (unchanged_at l1 s1 s2)) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1 s2;
lemma_unchanged_at_difference_elim xs l2 s1 s2
) else (
lemma_unchanged_at_difference_elim xs l2 s1 s2
)
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) =
lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2
let rec lemma_disjoint_location_from_locations_not_mem (locs:locations) (l:location) :
Lemma
(ensures (
!!(disjoint_location_from_locations l locs) <==>
not (L.mem l locs))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem xs l
let rec lemma_difference_disjoint (l1 l2:locations) :
Lemma
(ensures (
!!(disjoint_locations (l1 `difference` l2) l2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem l2 x;
lemma_difference_disjoint xs l2
let rec lemma_unchanged_except_to_at_difference (locs locs_change:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except locs_change s1 s2))
(ensures (unchanged_at (locs `difference` locs_change) s1 s2)) =
match locs with
| [] -> ()
| x :: xs ->
lemma_difference_disjoint locs locs_change;
lemma_unchanged_except_to_at_difference xs locs_change s1 s2
let rec lemma_unchanged_at_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(unchanged_at locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at locs_change s1' s2')))
(ensures (
(unchanged_at locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let lemma_bounded_effects_parallel_aux1 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f1 s1).ms_ok /\
(run f1 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f1 s1) (run f1 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw1.loc_reads s1 s2);
assert (unchanged_at rw1.loc_writes (run f1 s1) (run f1 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw2.loc_writes `difference` rw1.loc_writes) rw1.loc_writes s1 (run f1 s1) s2 (run f1 s2);
assert (unchanged_at (rw2.loc_writes `difference` rw1.loc_writes) (run f1 s1) (run f1 s2));
lemma_unchanged_at_difference_elim rw2.loc_writes rw1.loc_writes (run f1 s1) (run f1 s2);
assert (unchanged_at rw2.loc_writes (run f1 s1) (run f1 s2))
let lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let rw = rw_set_in_parallel rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
let rw = rw_set_in_parallel rw1 rw2 in
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2;
lemma_unchanged_at_append rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw2.loc_reads s1 s2);
assert (unchanged_at rw2.loc_writes (run f2 s1) (run f2 s2));
lemma_unchanged_at_sym_diff_implies_difference rw1.loc_writes rw2.loc_writes s1 s2;
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) s1 s2);
lemma_unchanged_at_maintained (rw1.loc_writes `difference` rw2.loc_writes) rw2.loc_writes s1 (run f2 s1) s2 (run f2 s2);
assert (unchanged_at (rw1.loc_writes `difference` rw2.loc_writes) (run f2 s1) (run f2 s2));
lemma_unchanged_at_difference_elim rw1.loc_writes rw2.loc_writes (run f2 s1) (run f2 s2);
assert (unchanged_at rw1.loc_writes (run f2 s1) (run f2 s2))
(* See fsti *)
let lemma_bounded_effects_parallel rw1 rw2 f1 f2 =
let rw = rw_set_in_parallel rw1 rw2 in
let aux s a :
Lemma
(requires (
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run f1 s).ms_ok))
(ensures (eval_location a s == eval_location a (run f1 s))) =
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw1.loc_writes s (run f1 s)) (* OBSERVE *)
in
let aux s = FStar.Classical.move_requires (aux s) in
FStar.Classical.forall_intro_2 aux;
let aux s a :
Lemma
(requires (
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run f2 s).ms_ok))
(ensures (eval_location a s == eval_location a (run f2 s))) =
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw2.loc_writes s (run f2 s)) (* OBSERVE *)
in
let aux s = FStar.Classical.move_requires (aux s) in
FStar.Classical.forall_intro_2 aux;
assert (only_affects rw.loc_writes f1);
assert (only_affects rw.loc_writes f2);
let rec aux c1 c2 s :
Lemma
(requires (constant_on_execution c1 f1 s /\ constant_on_execution c2 f2 s))
(ensures (constant_on_execution (c1 `intersect` c2) f1 s)) =
match c1 with
| [] -> ()
| x :: xs ->
aux xs c2 s
in
let aux = FStar.Classical.move_requires (aux rw1.loc_constant_writes rw2.loc_constant_writes) in
FStar.Classical.forall_intro aux;
let rec aux c1 c2 s :
Lemma
(requires (constant_on_execution c1 f1 s /\ constant_on_execution c2 f2 s))
(ensures (constant_on_execution (c1 `intersect` c2) f2 s)) =
match c1 with
| [] -> ()
| x :: xs ->
aux xs c2 s;
if (run f2 s).ms_ok && x `L.mem` c2 then (
lemma_constant_on_execution_mem c2 f2 s (dfst x) (dsnd x)
) else ()
in
let aux = FStar.Classical.move_requires (aux rw1.loc_constant_writes rw2.loc_constant_writes) in
FStar.Classical.forall_intro aux;
assert (forall s. constant_on_execution rw.loc_constant_writes f1 s);
assert (forall s. constant_on_execution rw.loc_constant_writes f2 s);
let aux l v :
Lemma
(L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes) =
FStar.Classical.arrow_to_impl #(L.mem (|l,v|) rw.loc_constant_writes) #(L.mem l rw.loc_writes)
(fun _ -> lemma_constant_intersect_belongs_to_writes_union
rw1.loc_constant_writes rw2.loc_constant_writes rw1.loc_writes rw2.loc_writes l v)
in
FStar.Classical.forall_intro_2 aux;
assert (forall l v. L.mem (|l,v|) rw.loc_constant_writes ==> L.mem l rw.loc_writes);
let aux s1 s2 :
Lemma
(requires (s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2))
(ensures (
((run f1 s1).ms_ok = (run f1 s2).ms_ok) /\
((run f2 s1).ms_ok = (run f2 s2).ms_ok))) =
lemma_unchanged_at_append rw1.loc_reads rw2.loc_reads s1 s2;
lemma_unchanged_at_append (sym_difference rw1.loc_writes rw2.loc_writes) (rw1.loc_reads `L.append` rw2.loc_reads) s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 s2 :
Lemma
(requires ((s1.ms_ok = s2.ms_ok) /\
(run f1 s1).ms_ok /\
(run f1 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
(unchanged_at rw.loc_writes (run f1 s1) (run f1 s2)))) =
lemma_bounded_effects_parallel_aux1 rw1 rw2 f1 f2 s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 s2 :
Lemma
(requires ((s1.ms_ok = s2.ms_ok) /\
(run f2 s1).ms_ok /\
(run f2 s2).ms_ok /\
unchanged_at rw.loc_reads s1 s2))
(ensures (
(unchanged_at rw.loc_writes (run f2 s1) (run f2 s2)))) =
lemma_bounded_effects_parallel_aux2 rw1 rw2 f1 f2 s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux;
assert (
forall s1 s2. (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f1 s1).ms_ok = (run f1 s2).ms_ok) /\
((run f1 s1).ms_ok ==>
unchanged_at rw.loc_writes (run f1 s1) (run f1 s2))
)
)
);
assert (
forall s1 s2. (
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2) ==> (
((run f2 s1).ms_ok = (run f2 s2).ms_ok) /\
((run f2 s1).ms_ok ==>
unchanged_at rw.loc_writes (run f2 s1) (run f2 s2))
)
)
)
let lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s a :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
!!(disjoint_location_from_locations a rw.loc_writes) /\
(run (f1 ;* f2) s).ms_ok))
(ensures (
let open Vale.X64.Machine_Semantics_s in
eval_location a s == eval_location a (run (f1;*f2) s))) =
let open Vale.X64.Machine_Semantics_s in
lemma_disjoint_location_from_locations_append a rw1.loc_writes rw2.loc_writes;
assert (unchanged_except rw1.loc_writes s (run f1 s));
assert (eval_location a s == eval_location a (run f1 s));
assert (unchanged_except rw2.loc_writes (run f1 s) (run f2 (run f1 s)));
assert (eval_location a s == eval_location a (run (f1;*f2) s))
#push-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_bounded_effects_series_aux2 c1 c2 f1 f2 s :
Lemma
(requires (
(forall s. {:pattern (constant_on_execution c1 f1 s)} (constant_on_execution c1 f1 s)) /\
(forall s. {:pattern (constant_on_execution c2 f2 s)} (constant_on_execution c2 f2 s))))
(ensures (
let open Vale.X64.Machine_Semantics_s in
(constant_on_execution (c1 `intersect` c2) (f1;*f2) s))) =
let open Vale.X64.Machine_Semantics_s in
let f = f1;*f2 in
if (run f s).ms_ok then (
match c1 with
| [] -> ()
| (|l,v|) :: xs ->
if L.mem (|l,v|) c2 then (
lemma_constant_on_execution_mem c2 f2 (run f1 s) l v
) else ();
assert (forall s. constant_on_execution c1 f1 s ==> constant_on_execution xs f1 s); (* OBSERVE *)
lemma_bounded_effects_series_aux2 xs c2 f1 f2 s
) else ()
#pop-options
let rec lemma_unchanged_at_except_disjoint (same change:locations) (s1 s2 s1' s2':machine_state) :
Lemma
(requires (
(unchanged_at same s1 s2) /\
(unchanged_except change s1 s1') /\
(unchanged_except change s2 s2') /\
!!(disjoint_locations same change)))
(ensures (
(unchanged_at same s1' s2'))) =
match same with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_except_disjoint xs change s1 s2 s1' s2'
let lemma_bounded_effects_series_aux3 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
let f = f1;*f2 in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
let f = (f1;*f2) in
let s1_1, s2_1 = run f1 s1, run f1 s2 in
let s1_1_2, s2_1_2 = run f2 s1_1, run f2 s2_1 in
lemma_unchanged_at_append rw1.loc_reads (rw2.loc_reads `difference` rw1.loc_writes) s1 s2;
assert (s1_1.ms_ok = s2_1.ms_ok);
if s1_1.ms_ok then (
assert (only_affects rw1.loc_writes f1);
assert (unchanged_except rw1.loc_writes s1 s1_1);
assert (unchanged_except rw1.loc_writes s2 s2_1);
assert (unchanged_at (rw2.loc_reads `difference` rw1.loc_writes) s1 s2);
lemma_difference_disjoint rw2.loc_reads rw1.loc_writes;
lemma_unchanged_at_except_disjoint (rw2.loc_reads `difference` rw1.loc_writes) rw1.loc_writes s1 s2 s1_1 s2_1;
lemma_unchanged_at_difference_elim rw2.loc_reads rw1.loc_writes s1_1 s2_1
) else ()
let rec lemma_unchanged_at_extend_append (l1 l2:locations) (s1 s2 s1' s2':machine_state):
Lemma
(requires (
(unchanged_at l1 s1 s2) /\
(unchanged_except l2 s1 s1') /\
(unchanged_except l2 s2 s2') /\
(unchanged_at l2 s1' s2')))
(ensures (
(unchanged_at (l1 `L.append` l2) s1' s2'))) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1' s2'
) else (
lemma_unchanged_except_not_mem l2 x
);
lemma_unchanged_at_extend_append xs l2 s1 s2 s1' s2'
let lemma_bounded_effects_series_aux4 rw1 rw2 f1 f2 s1 s2 :
Lemma
(requires (
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2) /\
(s1.ms_ok = s2.ms_ok) /\
(run (f1;*f2) s1).ms_ok /\
(run (f1;*f2) s2).ms_ok /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
let f = f1;*f2 in
let rw = rw_set_in_series rw1 rw2 in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_bounded_effects_series_aux4 (rw1 rw2 f1 f2 s1 s2: _)
: Lemma
(requires
(let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
(bounded_effects rw1 f1) /\ (bounded_effects rw2 f2) /\ (s1.ms_ok = s2.ms_ok) /\
(run (let* _ = f1 in
f2)
s1)
.ms_ok /\
(run (let* _ = f1 in
f2)
s2)
.ms_ok /\ (unchanged_at rw.loc_reads s1 s2)))
(ensures
(let open Vale.X64.Machine_Semantics_s in
let f =
let* _ = f1 in
f2
in
let rw = rw_set_in_series rw1 rw2 in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux4 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
rw1: Vale.Transformers.BoundedInstructionEffects.rw_set ->
rw2: Vale.Transformers.BoundedInstructionEffects.rw_set ->
f1: Vale.X64.Machine_Semantics_s.st Prims.unit ->
f2: Vale.X64.Machine_Semantics_s.st Prims.unit ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
(let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_in_series rw1 rw2 in
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw1 f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw2 f2 /\
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run (( op_let_Star* ) f1
(fun _ -> f2))
s1) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run (( op_let_Star* ) f1
(fun _ -> f2))
s2) /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_reads rw) s1 s2))
(ensures
(let f = ( op_let_Star* ) f1 (fun _ -> f2) in
let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_in_series rw1 rw2 in
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_writes rw)
(Vale.X64.Machine_Semantics_s.run f s1)
(Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 88,
"end_line": 1320,
"start_col": 2,
"start_line": 1302
} |
FStar.Pervasives.Lemma | val lemma_unchanged_at'_mem (as0: locations) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at' as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2 | val lemma_unchanged_at'_mem (as0: locations) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at' as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2 \/ not s1.ms_ok)))
let rec lemma_unchanged_at'_mem (as0: locations) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at' as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) = | false | null | true | match as0 with
| [_] -> ()
| x :: xs -> if a = x then () else lemma_unchanged_at'_mem xs a s1 s2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.Transformers.Locations.location",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.list",
"Prims.op_Equality",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_mem",
"Prims.unit",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at'",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.squash",
"Prims.l_or",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Prims.op_Negation",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures ( | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_at'_mem (as0: locations) (a: location) (s1 s2: machine_state)
: Lemma (requires ((unchanged_at' as0 s1 s2) /\ (L.mem a as0)))
(ensures ((eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_mem | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
as0: Vale.Transformers.Locations.locations ->
a: Vale.Transformers.Locations.location ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.unchanged_at' as0 s1 s2 /\
FStar.List.Tot.Base.mem a as0)
(ensures
Vale.Transformers.Locations.eval_location a s1 ==
Vale.Transformers.Locations.eval_location a s2 \/
Prims.op_Negation (Mkmachine_state?.ms_ok s1)) | {
"end_col": 38,
"end_line": 414,
"start_col": 2,
"start_line": 410
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_code_Ins_bounded_effects_aux4 (i: ins) (fuel: nat) (s1 s2: _)
: Lemma
(requires
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\ (s1.ms_ok = s2.ms_ok) /\ (unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace | val lemma_machine_eval_code_Ins_bounded_effects_aux4 (i: ins) (fuel: nat) (s1 s2: _)
: Lemma
(requires
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\ (s1.ms_ok = s2.ms_ok) /\ (unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2))))
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i: ins) (fuel: nat) s1 s2
: Lemma
(requires
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\ (s1.ms_ok = s2.ms_ok) /\ (unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) = | false | null | true | let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes
(machine_eval_ins i (filt s1))
(machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace
(intr s2 s2).ms_trace | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_trace",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.X64.Machine_Semantics_s.machine_eval_ins",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_unchanged_behavior",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Prims.Nil",
"Vale.X64.Machine_s.observation",
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Machine_Semantics_s.st",
"Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"FStar.List.Tot.Base.append",
"Vale.X64.Machine_Semantics_s.ins_obs",
"Prims.l_and",
"Prims.b2t",
"Vale.Transformers.BoundedInstructionEffects.safely_bounded",
"Prims.op_Equality",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.X64.Machine_Semantics_s.run",
"Prims.squash",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_code_Ins_bounded_effects_aux4 (i: ins) (fuel: nat) (s1 s2: _)
: Lemma
(requires
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\ (s1.ms_ok = s2.ms_ok) /\ (unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\ (run f s2).ms_ok))
(ensures
(let f:st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects_aux4 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Machine_Semantics_s.ins ->
fuel: Prims.nat ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
(let f = Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins i fuel in
let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i in
Vale.Transformers.BoundedInstructionEffects.safely_bounded i /\
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_reads rw) s1 s2 /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s1) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s2)))
(ensures
(let f = Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins i fuel in
let rw = Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i in
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_writes rw)
(Vale.X64.Machine_Semantics_s.run f s1)
(Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 47,
"end_line": 815,
"start_col": 62,
"start_line": 807
} |
FStar.Pervasives.Lemma | val lemma_add_r_to_rw_set :
r:locations ->
rw:rw_set ->
f:st unit ->
Lemma
(requires (
(bounded_effects rw f)))
(ensures (
(bounded_effects (add_r_to_rw_set r rw) f))) | [
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux | val lemma_add_r_to_rw_set :
r:locations ->
rw:rw_set ->
f:st unit ->
Lemma
(requires (
(bounded_effects rw f)))
(ensures (
(bounded_effects (add_r_to_rw_set r rw) f)))
let lemma_add_r_to_rw_set r rw_old f = | false | null | true | let rw = add_r_to_rw_set r rw_old in
let aux s1 s2
: Lemma
(requires
((bounded_effects rw_old f) /\ (s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures
(((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==> unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.Transformers.BoundedInstructionEffects.rw_set",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_imp",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"FStar.Pervasives.Native.snd",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Classical.move_requires",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.add_r_to_rw_set"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_add_r_to_rw_set :
r:locations ->
rw:rw_set ->
f:st unit ->
Lemma
(requires (
(bounded_effects rw f)))
(ensures (
(bounded_effects (add_r_to_rw_set r rw) f))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_add_r_to_rw_set | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
r: Vale.Transformers.Locations.locations ->
rw: Vale.Transformers.BoundedInstructionEffects.rw_set ->
f: Vale.X64.Machine_Semantics_s.st Prims.unit
-> FStar.Pervasives.Lemma
(requires Vale.Transformers.BoundedInstructionEffects.bounded_effects rw f)
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.add_r_to_rw_set
r
rw)
f) | {
"end_col": 36,
"end_line": 901,
"start_col": 38,
"start_line": 887
} |
FStar.Pervasives.Lemma | val lemma_machine_eval_code_Ins_bounded_effects :
(i:ins) ->
(fuel:nat) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))))) | [
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel | val lemma_machine_eval_code_Ins_bounded_effects :
(i:ins) ->
(fuel:nat) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s))))))
let lemma_machine_eval_code_Ins_bounded_effects i fuel = | false | null | true | lemma_machine_eval_code_Ins_bounded_effects_aux i fuel | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.nat",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects_aux",
"Prims.unit"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_machine_eval_code_Ins_bounded_effects :
(i:ins) ->
(fuel:nat) ->
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Vale.X64.Machine_Semantics_s.ins -> fuel: Prims.nat
-> FStar.Pervasives.Lemma (requires Vale.Transformers.BoundedInstructionEffects.safely_bounded i)
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins
i)
(fun s -> (), Some?.v (Vale.X64.Machine_Semantics_s.machine_eval_code_ins_def i s))) | {
"end_col": 56,
"end_line": 837,
"start_col": 2,
"start_line": 837
} |
Prims.Tot | val locations_of_explicit (t: instr_operand_explicit) (i: instr_operand_t t) : locations & locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i | val locations_of_explicit (t: instr_operand_explicit) (i: instr_operand_t t) : locations & locations
let locations_of_explicit (t: instr_operand_explicit) (i: instr_operand_t t) : locations & locations = | false | null | false | match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand64",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand128",
"FStar.Pervasives.Native.tuple2",
"Vale.Transformers.Locations.locations"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val locations_of_explicit (t: instr_operand_explicit) (i: instr_operand_t t) : locations & locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_explicit | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.X64.Instruction_s.instr_operand_explicit -> i: Vale.X64.Instruction_s.instr_operand_t t
-> Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations | {
"end_col": 39,
"end_line": 43,
"start_col": 2,
"start_line": 41
} |
Prims.Tot | val rw_set_of_ins : i:ins -> rw_set | [
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
} | val rw_set_of_ins : i:ins -> rw_set
let rw_set_of_ins i = | false | null | false | match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = []
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = []
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = []
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = []
} | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Vale.X64.Machine_Semantics_s.instr_annotation",
"Vale.Transformers.BoundedInstructionEffects.Mkrw_set",
"Vale.Transformers.BoundedInstructionEffects.read_set",
"Vale.Transformers.BoundedInstructionEffects.write_set",
"Vale.Transformers.BoundedInstructionEffects.constant_writes",
"Vale.X64.Machine_s.operand64",
"Vale.Arch.HeapTypes_s.taint",
"Prims.Cons",
"Vale.Transformers.Locations.location",
"Vale.Transformers.Locations.ALocReg",
"Vale.X64.Machine_s.Reg",
"Vale.X64.Machine_s.rRsp",
"Vale.Transformers.Locations.ALocStack",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand64",
"Prims.Nil",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"FStar.Pervasives.Native.fst",
"Vale.Transformers.Locations.locations",
"FStar.Pervasives.Native.snd",
"Vale.X64.Machine_s.nat64",
"Vale.Transformers.BoundedInstructionEffects.rw_set"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *) | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rw_set_of_ins : i:ins -> rw_set | [] | Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Vale.X64.Machine_Semantics_s.ins -> Vale.Transformers.BoundedInstructionEffects.rw_set | {
"end_col": 5,
"end_line": 144,
"start_col": 2,
"start_line": 114
} |
Prims.Tot | val difference (#t: eqtype) (l1 l2: list t) : list t | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2 | val difference (#t: eqtype) (l1 l2: list t) : list t
let rec difference (#t: eqtype) (l1 l2: list t) : list t = | false | null | false | match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Prims.eqtype",
"Prims.list",
"Prims.Nil",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Prims.bool",
"Prims.Cons"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2 | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val difference (#t: eqtype) (l1 l2: list t) : list t | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.difference | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l1: Prims.list t -> l2: Prims.list t -> Prims.list t | {
"end_col": 77,
"end_line": 852,
"start_col": 2,
"start_line": 850
} |
Prims.Tot | val locations_of_operand64 (o: operand64) : locations & locations | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | val locations_of_operand64 (o: operand64) : locations & locations
let locations_of_operand64 (o: operand64) : locations & locations = | false | null | false | match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack] | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.operand64",
"Vale.X64.Machine_s.nat64",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Transformers.Locations.locations",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Vale.X64.Machine_s.reg_64",
"Prims.Cons",
"Vale.Transformers.Locations.ALocReg",
"Vale.X64.Machine_s.Reg",
"Vale.X64.Machine_s.maddr",
"Vale.Arch.HeapTypes_s.taint",
"Vale.Transformers.BoundedInstructionEffects.locations_of_maddr",
"Vale.Transformers.Locations.ALocMem",
"Vale.X64.Machine_s.rRsp",
"Vale.Transformers.Locations.ALocStack",
"FStar.Pervasives.Native.tuple2"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
) | false | true | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val locations_of_operand64 (o: operand64) : locations & locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_operand64 | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | o: Vale.X64.Machine_s.operand64
-> Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations | {
"end_col": 90,
"end_line": 31,
"start_col": 2,
"start_line": 27
} |
Prims.Tot | val constant_writes (i: instr_t_record) (oprs: instr_operands_t i.outs i.args)
: locations_with_values | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> [] | val constant_writes (i: instr_t_record) (oprs: instr_operands_t i.outs i.args)
: locations_with_values
let constant_writes (i: instr_t_record) (oprs: instr_operands_t i.outs i.args)
: locations_with_values = | false | null | false | let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags ->
(let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr)
| PreserveFlags -> [] | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"total"
] | [
"Vale.X64.Instruction_s.instr_t_record",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs",
"Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args",
"Prims.list",
"Vale.X64.Instruction_s.instr_out",
"Vale.X64.Instruction_s.instr_operand",
"Vale.X64.Instruction_s.flag_havoc",
"Vale.X64.Instruction_s.instr_t",
"Vale.Transformers.BoundedInstructionEffects.locations_with_values",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.Locations.location",
"Vale.Transformers.Locations.ALocOf",
"Prims.bool",
"Prims.Cons",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.Mkdtuple2",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.Locations.location_val_eqt",
"FStar.Pervasives.Native.None",
"Vale.Transformers.Locations.ALocCf",
"Prims.Nil",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val constant_writes (i: instr_t_record) (oprs: instr_operands_t i.outs i.args)
: locations_with_values | [] | Vale.Transformers.BoundedInstructionEffects.constant_writes | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs i) (InstrTypeRecord?.args i)
-> Vale.Transformers.BoundedInstructionEffects.locations_with_values | {
"end_col": 23,
"end_line": 110,
"start_col": 102,
"start_line": 100
} |
FStar.Pervasives.Lemma | val lemma_unchanged_at_trace (locs: locations) (s1 s2: machine_state) (trace1 trace2: _)
: Lemma (requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({ s1 with ms_trace = trace1 }) ({ s2 with ms_trace = trace2 }))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2 | val lemma_unchanged_at_trace (locs: locations) (s1 s2: machine_state) (trace1 trace2: _)
: Lemma (requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({ s1 with ms_trace = trace1 }) ({ s2 with ms_trace = trace2 })))
let rec lemma_unchanged_at_trace
(locs: locations)
(s1: machine_state)
(s2: machine_state)
trace1
trace2
: Lemma (requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({ s1 with ms_trace = trace1 }) ({ s2 with ms_trace = trace2 }))) = | false | null | true | match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at_trace xs s1 s2 trace1 trace2 | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.list",
"Vale.X64.Machine_s.observation",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_trace",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Prims.squash",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2)) | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_at_trace (locs: locations) (s1 s2: machine_state) (trace1 trace2: _)
: Lemma (requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({ s1 with ms_trace = trace1 }) ({ s2 with ms_trace = trace2 }))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_trace | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
locs: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state ->
trace1: Prims.list Vale.X64.Machine_s.observation ->
trace2: Prims.list Vale.X64.Machine_s.observation
-> FStar.Pervasives.Lemma
(requires Vale.Transformers.BoundedInstructionEffects.unchanged_at locs s1 s2)
(ensures
Vale.Transformers.BoundedInstructionEffects.unchanged_at locs
(Vale.X64.Machine_Semantics_s.Mkmachine_state (Mkmachine_state?.ms_ok s1)
(Mkmachine_state?.ms_regs s1)
(Mkmachine_state?.ms_flags s1)
(Mkmachine_state?.ms_heap s1)
(Mkmachine_state?.ms_stack s1)
(Mkmachine_state?.ms_stackTaint s1)
trace1)
(Vale.X64.Machine_Semantics_s.Mkmachine_state (Mkmachine_state?.ms_ok s2)
(Mkmachine_state?.ms_regs s2)
(Mkmachine_state?.ms_flags s2)
(Mkmachine_state?.ms_heap s2)
(Mkmachine_state?.ms_stack s2)
(Mkmachine_state?.ms_stackTaint s2)
trace2)) | {
"end_col": 51,
"end_line": 732,
"start_col": 2,
"start_line": 729
} |
FStar.Pervasives.Lemma | val lemma_unchanged_at_maintained (locs locs_change: locations) (s1 s1' s2 s2': machine_state)
: Lemma
(requires
((unchanged_at locs s1 s2) /\ (unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\ (unchanged_at locs_change s1' s2')))
(ensures ((unchanged_at locs s1' s2'))) | [
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Print_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instructions_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Instruction_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Vale.Transformers.Locations",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.PossiblyMonad",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Bytes_Code_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Transformers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec lemma_unchanged_at_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(unchanged_at locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at locs_change s1' s2')))
(ensures (
(unchanged_at locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
) | val lemma_unchanged_at_maintained (locs locs_change: locations) (s1 s1' s2 s2': machine_state)
: Lemma
(requires
((unchanged_at locs s1 s2) /\ (unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\ (unchanged_at locs_change s1' s2')))
(ensures ((unchanged_at locs s1' s2')))
let rec lemma_unchanged_at_maintained (locs locs_change: locations) (s1 s1' s2 s2': machine_state)
: Lemma
(requires
((unchanged_at locs s1 s2) /\ (unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\ (unchanged_at locs_change s1' s2')))
(ensures ((unchanged_at locs s1' s2'))) = | false | null | true | match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change
then (lemma_unchanged_at_mem locs_change x s1' s2')
else (lemma_unchanged_except_not_mem locs_change x) | {
"checked_file": "Vale.Transformers.BoundedInstructionEffects.fst.checked",
"dependencies": [
"Vale.X64.Print_s.fst.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Instructions_s.fsti.checked",
"Vale.X64.Instruction_s.fsti.checked",
"Vale.X64.Bytes_Code_s.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Transformers.Locations.fst.checked",
"Vale.Def.PossiblyMonad.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Option.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.Transformers.BoundedInstructionEffects.fst"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.location",
"Prims.list",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_mem",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_mem",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_maintained",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Transformers.BoundedInstructionEffects
open Vale.X64.Bytes_Code_s
open Vale.X64.Instruction_s
open Vale.X64.Instructions_s
open Vale.X64.Machine_Semantics_s
open Vale.X64.Machine_s
open Vale.X64.Print_s
open Vale.Def.PossiblyMonad
open Vale.Transformers.Locations
friend Vale.Transformers.Locations
module L = FStar.List.Tot
let locations_of_maddr (m:maddr) (mem:location) : locations =
mem :: (
match m with
| MConst _ -> []
| MReg r _ -> [ALocReg r]
| MIndex b _ i _ -> [ALocReg b; ALocReg i]
)
let locations_of_operand64 (o:operand64) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 0 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_operand128 (o:operand128) : locations & locations =
match o with
| OConst _ -> [], []
| OReg r -> [], [ALocReg (Reg 1 r)]
| OMem (m, _) -> locations_of_maddr m ALocMem, [ALocMem]
| OStack (m, _) -> (ALocReg (Reg 0 rRsp)) :: locations_of_maddr m ALocStack, [ALocStack]
let locations_of_explicit (t:instr_operand_explicit) (i:instr_operand_t t) : locations & locations =
match t with
| IOp64 -> locations_of_operand64 i
| IOpXmm -> locations_of_operand128 i
let locations_of_implicit (t:instr_operand_implicit) : locations & locations =
match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf]
let both (x: locations & locations) =
let a, b = x in
a `L.append` b
let rec aux_read_set0 (args:list instr_operand) (oprs:instr_operands_t_args args) : locations =
match args with
| [] -> []
| (IOpEx i) :: args ->
let l, r = coerce #(instr_operand_t i & instr_operands_t_args args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set0 args r
| (IOpIm i) :: args ->
both (locations_of_implicit i) `L.append` aux_read_set0 args (coerce #(instr_operands_t_args args) oprs)
let rec aux_read_set1
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> aux_read_set0 args oprs
| (Out, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
fst (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (InOut, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
both (locations_of_explicit i l) `L.append` aux_read_set1 outs args r
| (Out, IOpIm i) :: outs ->
fst (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
| (InOut, IOpIm i) :: outs ->
both (locations_of_implicit i) `L.append` aux_read_set1 outs args (coerce #(instr_operands_t outs args) oprs)
let read_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations =
aux_read_set1 i.outs i.args oprs
let rec aux_write_set
(outs:list instr_out) (args:list instr_operand) (oprs:instr_operands_t outs args) : locations =
match outs with
| [] -> []
| (_, IOpEx i) :: outs ->
let l, r = coerce #(instr_operand_t i & instr_operands_t outs args) oprs in
snd (locations_of_explicit i l) `L.append` aux_write_set outs args r
| (_, IOpIm i) :: outs ->
snd (locations_of_implicit i) `L.append` aux_write_set outs args (coerce #(instr_operands_t outs args) oprs)
let write_set (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : list location =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
let ws = aux_write_set outs args oprs in
match havoc_flags with
| HavocFlags -> ALocCf :: ALocOf :: ws
| PreserveFlags -> ws
let constant_writes (i:instr_t_record) (oprs:instr_operands_t i.outs i.args) : locations_with_values =
let InstrTypeRecord #outs #args #havoc_flags _ = i in
match havoc_flags with
| HavocFlags -> (
let ws = aux_write_set outs args oprs in
let cr = [] in
let cr = if L.mem ALocCf ws then cr else (| ALocCf, None |) :: cr in
let cr = if L.mem ALocOf ws then cr else (| ALocOf, None |) :: cr in
cr
)
| PreserveFlags -> []
(* See fsti *)
let rw_set_of_ins i =
match i with
| Instr i oprs _ ->
{
loc_reads = read_set i oprs;
loc_writes = write_set i oprs;
loc_constant_writes = constant_writes i oprs;
}
| Push src t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: both (locations_of_operand64 src);
loc_writes = [ALocReg (Reg 0 rRsp); ALocStack];
loc_constant_writes = [];
}
| Pop dst t ->
{
loc_reads = ALocReg (Reg 0 rRsp) :: ALocStack :: fst (locations_of_operand64 dst);
loc_writes = ALocReg (Reg 0 rRsp) :: snd (locations_of_operand64 dst);
loc_constant_writes = [];
}
| Alloc _ ->
{
loc_reads = [ALocReg (Reg 0 rRsp)];
loc_writes = [ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
| Dealloc _ ->
{
loc_reads = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_writes = [ALocStack; ALocReg (Reg 0 rRsp)];
loc_constant_writes = [];
}
(* See fsti *)
let locations_of_ocmp o =
match o with
| OEq o1 o2
| ONe o1 o2
| OLe o1 o2
| OGe o1 o2
| OLt o1 o2
| OGt o1 o2 ->
both (locations_of_operand64 o1) `L.append` both (locations_of_operand64 o2)
#push-options "--z3rlimit 50 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
#restart-solver
let rec lemma_instr_write_outputs_only_affects_write
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
(a:location) :
Lemma
(requires (
let w = aux_write_set outs args oprs in
!!(disjoint_location_from_locations a w)))
(ensures (
(eval_location a s == eval_location a (instr_write_outputs outs args vs oprs s_orig s)))) =
match outs with
| [] -> ()
| (_, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let oprs = coerce oprs in
let s = instr_write_output_explicit i v (fst oprs) s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (snd oprs) s_orig s a
| IOpIm i ->
let s = instr_write_output_implicit i v s_orig s in
lemma_instr_write_outputs_only_affects_write outs args vs (coerce oprs) s_orig s a
)
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_only_affects_write
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s0:machine_state)
(a:location) :
Lemma
(requires (
(let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
!!(disjoint_location_from_locations a w) /\
(Some? (eval_instr it oprs ann s0)))))
(ensures (
(eval_location a s0 == eval_location a (Some?.v (eval_instr it oprs ann s0))))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
let Some vs = vs in
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 a
#pop-options
let lemma_machine_eval_ins_st_only_affects_write_aux (i:ins{Instr? i}) (s:machine_state) (a:location) :
Lemma
(requires (
let w = (rw_set_of_ins i).loc_writes in
(!!(disjoint_location_from_locations a w))))
(ensures (
(eval_location a s == eval_location a (run (machine_eval_ins_st i) s)))) =
let Instr it oprs ann = i in
match eval_instr it oprs ann s with
| Some _ -> lemma_eval_instr_only_affects_write it oprs ann s a
| None -> ()
let lemma_machine_eval_ins_st_only_affects_write (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (
(let w = (rw_set_of_ins i).loc_writes in
(unchanged_except w s (run (machine_eval_ins_st i) s))))) =
FStar.Classical.forall_intro (
FStar.Classical.move_requires (lemma_machine_eval_ins_st_only_affects_write_aux i s))
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_explicit_same_read_both
(i:instr_operand_explicit) (o:instr_operand_t i)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_explicit i o)) s1 s2)))
(ensures (
(instr_eval_operand_explicit i o s1) ==
(instr_eval_operand_explicit i o s2))) = ()
#pop-options
#push-options "--initial_fuel 4 --max_fuel 4 --initial_ifuel 2 --max_ifuel 2"
let lemma_instr_eval_operand_implicit_same_read_both
(i:instr_operand_implicit)
(s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at (both (locations_of_implicit i)) s1 s2)))
(ensures (
(instr_eval_operand_implicit i s1) ==
(instr_eval_operand_implicit i s2))) = ()
#pop-options
let rec lemma_unchanged_at_append (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(ensures (
(unchanged_at (l1 `L.append` l2) s1 s2) <==>
(unchanged_at l1 s1 s2 /\ unchanged_at l2 s1 s2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_append xs l2 s1 s2
let rec lemma_instr_apply_eval_args_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_args_t outs args) (oprs:instr_operands_t_args args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set0 args oprs) s1 s2))
(ensures (
(instr_apply_eval_args outs args f oprs s1) ==
(instr_apply_eval_args outs args f oprs s2))) =
match args with
| [] -> ()
| i :: args ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t_args args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set0 args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_implicit i)) (aux_read_set0 args oprs) s1 s2;
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_args outs args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_args outs args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_args_same_read outs args (f v) oprs s1 s2
#push-options "--z3rlimit 25 --initial_fuel 6 --max_fuel 6 --initial_ifuel 2 --max_ifuel 2"
let rec lemma_instr_apply_eval_inouts_same_read
(outs inouts:list instr_out) (args:list instr_operand)
(f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 inouts args oprs) s1 s2))
(ensures (
(instr_apply_eval_inouts outs inouts args f oprs s1) ==
(instr_apply_eval_inouts outs inouts args f oprs s2))) =
match inouts with
| [] ->
lemma_instr_apply_eval_args_same_read outs args f oprs s1 s2
| (Out, i)::inouts ->
let oprs =
match i with
| IOpEx i -> snd #(instr_operand_t i) (coerce oprs)
| IOpIm i -> coerce oprs
in
lemma_instr_apply_eval_inouts_same_read outs inouts args (coerce f) oprs s1 s2
| (InOut, i)::inouts ->
let (v1, v2, oprs) : option _ & option _ & instr_operands_t inouts args =
match i with
| IOpEx i ->
let oprs = coerce oprs in
lemma_unchanged_at_append (both (locations_of_explicit i (fst oprs))) (aux_read_set1 inouts args (snd oprs)) s1 s2;
lemma_instr_eval_operand_explicit_same_read_both i (fst oprs) s1 s2;
(instr_eval_operand_explicit i (fst oprs) s1,
instr_eval_operand_explicit i (fst oprs) s2,
snd oprs)
| IOpIm i ->
lemma_instr_eval_operand_implicit_same_read_both i s1 s2;
(instr_eval_operand_implicit i s1,
instr_eval_operand_implicit i s2,
coerce oprs)
in
assert (v1 == v2);
let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in
let _ = bind_option v1 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s1) in
let _ = bind_option v2 (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s2) in
match v1 with
| None -> ()
| Some v ->
lemma_instr_apply_eval_inouts_same_read outs inouts args (f v) oprs s1 s2
#pop-options
let lemma_instr_apply_eval_same_read
(outs:list instr_out) (args:list instr_operand)
(f:instr_eval_t outs args) (oprs:instr_operands_t outs args)
(s1 s2:machine_state) :
Lemma
(requires (unchanged_at (aux_read_set1 outs args oprs) s1 s2))
(ensures (
(instr_apply_eval outs args f oprs s1) ==
(instr_apply_eval outs args f oprs s2))) =
lemma_instr_apply_eval_inouts_same_read outs outs args f oprs s1 s2
let unchanged_at' (l:locations) (s1 s2:machine_state) =
(s1.ms_ok = s2.ms_ok) /\
(s1.ms_ok /\ s2.ms_ok ==>
unchanged_at l s1 s2)
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 3 --max_ifuel 3"
let lemma_instr_write_output_explicit_only_writes
(i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_explicit i o)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_explicit i o)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_explicit i v o s_orig1 s1,
instr_write_output_explicit i v o s_orig2 s2 in
let locs = snd (locations_of_explicit i o) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--z3rlimit 20 --initial_fuel 4 --max_fuel 4 --initial_ifuel 4 --max_ifuel 4"
let lemma_instr_write_output_implicit_only_writes
(i:instr_operand_implicit) (v:instr_val_t (IOpIm i))
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (fst (locations_of_implicit i)) s_orig1 s_orig2) /\
(unchanged_at' (fst (locations_of_implicit i)) s1 s2)))
(ensures (
let s1', s2' =
instr_write_output_implicit i v s_orig1 s1,
instr_write_output_implicit i v s_orig2 s2 in
let locs = snd (locations_of_implicit i) in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2'))) = ()
#pop-options
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at'_mem (as0:locations) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at' as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2 \/ not s1.ms_ok))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at'_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_except_not_mem (as0:locations) (a:location) :
Lemma
(requires (
(not (L.mem a as0))))
(ensures (
!!(disjoint_location_from_locations a as0))) =
match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a
let rec lemma_unchanged_at'_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok) /\
(unchanged_at' locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at' locs_change s1' s2')))
(ensures (
(unchanged_at' locs s1' s2'))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at'_maintained xs locs_change s1 s1' s2 s2';
if x `L.mem` locs_change then (
lemma_unchanged_at'_mem locs_change x s1' s2'
) else (
lemma_unchanged_except_not_mem locs_change x
)
let rec lemma_disjoint_location_from_locations_append
(a:location) (as1 as2:list location) :
Lemma (
(!!(disjoint_location_from_locations a as1) /\
!!(disjoint_location_from_locations a as2)) <==>
(!!(disjoint_location_from_locations a (as1 `L.append` as2)))) =
match as1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_append a xs as2
let lemma_unchanged_except_extend (ls_extend ls:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except ls s1 s2))
(ensures (unchanged_except (ls_extend `L.append` ls) s1 s2)) =
let aux a :
Lemma
(requires (!!(disjoint_location_from_locations a (ls_extend `L.append` ls))))
(ensures (eval_location a s1 == eval_location a s2)) =
lemma_disjoint_location_from_locations_append a ls_extend ls
in
FStar.Classical.forall_intro (FStar.Classical.move_requires aux)
let lemma_instr_write_outputs_only_affects_write_extend
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig s:machine_state)
(locs_extension:locations) :
Lemma
(ensures (
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
unchanged_except (locs_extension `L.append` locs) s s')) =
let s' = instr_write_outputs outs args vs oprs s_orig s in
let locs = aux_write_set outs args oprs in
FStar.Classical.forall_intro
(FStar.Classical.move_requires (lemma_instr_write_outputs_only_affects_write outs args vs oprs s_orig s));
lemma_unchanged_except_extend locs_extension locs s s'
#restart-solver
#push-options "--z3rlimit 400 --initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_instr_write_outputs_only_writes
(outs:list instr_out) (args:list instr_operand)
(vs:instr_ret_t outs) (oprs:instr_operands_t outs args)
(s_orig1 s1 s_orig2 s2:machine_state) :
Lemma
(requires (
(unchanged_at (aux_read_set1 outs args oprs) s_orig1 s_orig2) /\
(unchanged_at' (aux_read_set1 outs args oprs) s1 s2) /\
(s1.ms_ok = s2.ms_ok)))
(ensures (
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
let locs = aux_write_set outs args oprs in
(unchanged_at' locs s1' s2' /\
unchanged_except locs s1 s1' /\
unchanged_except locs s2 s2' /\
(not s1.ms_ok ==> not s1'.ms_ok) /\
(not s2.ms_ok ==> not s2'.ms_ok)))) =
let s1', s2' =
instr_write_outputs outs args vs oprs s_orig1 s1,
instr_write_outputs outs args vs oprs s_orig2 s2 in
match outs with
| [] -> ()
| (io, i) :: outs -> (
let ((v:instr_val_t i), (vs:instr_ret_t outs)) =
match outs with
| [] -> (vs, ())
| _::_ -> let vs = coerce vs in (fst vs, snd vs)
in
match i with
| IOpEx i ->
let o, oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_explicit i o in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_explicit_only_writes i v o s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_explicit i v o s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_explicit i v o s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
| IOpIm i ->
let oprs = coerce oprs in
let loc_op_l, loc_op_r = locations_of_implicit i in
let loc_op_b = loc_op_l `L.append` loc_op_r in
let loc_rest = aux_read_set1 outs args oprs in
lemma_unchanged_at_append loc_op_l loc_op_r s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_b loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_rest s_orig1 s_orig2;
lemma_unchanged_at_append loc_op_l loc_op_r s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_unchanged_at_append loc_op_b loc_rest s1 s2;
lemma_unchanged_at_append loc_op_l loc_rest s1 s2;
lemma_instr_write_output_implicit_only_writes i v s_orig1 s1 s_orig2 s2;
let s1_old, s1 = s1, instr_write_output_implicit i v s_orig1 s1 in
let s2_old, s2 = s2, instr_write_output_implicit i v s_orig2 s2 in
lemma_unchanged_at'_maintained loc_rest loc_op_r s1_old s1 s2_old s2;
lemma_instr_write_outputs_only_writes outs args vs oprs s_orig1 s1 s_orig2 s2;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 loc_op_r;
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig1 s1 [];
lemma_instr_write_outputs_only_affects_write_extend outs args vs oprs s_orig2 s2 [];
let s1_old, s1 = s1, instr_write_outputs outs args vs oprs s_orig1 s1 in
let s2_old, s2 = s2, instr_write_outputs outs args vs oprs s_orig2 s2 in
lemma_unchanged_at_append loc_op_r (aux_write_set outs args oprs) s1 s2;
lemma_unchanged_at'_maintained loc_op_r (aux_write_set outs args oprs) s1_old s1 s2_old s2
)
#pop-options
let rec lemma_unchanged_at'_maintained_upon_flag_update (locs:locations) (s1 s2:machine_state) (flags:flags_t) :
Lemma
(requires (unchanged_at' locs s1 s2))
(ensures (unchanged_at' locs
({s1 with ms_flags = flags})
({s2 with ms_flags = flags}))) =
match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let lemma_eval_instr_unchanged_at'
(it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
(s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins (Instr it oprs ann)).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let w = (rw_set_of_ins (Instr it oprs ann)).loc_writes in
let s1' = eval_instr it oprs ann s1 in
let s2' = eval_instr it oprs ann s2 in
(Some? s1' = Some? s2') /\
(Some? s1' ==>
unchanged_at' w (Some?.v s1') (Some?.v s2')))) =
let InstrTypeRecord #outs #args #havoc_flags' i = it in
let vs1 = instr_apply_eval outs args (instr_eval i) oprs s1 in
let vs2 = instr_apply_eval outs args (instr_eval i) oprs s2 in
lemma_instr_apply_eval_same_read outs args (instr_eval i) oprs s1 s2;
assert (vs1 == vs2);
let s11, s22 =
match havoc_flags' with
| HavocFlags -> {s1 with ms_flags = havoc_flags}, {s2 with ms_flags = havoc_flags}
| PreserveFlags -> s1, s2
in
let s111 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s1 s11) vs1 in
let s222 = FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s2 s22) vs2 in
match vs1 with
| None -> ()
| Some vs ->
lemma_unchanged_at'_maintained_upon_flag_update (aux_read_set1 outs args oprs) s1 s2 havoc_flags;
lemma_instr_write_outputs_only_writes outs args vs oprs s1 s11 s2 s22;
if havoc_flags' = HavocFlags then (
let Some s1', Some s2' = s111, s222 in
let locs = aux_write_set outs args oprs in
if L.mem ALocOf locs then (
lemma_unchanged_at'_mem locs ALocOf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocOf
);
if L.mem ALocCf locs then (
lemma_unchanged_at'_mem locs ALocCf s1' s2'
) else (
lemma_unchanged_except_not_mem locs ALocCf
)
) else ()
#pop-options
let lemma_machine_eval_ins_st_ok (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2)))
(ensures (
let f = machine_eval_ins_st i in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
let lemma_machine_eval_ins_st_unchanged_behavior (i:ins{Instr? i}) (s1 s2:machine_state) :
Lemma
(requires (
let r = (rw_set_of_ins i).loc_reads in
let f = machine_eval_ins_st i in
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at r s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let w = (rw_set_of_ins i).loc_writes in
let f = machine_eval_ins_st i in
(unchanged_at w (run f s1) (run f s2)))) =
let Instr it oprs ann = i in
lemma_eval_instr_unchanged_at' it oprs ann s1 s2
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_constant_on_execution (i:ins{Instr? i}) (s:machine_state) :
Lemma
(ensures (constant_on_execution (rw_set_of_ins i).loc_constant_writes (machine_eval_ins_st i) s)) =
if s.ms_ok then (
let Instr it oprs ann = i in
let InstrTypeRecord #outs #args #havoc_flags' i = it in
match havoc_flags' with
| PreserveFlags -> ()
| HavocFlags ->
let ws = aux_write_set outs args oprs in
if L.mem ALocCf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocCf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocCf
);
if L.mem ALocOf ws then () else (
let s0 = s in
let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in
let s1 =
match havoc_flags' with
| HavocFlags -> {s0 with ms_flags = havoc_flags}
| PreserveFlags -> s0
in
match vs with
| None -> ()
| Some vs ->
let _ = instr_write_outputs outs args vs oprs s0 s1 in
lemma_unchanged_except_not_mem ws ALocOf;
lemma_instr_write_outputs_only_affects_write outs args vs oprs s0 s1 ALocOf
)
) else ()
#pop-options
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_ins_st_bounded_effects_Instr (i:ins{Instr? i}) :
Lemma
(ensures (
(bounded_effects (rw_set_of_ins i) (machine_eval_ins_st i)))) =
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_only_affects_write i);
FStar.Classical.forall_intro (lemma_machine_eval_ins_st_constant_on_execution i);
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_ok i s1));
FStar.Classical.forall_intro_2 (fun s1 ->
FStar.Classical.move_requires (lemma_machine_eval_ins_st_unchanged_behavior i s1))
#pop-options
(* See fsti *)
let lemma_machine_eval_ins_st_bounded_effects i =
match i with
| Instr _ _ _ -> lemma_machine_eval_ins_st_bounded_effects_Instr i
| _ -> assert_norm (not (safely_bounded i))
let rec lemma_unchanged_at_trace (locs:locations) (s1 s2:machine_state) trace1 trace2 :
Lemma
(requires (unchanged_at locs s1 s2))
(ensures (unchanged_at locs ({s1 with ms_trace = trace1}) ({s2 with ms_trace = trace2}))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_unchanged_at_trace xs s1 s2 trace1 trace2
let machine_eval_code_Ins i fuel : st unit =
(fun s -> (), (Some?.v (machine_eval_code_ins_def i s)))
let lemma_machine_eval_code_Ins_bounded_effects_aux1 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
unchanged_except rw.loc_writes s (run f s))) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_only_affects_write i (filt s);
assert (unchanged_except rw.loc_writes
(run (machine_eval_ins_st i) (filt s))
(run f s)) (* OBSERVE *)
let lemma_machine_eval_code_Ins_bounded_effects_aux2 (i:ins) (fuel:nat) s :
Lemma
(requires (safely_bounded i))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
constant_on_execution rw.loc_constant_writes f s)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_machine_eval_ins_st_constant_on_execution i (filt s);
let rec aux c :
Lemma
(requires (constant_on_execution c (machine_eval_ins_st i) (filt s)))
(ensures (constant_on_execution c f s)) =
if (run f s).ms_ok then (
match c with
| [] -> ()
| (|l,v|) :: xs ->
aux xs
) else ()
in
aux rw.loc_constant_writes
let lemma_machine_eval_code_Ins_bounded_effects_aux3 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2)))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
(run f s1).ms_ok = (run f s2).ms_ok)) =
let filt s = { s with ms_trace = [] } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt s2)
let lemma_machine_eval_code_Ins_bounded_effects_aux4 (i:ins) (fuel:nat) s1 s2 :
Lemma
(requires (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(safely_bounded i) /\
(s1.ms_ok = s2.ms_ok) /\
(unchanged_at rw.loc_reads s1 s2) /\
(run f s1).ms_ok /\
(run f s2).ms_ok))
(ensures (
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
(unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
let filt s = { s with ms_trace = [] } in
let intr s_orig s = { s with ms_trace = (ins_obs i s_orig) `L.append` s_orig.ms_trace } in
let f : st unit = machine_eval_code_Ins i fuel in
let rw = rw_set_of_ins i in
lemma_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_unchanged_behavior i (filt s1) (filt s2);
lemma_unchanged_at_trace rw.loc_writes (machine_eval_ins i (filt s1)) (machine_eval_ins i (filt s2))
(intr s1 s1).ms_trace (intr s2 s2).ms_trace
#push-options "--initial_fuel 3 --max_fuel 3 --initial_ifuel 1 --max_ifuel 1"
let lemma_machine_eval_code_Ins_bounded_effects_aux i fuel :
Lemma
(requires (safely_bounded i))
(ensures (
(bounded_effects (rw_set_of_ins i)
(machine_eval_code_Ins i fuel)))) =
let f : st unit = machine_eval_code_Ins i fuel in
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux1 i fuel) in
FStar.Classical.forall_intro aux;
let aux = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux2 i fuel) in
FStar.Classical.forall_intro aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux3 i fuel s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_machine_eval_code_Ins_bounded_effects_aux4 i fuel s1) in
FStar.Classical.forall_intro_2 aux
#pop-options
(* See fsti *)
let lemma_machine_eval_code_Ins_bounded_effects i fuel =
lemma_machine_eval_code_Ins_bounded_effects_aux i fuel
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
(* See fsti *)
let lemma_locations_of_ocmp o s1 s2 = ()
#pop-options
let rec intersect (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect xs l2
let rec difference (#t:eqtype) (l1 l2:list t) : list t =
match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then difference xs l2 else x :: difference xs l2
let sym_difference (#t:eqtype) (l1 l2:list t) : list t =
difference l1 l2 `L.append` difference l2 l1
(* See fsti *)
let rw_set_in_parallel rw1 rw2 =
{
loc_reads = sym_difference rw1.loc_writes rw2.loc_writes `L.append` (rw1.loc_reads `L.append` rw2.loc_reads);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
(* See fsti *)
let rw_set_in_series rw1 rw2 =
{
loc_reads = rw1.loc_reads `L.append` (difference rw2.loc_reads rw1.loc_writes);
loc_writes = rw1.loc_writes `L.append` rw2.loc_writes;
loc_constant_writes = rw1.loc_constant_writes `intersect` rw2.loc_constant_writes;
}
let rec lemma_constant_on_execution_mem (locv:locations_with_values) (f:st unit) (s:machine_state)
(l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(run f s).ms_ok /\
(constant_on_execution locv f s) /\
(L.mem (|l,v|) locv)))
(ensures (eval_location l (run f s) == raise_location_val_eqt v)) =
let (|l1,v1|) :: xs = locv in
if l = l1 && v = v1 then () else (
lemma_constant_on_execution_mem xs f s l v
)
(* See fsti *)
let lemma_add_r_to_rw_set r rw_old f =
let rw = add_r_to_rw_set r rw_old in
let aux s1 s2 :
Lemma
(requires (
(bounded_effects rw_old f) /\
(s1.ms_ok = s2.ms_ok /\ unchanged_at rw.loc_reads s1 s2)))
(ensures (
((run f s1).ms_ok = (run f s2).ms_ok) /\
((run f s1).ms_ok ==>
unchanged_at rw.loc_writes (run f s1) (run f s2)))) =
lemma_unchanged_at_append r rw_old.loc_reads s1 s2
in
let aux s1 = FStar.Classical.move_requires (aux s1) in
FStar.Classical.forall_intro_2 aux
let rec lemma_constant_intersect_belongs_to_writes_union
(c1 c2:locations_with_values) (w1 w2:locations) (l:location_eq) (v:location_val_eqt l) :
Lemma
(requires (
(let x : location_with_value = (|l,v|) in
L.mem x (c1 `intersect` c2) /\
(forall l v. {:pattern (L.mem (|l,v|) c1); (L.mem l w1)}
L.mem (|l,v|) c1 ==> L.mem l w1) /\
(forall l v. {:pattern (L.mem (|l,v|) c2); (L.mem l w2)}
L.mem (|l,v|) c2 ==> L.mem l w2))))
(ensures (L.mem l (w1 `L.append` w2))) =
match c1 with
| [] -> ()
| x :: xs ->
if x = (|l,v|) then (
assert (L.mem (|l,v|) c1);
assert (L.mem l w1);
L.append_mem w1 w2 l
) else (
assert (forall l v. L.mem (|l,v|) xs ==> L.mem (|l,v|) c1);
lemma_constant_intersect_belongs_to_writes_union xs c2 w1 w2 l v
)
#push-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let rec lemma_unchanged_at_mem (as0:list location) (a:location) (s1 s2:machine_state) :
Lemma
(requires (
(unchanged_at as0 s1 s2) /\
(L.mem a as0)))
(ensures (
(eval_location a s1 == eval_location a s2))) =
match as0 with
| [_] -> ()
| x :: xs ->
if a = x then () else
lemma_unchanged_at_mem xs a s1 s2
#pop-options
let rec lemma_unchanged_at_difference_elim (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at l2 s1 s2))
(ensures (unchanged_at l1 s1 s2)) =
match l1 with
| [] -> ()
| x :: xs ->
if L.mem x l2 then (
lemma_unchanged_at_mem l2 x s1 s2;
lemma_unchanged_at_difference_elim xs l2 s1 s2
) else (
lemma_unchanged_at_difference_elim xs l2 s1 s2
)
let lemma_unchanged_at_sym_diff_implies_difference (l1 l2:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_at (sym_difference l1 l2) s1 s2))
(ensures (unchanged_at (l1 `difference` l2) s1 s2 /\ unchanged_at (l2 `difference` l1) s1 s2)) =
lemma_unchanged_at_append (l1 `difference` l2) (l2 `difference` l1) s1 s2
let rec lemma_disjoint_location_from_locations_not_mem (locs:locations) (l:location) :
Lemma
(ensures (
!!(disjoint_location_from_locations l locs) <==>
not (L.mem l locs))) =
match locs with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem xs l
let rec lemma_difference_disjoint (l1 l2:locations) :
Lemma
(ensures (
!!(disjoint_locations (l1 `difference` l2) l2))) =
match l1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem l2 x;
lemma_difference_disjoint xs l2
let rec lemma_unchanged_except_to_at_difference (locs locs_change:locations) (s1 s2:machine_state) :
Lemma
(requires (unchanged_except locs_change s1 s2))
(ensures (unchanged_at (locs `difference` locs_change) s1 s2)) =
match locs with
| [] -> ()
| x :: xs ->
lemma_difference_disjoint locs locs_change;
lemma_unchanged_except_to_at_difference xs locs_change s1 s2
let rec lemma_unchanged_at_maintained (locs locs_change:locations) (s1 s1' s2 s2':machine_state) :
Lemma
(requires (
(unchanged_at locs s1 s2) /\
(unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\
(unchanged_at locs_change s1' s2')))
(ensures ( | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_unchanged_at_maintained (locs locs_change: locations) (s1 s1' s2 s2': machine_state)
: Lemma
(requires
((unchanged_at locs s1 s2) /\ (unchanged_except locs_change s1 s1') /\
(unchanged_except locs_change s2 s2') /\ (unchanged_at locs_change s1' s2')))
(ensures ((unchanged_at locs s1' s2'))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_maintained | {
"file_name": "vale/code/lib/transformers/Vale.Transformers.BoundedInstructionEffects.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
locs: Vale.Transformers.Locations.locations ->
locs_change: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s1': Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state ->
s2': Vale.X64.Machine_Semantics_s.machine_state
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.unchanged_at locs s1 s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except locs_change s1 s1' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except locs_change s2 s2' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at locs_change s1' s2')
(ensures Vale.Transformers.BoundedInstructionEffects.unchanged_at locs s1' s2') | {
"end_col": 5,
"end_line": 1008,
"start_col": 2,
"start_line": 1000
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.