effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.Pervasives.Lemma | val 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)))) | [
{
"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_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 | val 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))))
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)))) = | false | null | true | match as1 with
| [] -> ()
| x :: xs -> lemma_disjoint_location_from_locations_append a xs as2 | {
"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.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_append",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Prims.l_and",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"FStar.List.Tot.Base.append",
"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)) <==> | 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_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)))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_append | {
"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"
} |
a: Vale.Transformers.Locations.location ->
as1: Prims.list Vale.Transformers.Locations.location ->
as2: Prims.list Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(ensures
!!(Vale.Transformers.Locations.disjoint_location_from_locations a as1) /\
!!(Vale.Transformers.Locations.disjoint_location_from_locations a as2) <==>
!!(Vale.Transformers.Locations.disjoint_location_from_locations a (as1 @ as2))) | {
"end_col": 58,
"end_line": 457,
"start_col": 2,
"start_line": 454
} |
FStar.Pervasives.Lemma | val lemma_difference_disjoint (l1 l2: locations)
: Lemma (ensures (!!(disjoint_locations (l1 `difference` l2) l2))) | [
{
"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_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 | val lemma_difference_disjoint (l1 l2: locations)
: Lemma (ensures (!!(disjoint_locations (l1 `difference` l2) l2)))
let rec lemma_difference_disjoint (l1 l2: locations)
: Lemma (ensures (!!(disjoint_locations (l1 `difference` l2) l2))) = | false | null | true | match l1 with
| [] -> ()
| x :: xs ->
lemma_disjoint_location_from_locations_not_mem l2 x;
lemma_difference_disjoint 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"
} | [
"lemma"
] | [
"Vale.Transformers.Locations.locations",
"Vale.Transformers.Locations.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_difference_disjoint",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_not_mem",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_locations",
"Vale.Transformers.BoundedInstructionEffects.difference",
"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 ( | 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_difference_disjoint (l1 l2: locations)
: Lemma (ensures (!!(disjoint_locations (l1 `difference` l2) l2))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_difference_disjoint | {
"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
-> FStar.Pervasives.Lemma
(ensures
!!(Vale.Transformers.Locations.disjoint_locations (Vale.Transformers.BoundedInstructionEffects.difference
l1
l2)
l2)) | {
"end_col": 35,
"end_line": 979,
"start_col": 2,
"start_line": 975
} |
FStar.Pervasives.Lemma | val 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)
)) | [
{
"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_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 | val 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)
))
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)
)) = | false | null | true | match l1 with
| [] -> ()
| x :: xs -> lemma_unchanged_at_append xs l2 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.Locations.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"FStar.List.Tot.Base.append",
"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) <==> | 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_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)
)) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append | {
"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
(ensures
Vale.Transformers.BoundedInstructionEffects.unchanged_at (l1 @ l2) s1 s2 <==>
Vale.Transformers.BoundedInstructionEffects.unchanged_at l1 s1 s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at l2 s1 s2) | {
"end_col": 41,
"end_line": 264,
"start_col": 2,
"start_line": 261
} |
FStar.Pervasives.Lemma | val 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'))) | [
{
"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 (
(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
) | val 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')))
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'))) = | 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",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_Negation",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"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 ( | 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
((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'))) | [
"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
(Prims.op_Negation (Mkmachine_state?.ms_ok s1) ==>
Prims.op_Negation (Mkmachine_state?.ms_ok s1')) /\
(Prims.op_Negation (Mkmachine_state?.ms_ok s2) ==>
Prims.op_Negation (Mkmachine_state?.ms_ok s2')) /\
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": 446,
"start_col": 2,
"start_line": 438
} |
FStar.Pervasives.Lemma | val 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'))) | [
{
"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_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' | val 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')))
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'))) = | false | null | true | 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' | {
"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",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_extend_append",
"Prims.unit",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_mem",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_mem",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.squash",
"FStar.List.Tot.Base.append",
"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 ( | 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_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'))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_extend_append | {
"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 ->
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 l1 s1 s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except l2 s1 s1' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except l2 s2 s2' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at l2 s1' s2')
(ensures Vale.Transformers.BoundedInstructionEffects.unchanged_at (l1 @ l2) s1' s2') | {
"end_col": 56,
"end_line": 1284,
"start_col": 2,
"start_line": 1276
} |
FStar.Pervasives.Lemma | val 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'))) | [
{
"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_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' | val 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')))
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'))) = | false | null | true | match same with
| [] -> ()
| x :: xs -> lemma_unchanged_at_except_disjoint xs change s1 s2 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.Locations.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_except_disjoint",
"Prims.unit",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_locations",
"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 ( | 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_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'))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_except_disjoint | {
"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"
} |
same: Vale.Transformers.Locations.locations ->
change: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state ->
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 same s1 s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except change s1 s1' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except change s2 s2' /\
!!(Vale.Transformers.Locations.disjoint_locations same change))
(ensures Vale.Transformers.BoundedInstructionEffects.unchanged_at same s1' s2') | {
"end_col": 62,
"end_line": 1235,
"start_col": 2,
"start_line": 1232
} |
FStar.Pervasives.Lemma | val 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))))) | [
{
"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_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 | val 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 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))))) = | false | null | true | 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 | {
"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.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.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.location",
"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.X64.Instruction_s.instr_ret_t",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"Prims.unit",
"FStar.Pervasives.Native.option",
"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.havoc_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",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"Vale.X64.Machine_Semantics_s.instr_apply_eval",
"Vale.X64.Instruction_s.instr_eval",
"Prims.l_and",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"FStar.Pervasives.Native.uu___is_Some",
"Vale.X64.Machine_Semantics_s.eval_instr",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Bytes_Code_s.Instr",
"Prims.squash",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"FStar.Pervasives.Native.__proj__Some__item__v",
"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))))) | 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_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))))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_eval_instr_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"
} |
it: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs it) (InstrTypeRecord?.args it) ->
ann: Vale.X64.Machine_Semantics_s.instr_annotation it ->
s0: Vale.X64.Machine_Semantics_s.machine_state ->
a: Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(requires
(let w =
Mkrw_set?.loc_writes (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins (Vale.X64.Bytes_Code_s.Instr
it oprs ann))
in
!!(Vale.Transformers.Locations.disjoint_location_from_locations a w) /\
Some? (Vale.X64.Machine_Semantics_s.eval_instr it oprs ann s0)))
(ensures
Vale.Transformers.Locations.eval_location a s0 ==
Vale.Transformers.Locations.eval_location a
(Some?.v (Vale.X64.Machine_Semantics_s.eval_instr it oprs ann s0))) | {
"end_col": 72,
"end_line": 209,
"start_col": 89,
"start_line": 199
} |
FStar.Pervasives.Lemma | val 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))
) | [
{
"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_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 | val 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))
)
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))
) = | false | null | true | 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 | {
"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_args_t",
"Vale.X64.Instruction_s.instr_operands_t_args",
"Vale.X64.Machine_Semantics_s.machine_state",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_args_same_read",
"Prims.unit",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Machine_Semantics_s.bind_option",
"Vale.X64.Machine_Semantics_s.instr_apply_eval_args",
"Vale.X64.Instruction_s.arrow",
"Vale.X64.Instruction_s.coerce",
"Prims._assert",
"Prims.eq2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.Pervasives.Native.snd",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_eval_operand_explicit_same_read_both",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set0",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_eval_operand_implicit_same_read_both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_implicit",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"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) == | 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_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))
) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_args_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_args_t outs args ->
oprs: Vale.X64.Instruction_s.instr_operands_t_args 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_set0
args
oprs)
s1
s2)
(ensures
Vale.X64.Machine_Semantics_s.instr_apply_eval_args outs args f oprs s1 ==
Vale.X64.Machine_Semantics_s.instr_apply_eval_args outs args f oprs s2) | {
"end_col": 70,
"end_line": 302,
"start_col": 2,
"start_line": 275
} |
FStar.Pervasives.Lemma | val 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)
(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 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 () | val 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)
(let* _ = f1 in
f2)
s)))
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)
(let* _ = f1 in
f2)
s))) = | false | null | true | let open Vale.X64.Machine_Semantics_s in
let f =
let* _ = f1 in
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);
assert (forall s. constant_on_execution c1 f1 s ==> constant_on_execution xs f1 s);
lemma_bounded_effects_series_aux2 xs c2 f1 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.locations_with_values",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.Locations.location_val_eqt",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux2",
"Prims._assert",
"Prims.l_Forall",
"Prims.l_imp",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"FStar.List.Tot.Base.mem",
"Prims.Mkdtuple2",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_on_execution_mem",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.op_let_Star",
"Prims.l_and",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"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 | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"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_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)
(let* _ = f1 in
f2)
s))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_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"
} |
c1: Vale.Transformers.BoundedInstructionEffects.locations_with_values ->
c2: Vale.Transformers.BoundedInstructionEffects.locations_with_values ->
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
-> FStar.Pervasives.Lemma
(requires
(forall (s: Vale.X64.Machine_Semantics_s.machine_state).
{:pattern Vale.Transformers.BoundedInstructionEffects.constant_on_execution c1 f1 s}
Vale.Transformers.BoundedInstructionEffects.constant_on_execution c1 f1 s) /\
(forall (s: Vale.X64.Machine_Semantics_s.machine_state).
{:pattern Vale.Transformers.BoundedInstructionEffects.constant_on_execution c2 f2 s}
Vale.Transformers.BoundedInstructionEffects.constant_on_execution c2 f2 s))
(ensures
Vale.Transformers.BoundedInstructionEffects.constant_on_execution (Vale.Transformers.BoundedInstructionEffects.intersect
c1
c2)
(( op_let_Star* ) f1 (fun _ -> f2))
s) | {
"end_col": 11,
"end_line": 1220,
"start_col": 2,
"start_line": 1209
} |
FStar.Pervasives.Lemma | val 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')))) | [
{
"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_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 () | val 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 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')))) = | false | null | true | 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)) | {
"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.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.X64.Machine_Semantics_s.machine_state",
"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.X64.Instruction_s.instr_ret_t",
"Prims.op_Equality",
"Vale.X64.Instruction_s.HavocFlags",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.Locations.location",
"Vale.Transformers.Locations.ALocCf",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_mem",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_mem",
"Prims.unit",
"Vale.Transformers.Locations.ALocOf",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_writes",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_maintained_upon_flag_update",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"Vale.X64.Machine_Semantics_s.havoc_flags",
"FStar.Option.mapTot",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"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_heap",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"Prims._assert",
"Prims.eq2",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_same_read",
"Vale.X64.Instruction_s.instr_eval",
"Vale.X64.Machine_Semantics_s.instr_apply_eval",
"Prims.l_and",
"Prims.b2t",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Bytes_Code_s.Instr",
"Prims.squash",
"FStar.Pervasives.Native.uu___is_Some",
"Prims.l_imp",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at'",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Vale.X64.Machine_Semantics_s.eval_instr",
"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') /\ | 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_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')))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_eval_instr_unchanged_at' | {
"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"
} |
it: Vale.X64.Instruction_s.instr_t_record ->
oprs:
Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs it) (InstrTypeRecord?.args it) ->
ann: Vale.X64.Machine_Semantics_s.instr_annotation it ->
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 (Vale.X64.Bytes_Code_s.Instr
it oprs ann))
in
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at r s1 s2))
(ensures
(let w =
Mkrw_set?.loc_writes (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins (Vale.X64.Bytes_Code_s.Instr
it oprs ann))
in
let s1' = Vale.X64.Machine_Semantics_s.eval_instr it oprs ann s1 in
let s2' = Vale.X64.Machine_Semantics_s.eval_instr it oprs ann s2 in
Some? s1' = Some? s2' /\
(Some? s1' ==>
Vale.Transformers.BoundedInstructionEffects.unchanged_at' w (Some?.v s1') (Some?.v s2'))
)) | {
"end_col": 13,
"end_line": 631,
"start_col": 57,
"start_line": 600
} |
Prims.Tot | val locations_of_implicit (t: instr_operand_implicit) : 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_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] | val locations_of_implicit (t: instr_operand_implicit) : locations & locations
let locations_of_implicit (t: instr_operand_implicit) : locations & locations = | false | null | false | match t with
| IOp64One i -> locations_of_operand64 i
| IOpXmmOne i -> locations_of_operand128 i
| IOpFlagsCf -> [], [ALocCf]
| IOpFlagsOf -> [], [ALocOf] | {
"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_implicit",
"Vale.X64.Machine_s.operand64",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand64",
"Vale.X64.Machine_s.operand128",
"Vale.Transformers.BoundedInstructionEffects.locations_of_operand128",
"FStar.Pervasives.Native.Mktuple2",
"Vale.Transformers.Locations.locations",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Prims.Cons",
"Vale.Transformers.Locations.ALocCf",
"Vale.Transformers.Locations.ALocOf",
"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]
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 | 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_implicit (t: instr_operand_implicit) : locations & locations | [] | Vale.Transformers.BoundedInstructionEffects.locations_of_implicit | {
"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_implicit
-> Vale.Transformers.Locations.locations * Vale.Transformers.Locations.locations | {
"end_col": 30,
"end_line": 50,
"start_col": 2,
"start_line": 46
} |
FStar.Pervasives.Lemma | val 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)))) | [
{
"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_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 -> () | val 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 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)))) = | false | null | true | 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 -> () | {
"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.Transformers.Locations.location",
"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.eval_instr",
"Vale.Transformers.BoundedInstructionEffects.lemma_eval_instr_only_affects_write",
"Prims.unit",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Prims.squash",
"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",
"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)))) | 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_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)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_only_affects_write_aux | {
"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 ->
a: Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(requires
(let w =
Mkrw_set?.loc_writes (Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i)
in
!!(Vale.Transformers.Locations.disjoint_location_from_locations a w)))
(ensures
Vale.Transformers.Locations.eval_location a s ==
Vale.Transformers.Locations.eval_location a
(Vale.X64.Machine_Semantics_s.run (Vale.X64.Machine_Semantics_s.machine_eval_ins_st i) s)) | {
"end_col": 14,
"end_line": 222,
"start_col": 82,
"start_line": 218
} |
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 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) | let unchanged_at' (l: locations) (s1 s2: machine_state) = | false | null | false | (s1.ms_ok = s2.ms_ok) /\ (s1.ms_ok /\ s2.ms_ok ==> unchanged_at l 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"
} | [
"total"
] | [
"Vale.Transformers.Locations.locations",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_and",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Prims.l_imp",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Prims.logical"
] | [] | 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 | 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 unchanged_at' : l: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.logical | [] | Vale.Transformers.BoundedInstructionEffects.unchanged_at' | {
"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"
} |
l: Vale.Transformers.Locations.locations ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s2: Vale.X64.Machine_Semantics_s.machine_state
-> Prims.logical | {
"end_col": 24,
"end_line": 364,
"start_col": 2,
"start_line": 362
} |
|
FStar.Pervasives.Lemma | val 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))) | [
{
"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_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
) | val 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)))
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))) = | false | null | true | 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) | {
"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.locations_with_values",
"Vale.Transformers.Locations.locations",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.Locations.location_val_eqt",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.list",
"Prims.op_Equality",
"Prims.dtuple2",
"Prims.Mkdtuple2",
"FStar.List.Tot.Properties.append_mem",
"Vale.Transformers.Locations.location",
"Prims.unit",
"Prims._assert",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_intersect_belongs_to_writes_union",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"FStar.Universe.raise_t",
"Prims.squash",
"FStar.List.Tot.Base.append",
"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)))) | 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_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))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_constant_intersect_belongs_to_writes_union | {
"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"
} |
c1: Vale.Transformers.BoundedInstructionEffects.locations_with_values ->
c2: Vale.Transformers.BoundedInstructionEffects.locations_with_values ->
w1: Vale.Transformers.Locations.locations ->
w2: Vale.Transformers.Locations.locations ->
l: Vale.Transformers.Locations.location_eq ->
v: Vale.Transformers.Locations.location_val_eqt l
-> FStar.Pervasives.Lemma
(requires
(let x = (| l, v |) in
FStar.List.Tot.Base.mem x (Vale.Transformers.BoundedInstructionEffects.intersect c1 c2) /\
(forall (l:
Vale.Transformers.Locations.location
{ Vale.Transformers.Locations.location_val_t l ==
FStar.Universe.raise_t (Vale.Transformers.Locations.location_val_eqt l) })
(v: Vale.Transformers.Locations.location_val_eqt l).
{:pattern FStar.List.Tot.Base.mem (| l, v |) c1; FStar.List.Tot.Base.mem l w1}
FStar.List.Tot.Base.mem (| l, v |) c1 ==> FStar.List.Tot.Base.mem l w1) /\
(forall (l:
Vale.Transformers.Locations.location
{ Vale.Transformers.Locations.location_val_t l ==
FStar.Universe.raise_t (Vale.Transformers.Locations.location_val_eqt l) })
(v: Vale.Transformers.Locations.location_val_eqt l).
{:pattern FStar.List.Tot.Base.mem (| l, v |) c2; FStar.List.Tot.Base.mem l w2}
FStar.List.Tot.Base.mem (| l, v |) c2 ==> FStar.List.Tot.Base.mem l w2)))
(ensures FStar.List.Tot.Base.mem l (w1 @ w2)) | {
"end_col": 5,
"end_line": 924,
"start_col": 2,
"start_line": 914
} |
Prims.Tot | val aux_write_set
(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_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) | val aux_write_set
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations
let rec aux_write_set
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations = | false | null | false | 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)) | {
"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",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.List.Tot.Base.append",
"FStar.Pervasives.Native.snd",
"Vale.Transformers.Locations.locations",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"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
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 | 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_write_set
(outs: list instr_out)
(args: list instr_operand)
(oprs: instr_operands_t outs args)
: locations | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.aux_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"
} |
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": 112,
"end_line": 91,
"start_col": 2,
"start_line": 85
} |
FStar.Pervasives.Lemma | val lemma_bounded_effects_parallel :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
(bounded_effects (rw_set_in_parallel rw1 rw2) f1) /\
(bounded_effects (rw_set_in_parallel rw1 rw2) f2))) | [
{
"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_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))
)
)
) | val lemma_bounded_effects_parallel :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
(bounded_effects (rw_set_in_parallel rw1 rw2) f1) /\
(bounded_effects (rw_set_in_parallel rw1 rw2) f2)))
let lemma_bounded_effects_parallel rw1 rw2 f1 f2 = | false | null | true | 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))
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))
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))
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))))) | {
"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",
"Prims._assert",
"Prims.l_Forall",
"Vale.X64.Machine_Semantics_s.machine_state",
"Prims.l_imp",
"Prims.l_and",
"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",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"FStar.Classical.forall_intro_2",
"FStar.Pervasives.Native.snd",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Classical.move_requires",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_parallel_aux2",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_parallel_aux1",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.sym_difference",
"Vale.Transformers.Locations.location",
"FStar.List.Tot.Base.append",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"FStar.Universe.raise_t",
"Vale.Transformers.Locations.location_val_eqt",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.Mkdtuple2",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes",
"FStar.Classical.arrow_to_impl",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_intersect_belongs_to_writes_union",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"FStar.Classical.forall_intro",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Prims.list",
"Prims.op_AmpAmp",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_on_execution_mem",
"FStar.Pervasives.dfst",
"FStar.Pervasives.dsnd",
"Vale.Transformers.BoundedInstructionEffects.only_affects",
"Vale.Def.PossiblyMonad.uu___is_Ok",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Vale.Transformers.Locations.eval_location",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_append",
"Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel"
] | [] | 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)) | 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 :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
(bounded_effects (rw_set_in_parallel rw1 rw2) f1) /\
(bounded_effects (rw_set_in_parallel rw1 rw2) f2))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_parallel | {
"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
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw1 f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw2 f2)
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel
rw1
rw2)
f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel
rw1
rw2)
f2) | {
"end_col": 3,
"end_line": 1179,
"start_col": 50,
"start_line": 1061
} |
FStar.Pervasives.Lemma | val 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')) | [
{
"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_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' | val 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 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')) = | false | null | true | 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' | {
"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_ret_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.locations",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_extend",
"Prims.unit",
"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",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"FStar.Classical.move_requires",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write",
"Prims.l_True",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"FStar.List.Tot.Base.append",
"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 | 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_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')) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write_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"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
vs: Vale.X64.Instruction_s.instr_ret_t outs ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args ->
s_orig: Vale.X64.Machine_Semantics_s.machine_state ->
s: Vale.X64.Machine_Semantics_s.machine_state ->
locs_extension: Vale.Transformers.Locations.locations
-> FStar.Pervasives.Lemma
(ensures
(let s' = Vale.X64.Machine_Semantics_s.instr_write_outputs outs args vs oprs s_orig s in
let locs = Vale.Transformers.BoundedInstructionEffects.aux_write_set outs args oprs in
Vale.Transformers.BoundedInstructionEffects.unchanged_except (locs_extension @ locs) s s')) | {
"end_col": 56,
"end_line": 485,
"start_col": 66,
"start_line": 480
} |
Prims.Tot | val rw_set_in_series : rw_set -> rw_set -> 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_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;
} | val rw_set_in_series : rw_set -> rw_set -> rw_set
let rw_set_in_series rw1 rw2 = | false | null | false | {
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
} | {
"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.Transformers.BoundedInstructionEffects.rw_set",
"Vale.Transformers.BoundedInstructionEffects.Mkrw_set",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes"
] | [] | 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 = | 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_in_series : rw_set -> rw_set -> rw_set | [] | Vale.Transformers.BoundedInstructionEffects.rw_set_in_series | {
"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
-> Vale.Transformers.BoundedInstructionEffects.rw_set | {
"end_col": 86,
"end_line": 870,
"start_col": 4,
"start_line": 868
} |
Prims.Tot | val rw_set_in_parallel : rw_set -> rw_set -> 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_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;
} | val rw_set_in_parallel : rw_set -> rw_set -> rw_set
let rw_set_in_parallel rw1 rw2 = | false | null | false | {
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
} | {
"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.Transformers.BoundedInstructionEffects.rw_set",
"Vale.Transformers.BoundedInstructionEffects.Mkrw_set",
"FStar.List.Tot.Base.append",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.sym_difference",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes"
] | [] | 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 = | 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_in_parallel : rw_set -> rw_set -> rw_set | [] | Vale.Transformers.BoundedInstructionEffects.rw_set_in_parallel | {
"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
-> Vale.Transformers.BoundedInstructionEffects.rw_set | {
"end_col": 86,
"end_line": 862,
"start_col": 4,
"start_line": 860
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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 | val 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 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)) = | 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",
"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.X64.Machine_Semantics_s.run",
"Vale.X64.Machine_Semantics_s.st",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"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 ( | 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_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)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_ok | {
"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
Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at r s1 s2))
(ensures
(let f = Vale.X64.Machine_Semantics_s.machine_eval_ins_st i in
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s1) =
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 50,
"end_line": 644,
"start_col": 47,
"start_line": 642
} |
FStar.Pervasives.Lemma | val 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)))) | [
{
"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_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)) | val 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))))
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)))) = | 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 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)) | {
"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 | 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_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)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_parallel_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 ->
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 f1 s1) /\
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f1 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 f1 s1)
(Vale.X64.Machine_Semantics_s.run f1 s2))) | {
"end_col": 62,
"end_line": 1033,
"start_col": 2,
"start_line": 1023
} |
FStar.Pervasives.Lemma | val 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 =
let* _ = f1 in
f2
in
(run f s1).ms_ok = (run f s2).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 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 () | val 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 =
let* _ = f1 in
f2
in
(run f s1).ms_ok = (run f s2).ms_ok))
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 =
let* _ = f1 in
f2
in
(run f s1).ms_ok = (run f s2).ms_ok)) = | 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);
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) | {
"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.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_difference_elim",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_writes",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_except_disjoint",
"Vale.Transformers.BoundedInstructionEffects.difference",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.lemma_difference_disjoint",
"Prims._assert",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Vale.Transformers.BoundedInstructionEffects.only_affects",
"Prims.bool",
"Prims.b2t",
"Prims.op_Equality",
"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",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.bounded_effects",
"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 | 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_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 =
let* _ = f1 in
f2
in
(run f s1).ms_ok = (run f s2).ms_ok)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux3 | {
"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 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Mkrw_set?.loc_reads rw) s1 s2))
(ensures
(let f = ( op_let_Star* ) f1 (fun _ -> f2) in
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s1) =
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 11,
"end_line": 1265,
"start_col": 2,
"start_line": 1250
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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) | val 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 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)) = | 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_unchanged_at_trace rw.loc_reads s1 s2 [] [];
lemma_machine_eval_ins_st_ok i (filt s1) (filt 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.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_ok",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_trace",
"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",
"Prims.l_and",
"Prims.b2t",
"Vale.Transformers.BoundedInstructionEffects.safely_bounded",
"Prims.op_Equality",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Prims.squash",
"Vale.X64.Machine_Semantics_s.run",
"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 ( | 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_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)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects_aux3 | {
"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))
(ensures
(let f = Vale.Transformers.BoundedInstructionEffects.machine_eval_code_Ins i fuel in
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s1) =
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s2))) | {
"end_col": 52,
"end_line": 792,
"start_col": 47,
"start_line": 787
} |
FStar.Pervasives.Lemma | val 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))) | [
{
"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_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 | val 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)))
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))) = | false | null | true | 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 | {
"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_inouts_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_args_same_read",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_inouts_same_read",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_explicit",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.instr_operand_t",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.instr_operand_implicit",
"FStar.Pervasives.Native.option",
"Vale.X64.Instruction_s.instr_val_t",
"Prims.unit",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.X64.Machine_Semantics_s.bind_option",
"Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts",
"Vale.X64.Instruction_s.arrow",
"Prims._assert",
"Prims.eq2",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit",
"FStar.Pervasives.Native.fst",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_eval_operand_explicit_same_read_both",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"Vale.Transformers.BoundedInstructionEffects.both",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_eval_operand_implicit_same_read_both",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"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) == | false | false | Vale.Transformers.BoundedInstructionEffects.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 6,
"initial_ifuel": 2,
"max_fuel": 6,
"max_ifuel": 2,
"no_plugins": false,
"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": 25,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_apply_eval_inouts_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 ->
inouts: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
f: Vale.X64.Instruction_s.instr_inouts_t outs inouts args ->
oprs: Vale.X64.Instruction_s.instr_operands_t inouts 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
inouts
args
oprs)
s1
s2)
(ensures
Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts outs inouts args f oprs s1 ==
Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts outs inouts args f oprs s2) | {
"end_col": 79,
"end_line": 347,
"start_col": 2,
"start_line": 314
} |
FStar.Pervasives.Lemma | val lemma_unchanged_except_not_mem (as0: locations) (a: location)
: Lemma (requires ((not (L.mem a as0)))) (ensures (!!(disjoint_location_from_locations a as0))) | [
{
"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_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 | val lemma_unchanged_except_not_mem (as0: locations) (a: location)
: Lemma (requires ((not (L.mem a as0)))) (ensures (!!(disjoint_location_from_locations a as0)))
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))) = | false | null | true | match as0 with
| [] -> ()
| x :: xs -> lemma_unchanged_except_not_mem xs a | {
"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",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_mem",
"Prims.unit",
"Prims.b2t",
"Prims.op_Negation",
"FStar.List.Tot.Base.mem",
"Prims.squash",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"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 ( | 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_not_mem (as0: locations) (a: location)
: Lemma (requires ((not (L.mem a as0)))) (ensures (!!(disjoint_location_from_locations a as0))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_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
-> FStar.Pervasives.Lemma (requires Prims.op_Negation (FStar.List.Tot.Base.mem a as0))
(ensures !!(Vale.Transformers.Locations.disjoint_location_from_locations a as0)) | {
"end_col": 50,
"end_line": 425,
"start_col": 2,
"start_line": 423
} |
Prims.Tot | val intersect (#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 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 | val intersect (#t: eqtype) (l1 l2: list t) : list t
let rec intersect (#t: eqtype) (l1 l2: list t) : list t = | false | null | false | match l1 with
| [] -> []
| x :: xs -> if L.mem x l2 then x :: intersect xs l2 else intersect 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",
"Prims.Cons",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Prims.bool"
] | [] | 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 | 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 intersect (#t: eqtype) (l1 l2: list t) : list t | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.intersect | {
"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": 75,
"end_line": 847,
"start_col": 2,
"start_line": 845
} |
FStar.Pervasives.Lemma | val lemma_disjoint_location_from_locations_not_mem (locs: locations) (l: location)
: Lemma (ensures (!!(disjoint_location_from_locations l locs) <==> not (L.mem l locs))) | [
{
"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_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 | val lemma_disjoint_location_from_locations_not_mem (locs: locations) (l: location)
: Lemma (ensures (!!(disjoint_location_from_locations l locs) <==> not (L.mem l locs)))
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))) = | false | null | true | match locs with
| [] -> ()
| x :: xs -> lemma_disjoint_location_from_locations_not_mem xs l | {
"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",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_not_mem",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_iff",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Prims.op_Negation",
"FStar.List.Tot.Base.mem",
"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) <==> | 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_disjoint_location_from_locations_not_mem (locs: locations) (l: location)
: Lemma (ensures (!!(disjoint_location_from_locations l locs) <==> not (L.mem l locs))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_disjoint_location_from_locations_not_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"
} | locs: Vale.Transformers.Locations.locations -> l: Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(ensures
!!(Vale.Transformers.Locations.disjoint_location_from_locations l locs) <==>
Prims.op_Negation (FStar.List.Tot.Base.mem l locs)) | {
"end_col": 55,
"end_line": 969,
"start_col": 2,
"start_line": 966
} |
FStar.Pervasives.Lemma | val 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 }))) | [
{
"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_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 | val 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 })))
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 }))) = | false | null | true | match locs with
| [] -> ()
| x :: xs -> lemma_unchanged_at'_maintained_upon_flag_update xs s1 s2 flags | {
"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.X64.Machine_Semantics_s.flags_t",
"Vale.Transformers.Locations.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_maintained_upon_flag_update",
"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_heap",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"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}) | 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_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 }))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_maintained_upon_flag_update | {
"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 ->
flags: Vale.X64.Machine_Semantics_s.flags_t
-> 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)
flags
(Mkmachine_state?.ms_heap s1)
(Mkmachine_state?.ms_stack s1)
(Mkmachine_state?.ms_stackTaint s1)
(Mkmachine_state?.ms_trace s1))
(Vale.X64.Machine_Semantics_s.Mkmachine_state (Mkmachine_state?.ms_ok s2)
(Mkmachine_state?.ms_regs s2)
flags
(Mkmachine_state?.ms_heap s2)
(Mkmachine_state?.ms_stack s2)
(Mkmachine_state?.ms_stackTaint s2)
(Mkmachine_state?.ms_trace s2))) | {
"end_col": 77,
"end_line": 583,
"start_col": 2,
"start_line": 581
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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 | val 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))
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)) = | false | null | true | match locs with
| [] -> ()
| x :: xs ->
lemma_difference_disjoint locs locs_change;
lemma_unchanged_except_to_at_difference xs locs_change 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.Locations.location",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_to_at_difference",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_difference_disjoint",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.difference",
"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)) | 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_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)) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_to_at_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"
} |
locs: Vale.Transformers.Locations.locations ->
locs_change: 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 locs_change s1 s2)
(ensures
Vale.Transformers.BoundedInstructionEffects.unchanged_at (Vale.Transformers.BoundedInstructionEffects.difference
locs
locs_change)
s1
s2) | {
"end_col": 64,
"end_line": 989,
"start_col": 2,
"start_line": 985
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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
) | val 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))
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)) = | false | null | true | 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) | {
"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_difference_elim",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_mem",
"Prims.bool",
"Prims.l_and",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.difference",
"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)) | 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_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)) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_difference_elim | {
"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.difference
l1
l2)
s1
s2 /\ Vale.Transformers.BoundedInstructionEffects.unchanged_at l2 s1 s2)
(ensures Vale.Transformers.BoundedInstructionEffects.unchanged_at l1 s1 s2) | {
"end_col": 5,
"end_line": 953,
"start_col": 2,
"start_line": 945
} |
FStar.Pervasives.Lemma | val lemma_bounded_effects_series :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
(bounded_effects (rw_set_in_series rw1 rw2) (f1;*f2)))) | [
{
"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_bounded_effects_series rw1 rw2 f1 f2 =
let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
let aux s = FStar.Classical.move_requires (lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s) in
FStar.Classical.forall_intro_2 aux;
let aux = FStar.Classical.move_requires (lemma_bounded_effects_series_aux2
rw1.loc_constant_writes rw2.loc_constant_writes f1 f2) in
FStar.Classical.forall_intro aux;
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;
let aux s1 = FStar.Classical.move_requires (lemma_bounded_effects_series_aux3 rw1 rw2 f1 f2 s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_bounded_effects_series_aux4 rw1 rw2 f1 f2 s1) in
FStar.Classical.forall_intro_2 aux | val lemma_bounded_effects_series :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
(bounded_effects (rw_set_in_series rw1 rw2) (f1;*f2))))
let lemma_bounded_effects_series rw1 rw2 f1 f2 = | false | null | true | let open Vale.X64.Machine_Semantics_s in
let rw = rw_set_in_series rw1 rw2 in
let aux s = FStar.Classical.move_requires (lemma_bounded_effects_series_aux1 rw1 rw2 f1 f2 s) in
FStar.Classical.forall_intro_2 aux;
let aux =
FStar.Classical.move_requires (lemma_bounded_effects_series_aux2 rw1.loc_constant_writes
rw2.loc_constant_writes
f1
f2)
in
FStar.Classical.forall_intro aux;
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;
let aux s1 = FStar.Classical.move_requires (lemma_bounded_effects_series_aux3 rw1 rw2 f1 f2 s1) in
FStar.Classical.forall_intro_2 aux;
let aux s1 = FStar.Classical.move_requires (lemma_bounded_effects_series_aux4 rw1 rw2 f1 f2 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.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",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Prims.op_AmpAmp",
"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",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"FStar.Pervasives.Native.tuple2",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_reads",
"Vale.Transformers.BoundedInstructionEffects.rw_set_in_series",
"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.X64.Machine_Semantics_s.op_let_Star",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux4",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux3",
"Vale.Transformers.Locations.location",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"FStar.Universe.raise_t",
"Vale.Transformers.Locations.location_val_eqt",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.Mkdtuple2",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes",
"FStar.Classical.arrow_to_impl",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_intersect_belongs_to_writes_union",
"FStar.Classical.forall_intro",
"Prims.l_Forall",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"Vale.Transformers.BoundedInstructionEffects.intersect",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux2",
"Vale.Def.PossiblyMonad.uu___is_Ok",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Vale.Transformers.Locations.eval_location",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series_aux1"
] | [] | 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
(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
(* 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_bounded_effects_series :
rw1:rw_set -> rw2:rw_set ->
f1:st unit -> f2:st unit ->
Lemma
(requires (
(bounded_effects rw1 f1) /\
(bounded_effects rw2 f2)))
(ensures (
let open Vale.X64.Machine_Semantics_s in
(bounded_effects (rw_set_in_series rw1 rw2) (f1;*f2)))) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_bounded_effects_series | {
"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
-> FStar.Pervasives.Lemma
(requires
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw1 f1 /\
Vale.Transformers.BoundedInstructionEffects.bounded_effects rw2 f2)
(ensures
Vale.Transformers.BoundedInstructionEffects.bounded_effects (Vale.Transformers.BoundedInstructionEffects.rw_set_in_series
rw1
rw2)
(( op_let_Star* ) f1 (fun _ -> f2))) | {
"end_col": 36,
"end_line": 1342,
"start_col": 2,
"start_line": 1324
} |
FStar.Pervasives.Lemma | val 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)
) | [
{
"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_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 () | val 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)
)
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)
) = | false | null | true | 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)) | {
"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.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"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",
"FStar.List.Tot.Base.mem",
"Vale.Transformers.Locations.location",
"Vale.Transformers.Locations.ALocOf",
"Prims.bool",
"Vale.X64.Instruction_s.instr_ret_t",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_except_not_mem",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"Vale.X64.Machine_Semantics_s.Mkmachine_state",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs",
"Vale.X64.Machine_Semantics_s.havoc_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",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace",
"FStar.Pervasives.Native.option",
"Vale.X64.Machine_Semantics_s.instr_apply_eval",
"Vale.X64.Instruction_s.instr_eval",
"Vale.Transformers.Locations.ALocCf",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"Prims.l_True",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes",
"Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"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 | 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_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)
) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_constant_on_execution | {
"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
Vale.Transformers.BoundedInstructionEffects.constant_on_execution (Mkrw_set?.loc_constant_writes
(Vale.Transformers.BoundedInstructionEffects.rw_set_of_ins i))
(Vale.X64.Machine_Semantics_s.machine_eval_ins_st i)
s) | {
"end_col": 11,
"end_line": 703,
"start_col": 2,
"start_line": 666
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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 | val 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 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)) = | 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_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)
in
aux rw.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"
} | [
"lemma"
] | [
"Vale.X64.Machine_Semantics_s.ins",
"Prims.nat",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.BoundedInstructionEffects.__proj__Mkrw_set__item__loc_constant_writes",
"Vale.Transformers.BoundedInstructionEffects.locations_with_values",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"Vale.X64.Machine_Semantics_s.machine_eval_ins_st",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.Locations.location_val_eqt",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_ins_st_constant_on_execution",
"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_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",
"Vale.X64.Machine_s.observation",
"Prims.b2t",
"Vale.Transformers.BoundedInstructionEffects.safely_bounded"
] | [] | 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 | 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_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)) | [] | Vale.Transformers.BoundedInstructionEffects.lemma_machine_eval_code_Ins_bounded_effects_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"
} |
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 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.constant_on_execution (Mkrw_set?.loc_constant_writes
rw)
f
s)) | {
"end_col": 28,
"end_line": 775,
"start_col": 60,
"start_line": 759
} |
FStar.Pervasives.Lemma | val 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)) | [
{
"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_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
) | val 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 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)) = | false | null | true | let (| l1 , v1 |) :: xs = locv in
if l = l1 && v = v1 then () else (lemma_constant_on_execution_mem xs f s l v) | {
"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.locations_with_values",
"Vale.X64.Machine_Semantics_s.st",
"Prims.unit",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.location_eq",
"Vale.Transformers.Locations.location_val_eqt",
"Prims.list",
"Vale.Transformers.BoundedInstructionEffects.location_with_value",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Prims.bool",
"Vale.Transformers.BoundedInstructionEffects.lemma_constant_on_execution_mem",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Vale.X64.Machine_Semantics_s.run",
"Vale.Transformers.BoundedInstructionEffects.constant_on_execution",
"FStar.List.Tot.Base.mem",
"Prims.Mkdtuple2",
"Prims.squash",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Vale.Transformers.Locations.raise_location_val_eqt",
"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) /\ | 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_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)) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_constant_on_execution_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"
} |
locv: Vale.Transformers.BoundedInstructionEffects.locations_with_values ->
f: Vale.X64.Machine_Semantics_s.st Prims.unit ->
s: Vale.X64.Machine_Semantics_s.machine_state ->
l: Vale.Transformers.Locations.location_eq ->
v: Vale.Transformers.Locations.location_val_eqt l
-> FStar.Pervasives.Lemma
(requires
Mkmachine_state?.ms_ok (Vale.X64.Machine_Semantics_s.run f s) /\
Vale.Transformers.BoundedInstructionEffects.constant_on_execution locv f s /\
FStar.List.Tot.Base.mem (| l, v |) locv)
(ensures
Vale.Transformers.Locations.eval_location l (Vale.X64.Machine_Semantics_s.run f s) ==
Vale.Transformers.Locations.raise_location_val_eqt v) | {
"end_col": 3,
"end_line": 884,
"start_col": 71,
"start_line": 880
} |
FStar.Pervasives.Lemma | val 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)))) | [
{
"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_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
) | val 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))))
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)))) = | false | null | true | 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) | {
"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_ret_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.Transformers.Locations.location",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write",
"FStar.Pervasives.Native.snd",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.X64.Machine_Semantics_s.instr_write_output_explicit",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.instr_write_output_implicit",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Prims.b2t",
"Vale.Def.PossiblyMonad.op_Bang_Bang",
"Vale.Transformers.Locations.disjoint_location_from_locations",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"Prims.squash",
"Prims.eq2",
"Vale.Transformers.Locations.location_val_t",
"Vale.Transformers.Locations.eval_location",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"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 ( | 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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)))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_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"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
vs: Vale.X64.Instruction_s.instr_ret_t outs ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args ->
s_orig: Vale.X64.Machine_Semantics_s.machine_state ->
s: Vale.X64.Machine_Semantics_s.machine_state ->
a: Vale.Transformers.Locations.location
-> FStar.Pervasives.Lemma
(requires
(let w = Vale.Transformers.BoundedInstructionEffects.aux_write_set outs args oprs in
!!(Vale.Transformers.Locations.disjoint_location_from_locations a w)))
(ensures
Vale.Transformers.Locations.eval_location a s ==
Vale.Transformers.Locations.eval_location a
(Vale.X64.Machine_Semantics_s.instr_write_outputs outs args vs oprs s_orig s)) | {
"end_col": 5,
"end_line": 185,
"start_col": 2,
"start_line": 169
} |
FStar.Pervasives.Lemma | val 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)))) | [
{
"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_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
) | val 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 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)))) = | false | null | true | 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) | {
"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_ret_t",
"Vale.X64.Instruction_s.instr_operands_t",
"Vale.X64.Machine_Semantics_s.machine_state",
"Vale.X64.Instruction_s.instr_operand_inout",
"Vale.X64.Instruction_s.instr_val_t",
"Vale.X64.Instruction_s.instr_operand_explicit",
"Vale.X64.Instruction_s.instr_operand_t",
"Vale.Transformers.Locations.locations",
"Prims.l_or",
"Prims.precedes",
"Prims.l_and",
"Prims.op_Equals_Equals_Equals",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at'_maintained",
"Vale.Transformers.BoundedInstructionEffects.aux_write_set",
"Prims.unit",
"Vale.Transformers.BoundedInstructionEffects.lemma_unchanged_at_append",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Machine_Semantics_s.instr_write_outputs",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_affects_write_extend",
"Prims.Nil",
"Vale.Transformers.Locations.location",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_writes",
"Vale.X64.Machine_Semantics_s.instr_write_output_explicit",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_output_explicit_only_writes",
"Vale.Transformers.BoundedInstructionEffects.aux_read_set1",
"FStar.List.Tot.Base.append",
"Vale.Transformers.BoundedInstructionEffects.locations_of_explicit",
"Vale.X64.Instruction_s.coerce",
"Vale.X64.Instruction_s.instr_operand_implicit",
"Vale.X64.Machine_Semantics_s.instr_write_output_implicit",
"Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_output_implicit_only_writes",
"Vale.Transformers.BoundedInstructionEffects.locations_of_implicit",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at",
"Vale.Transformers.BoundedInstructionEffects.unchanged_at'",
"Prims.b2t",
"Prims.op_Equality",
"Prims.bool",
"Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok",
"Prims.squash",
"Vale.Transformers.BoundedInstructionEffects.unchanged_except",
"Prims.l_imp",
"Prims.op_Negation",
"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' /\ | 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": 400,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val 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)))) | [
"recursion"
] | Vale.Transformers.BoundedInstructionEffects.lemma_instr_write_outputs_only_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"
} |
outs: Prims.list Vale.X64.Instruction_s.instr_out ->
args: Prims.list Vale.X64.Instruction_s.instr_operand ->
vs: Vale.X64.Instruction_s.instr_ret_t outs ->
oprs: Vale.X64.Instruction_s.instr_operands_t outs args ->
s_orig1: Vale.X64.Machine_Semantics_s.machine_state ->
s1: Vale.X64.Machine_Semantics_s.machine_state ->
s_orig2: 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)
s_orig1
s_orig2 /\
Vale.Transformers.BoundedInstructionEffects.unchanged_at' (Vale.Transformers.BoundedInstructionEffects.aux_read_set1
outs
args
oprs)
s1
s2 /\ Mkmachine_state?.ms_ok s1 = Mkmachine_state?.ms_ok s2)
(ensures
(let _ =
Vale.X64.Machine_Semantics_s.instr_write_outputs outs args vs oprs s_orig1 s1,
Vale.X64.Machine_Semantics_s.instr_write_outputs outs args vs oprs s_orig2 s2
in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ s1' s2' = _ in
let locs = Vale.Transformers.BoundedInstructionEffects.aux_write_set outs args oprs in
Vale.Transformers.BoundedInstructionEffects.unchanged_at' locs s1' s2' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except locs s1 s1' /\
Vale.Transformers.BoundedInstructionEffects.unchanged_except locs s2 s2' /\
(Prims.op_Negation (Mkmachine_state?.ms_ok s1) ==>
Prims.op_Negation (Mkmachine_state?.ms_ok s1')) /\
(Prims.op_Negation (Mkmachine_state?.ms_ok s2) ==>
Prims.op_Negation (Mkmachine_state?.ms_ok s2')))
<:
Type0)) | {
"end_col": 5,
"end_line": 572,
"start_col": 46,
"start_line": 507
} |
Prims.Tot | val gf128_mul_BE (a b: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gf128_mul_BE (a b:quad32) : quad32 =
gf128_to_quad32 (gf128_mul (gf128_of_quad32 a) (gf128_of_quad32 b)) | val gf128_mul_BE (a b: quad32) : quad32
let gf128_mul_BE (a b: quad32) : quad32 = | false | null | false | gf128_to_quad32 (gf128_mul (gf128_of_quad32 a) (gf128_of_quad32 b)) | {
"checked_file": "Vale.AES.GHash_BE_s.fst.checked",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GHash_BE_s.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.GF128_s.gf128_to_quad32",
"Vale.AES.GF128_s.gf128_mul",
"Vale.AES.GF128_s.gf128_of_quad32"
] | [] | module Vale.AES.GHash_BE_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.AES.GF128_s
open Vale.Lib.Seqs_s
open FStar.Mul
open FStar.Seq
type ghash_plain_BE:eqtype = s:seq quad32 { length s > 0 } | false | true | Vale.AES.GHash_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gf128_mul_BE (a b: quad32) : quad32 | [] | Vale.AES.GHash_BE_s.gf128_mul_BE | {
"file_name": "vale/specs/crypto/Vale.AES.GHash_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Vale.Def.Types_s.quad32 -> b: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 69,
"end_line": 14,
"start_col": 2,
"start_line": 14
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghash_BE = opaque_make ghash_BE_def | let ghash_BE = | false | null | false | opaque_make ghash_BE_def | {
"checked_file": "Vale.AES.GHash_BE_s.fst.checked",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GHash_BE_s.fst"
} | [
"total"
] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_BE_s.ghash_plain_BE",
"Vale.AES.GHash_BE_s.ghash_BE_def"
] | [] | module Vale.AES.GHash_BE_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.AES.GF128_s
open Vale.Lib.Seqs_s
open FStar.Mul
open FStar.Seq
type ghash_plain_BE:eqtype = s:seq quad32 { length s > 0 }
let gf128_mul_BE (a b:quad32) : quad32 =
gf128_to_quad32 (gf128_mul (gf128_of_quad32 a) (gf128_of_quad32 b))
let rec ghash_BE_def (h_BE:quad32) (x:ghash_plain_BE) : Tot quad32 (decreases %[length x]) =
let y_i_minus_1 =
(if length x = 1 then
Mkfour 0 0 0 0
else
ghash_BE_def h_BE (all_but_last x)) in
let x_i = last x in
let xor_BE = quad32_xor y_i_minus_1 x_i in | false | true | Vale.AES.GHash_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghash_BE : _: Vale.Def.Types_s.quad32 -> _: Vale.AES.GHash_BE_s.ghash_plain_BE
-> Prims.Tot Vale.Def.Types_s.quad32 | [] | Vale.AES.GHash_BE_s.ghash_BE | {
"file_name": "vale/specs/crypto/Vale.AES.GHash_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Vale.Def.Types_s.quad32 -> _: Vale.AES.GHash_BE_s.ghash_plain_BE
-> Prims.Tot Vale.Def.Types_s.quad32 | {
"end_col": 58,
"end_line": 25,
"start_col": 34,
"start_line": 25
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ghash_BE_reveal = opaque_revealer (`%ghash_BE) ghash_BE ghash_BE_def | let ghash_BE_reveal = | false | null | true | opaque_revealer (`%ghash_BE) ghash_BE ghash_BE_def | {
"checked_file": "Vale.AES.GHash_BE_s.fst.checked",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GHash_BE_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_BE_s.ghash_plain_BE",
"Vale.AES.GHash_BE_s.ghash_BE",
"Vale.AES.GHash_BE_s.ghash_BE_def"
] | [] | module Vale.AES.GHash_BE_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.AES.GF128_s
open Vale.Lib.Seqs_s
open FStar.Mul
open FStar.Seq
type ghash_plain_BE:eqtype = s:seq quad32 { length s > 0 }
let gf128_mul_BE (a b:quad32) : quad32 =
gf128_to_quad32 (gf128_mul (gf128_of_quad32 a) (gf128_of_quad32 b))
let rec ghash_BE_def (h_BE:quad32) (x:ghash_plain_BE) : Tot quad32 (decreases %[length x]) =
let y_i_minus_1 =
(if length x = 1 then
Mkfour 0 0 0 0
else
ghash_BE_def h_BE (all_but_last x)) in
let x_i = last x in
let xor_BE = quad32_xor y_i_minus_1 x_i in
gf128_mul_BE xor_BE h_BE | false | false | Vale.AES.GHash_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghash_BE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GHash_BE_s.ghash_BE == Vale.AES.GHash_BE_s.ghash_BE_def) | [] | Vale.AES.GHash_BE_s.ghash_BE_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.GHash_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GHash_BE_s.ghash_BE == Vale.AES.GHash_BE_s.ghash_BE_def) | {
"end_col": 84,
"end_line": 26,
"start_col": 34,
"start_line": 26
} |
|
Prims.Tot | val ghash_BE_def (h_BE: quad32) (x: ghash_plain_BE) : Tot quad32 (decreases %[length x]) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec ghash_BE_def (h_BE:quad32) (x:ghash_plain_BE) : Tot quad32 (decreases %[length x]) =
let y_i_minus_1 =
(if length x = 1 then
Mkfour 0 0 0 0
else
ghash_BE_def h_BE (all_but_last x)) in
let x_i = last x in
let xor_BE = quad32_xor y_i_minus_1 x_i in
gf128_mul_BE xor_BE h_BE | val ghash_BE_def (h_BE: quad32) (x: ghash_plain_BE) : Tot quad32 (decreases %[length x])
let rec ghash_BE_def (h_BE: quad32) (x: ghash_plain_BE) : Tot quad32 (decreases %[length x]) = | false | null | false | let y_i_minus_1 = (if length x = 1 then Mkfour 0 0 0 0 else ghash_BE_def h_BE (all_but_last x)) in
let x_i = last x in
let xor_BE = quad32_xor y_i_minus_1 x_i in
gf128_mul_BE xor_BE h_BE | {
"checked_file": "Vale.AES.GHash_BE_s.fst.checked",
"dependencies": [
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GHash_BE_s.fst"
} | [
"total",
""
] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.GHash_BE_s.ghash_plain_BE",
"Vale.AES.GHash_BE_s.gf128_mul_BE",
"Vale.Def.Types_s.quad32_xor",
"FStar.Seq.Properties.last",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Prims.bool",
"Vale.AES.GHash_BE_s.ghash_BE_def",
"Vale.Lib.Seqs_s.all_but_last"
] | [] | module Vale.AES.GHash_BE_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.AES.GF128_s
open Vale.Lib.Seqs_s
open FStar.Mul
open FStar.Seq
type ghash_plain_BE:eqtype = s:seq quad32 { length s > 0 }
let gf128_mul_BE (a b:quad32) : quad32 =
gf128_to_quad32 (gf128_mul (gf128_of_quad32 a) (gf128_of_quad32 b)) | false | true | Vale.AES.GHash_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val ghash_BE_def (h_BE: quad32) (x: ghash_plain_BE) : Tot quad32 (decreases %[length x]) | [
"recursion"
] | Vale.AES.GHash_BE_s.ghash_BE_def | {
"file_name": "vale/specs/crypto/Vale.AES.GHash_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h_BE: Vale.Def.Types_s.quad32 -> x: Vale.AES.GHash_BE_s.ghash_plain_BE
-> Prims.Tot Vale.Def.Types_s.quad32 | {
"end_col": 26,
"end_line": 24,
"start_col": 92,
"start_line": 16
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 cons #a (x:a) (s:seq a) = singleton x `append` s | let cons #a (x: a) (s: seq a) = | false | null | false | (singleton x) `append` s | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"FStar.Sequence.Base.append",
"FStar.Sequence.Base.singleton"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i | false | false | FStar.Sequence.Util.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 cons : x: a -> s: FStar.Sequence.Base.seq a -> FStar.Sequence.Base.seq a | [] | FStar.Sequence.Util.cons | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> s: FStar.Sequence.Base.seq a -> FStar.Sequence.Base.seq a | {
"end_col": 52,
"end_line": 30,
"start_col": 30,
"start_line": 30
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 count (#a:eqtype) (x:a) (s:seq a) = count_matches (fun y -> x = y) s | let count (#a: eqtype) (x: a) (s: seq a) = | false | null | false | count_matches (fun y -> x = y) s | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"Prims.eqtype",
"FStar.Sequence.Base.seq",
"FStar.Sequence.Util.count_matches",
"Prims.op_Equality",
"Prims.bool",
"Prims.nat"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s)
/// count_matches on an empty sequence is always zero
let count_matches_empty (a:Type) (f:a -> bool) (s:seq a{length s = 0})
: Lemma (count_matches f s = 0)
= ()
/// count is a specialization of count_matches
/// to count the number of occurrences of a given element `x` in `s`.
///
/// It is opaque to give control over its unrollings in specific proofs | false | false | FStar.Sequence.Util.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 count : x: a -> s: FStar.Sequence.Base.seq a -> Prims.nat | [] | FStar.Sequence.Util.count | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> s: FStar.Sequence.Base.seq a -> Prims.nat | {
"end_col": 72,
"end_line": 67,
"start_col": 40,
"start_line": 67
} |
|
Prims.Tot | val split (#a: _) (s: seq a) (i: nat{i <= length s}) : seq a & seq a | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i | val split (#a: _) (s: seq a) (i: nat{i <= length s}) : seq a & seq a
let split #a (s: seq a) (i: nat{i <= length s}) : seq a & seq a = | false | null | false | take s i, drop s i | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Sequence.Base.length",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Sequence.Base.take",
"FStar.Sequence.Base.drop",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s}) | false | false | FStar.Sequence.Util.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 split (#a: _) (s: seq a) (i: nat{i <= length s}) : seq a & seq a | [] | FStar.Sequence.Util.split | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a -> i: Prims.nat{i <= FStar.Sequence.Base.length s}
-> FStar.Sequence.Base.seq a * FStar.Sequence.Base.seq a | {
"end_col": 12,
"end_line": 46,
"start_col": 4,
"start_line": 45
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 head #a (s:seq a{length s > 0}) = s $@ 0 | let head #a (s: seq a {length s > 0}) = | false | null | false | s $@ 0 | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Sequence.Base.length",
"FStar.Sequence.Base.op_Dollar_At"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s | false | false | FStar.Sequence.Util.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 head : s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> a | [] | FStar.Sequence.Util.head | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> a | {
"end_col": 44,
"end_line": 32,
"start_col": 38,
"start_line": 32
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 tail #a (s:seq a{length s > 0}) = drop s 1 | let tail #a (s: seq a {length s > 0}) = | false | null | false | drop s 1 | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Sequence.Base.length",
"FStar.Sequence.Base.drop"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0 | false | false | FStar.Sequence.Util.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 tail : s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> FStar.Sequence.Base.seq a | [] | FStar.Sequence.Util.tail | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> FStar.Sequence.Base.seq a | {
"end_col": 46,
"end_line": 34,
"start_col": 38,
"start_line": 34
} |
|
Prims.Tot | val slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s}) : seq ty | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i | val slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s}) : seq ty
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s}) : seq ty = | false | null | false | all_seq_facts_lemma ();
drop (take s j) i | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_AmpAmp",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"FStar.Sequence.Base.length",
"FStar.Sequence.Base.drop",
"FStar.Sequence.Base.take",
"Prims.unit",
"FStar.Sequence.Base.all_seq_facts_lemma"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s}) | false | false | FStar.Sequence.Util.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 slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s}) : seq ty | [] | FStar.Sequence.Util.slice | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
s: FStar.Sequence.Base.seq ty ->
i: Prims.nat ->
j: Prims.nat{j >= i && j <= FStar.Sequence.Base.length s}
-> FStar.Sequence.Base.seq ty | {
"end_col": 21,
"end_line": 28,
"start_col": 4,
"start_line": 27
} |
FStar.Pervasives.Lemma | val count_empty (#a: eqtype) (s: seq a {length s = 0}) : Lemma (forall x. count x s = 0) | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 count_empty (#a:eqtype) (s:seq a{length s = 0})
: Lemma (forall x. count x s = 0)
= reveal_opaque (`%count) (count #a) | val count_empty (#a: eqtype) (s: seq a {length s = 0}) : Lemma (forall x. count x s = 0)
let count_empty (#a: eqtype) (s: seq a {length s = 0}) : Lemma (forall x. count x s = 0) = | false | null | true | reveal_opaque (`%count) (count #a) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"lemma"
] | [
"Prims.eqtype",
"FStar.Sequence.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"FStar.Sequence.Base.length",
"FStar.Pervasives.reveal_opaque",
"Prims.nat",
"FStar.Sequence.Util.count",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.l_Forall",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s)
/// count_matches on an empty sequence is always zero
let count_matches_empty (a:Type) (f:a -> bool) (s:seq a{length s = 0})
: Lemma (count_matches f s = 0)
= ()
/// count is a specialization of count_matches
/// to count the number of occurrences of a given element `x` in `s`.
///
/// It is opaque to give control over its unrollings in specific proofs
[@@"opaque_to_smt"]
let count (#a:eqtype) (x:a) (s:seq a) = count_matches (fun y -> x = y) s
/// A specializtion of count_matches_empty
let count_empty (#a:eqtype) (s:seq a{length s = 0}) | false | false | FStar.Sequence.Util.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 count_empty (#a: eqtype) (s: seq a {length s = 0}) : Lemma (forall x. count x s = 0) | [] | FStar.Sequence.Util.count_empty | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s = 0}
-> FStar.Pervasives.Lemma (ensures forall (x: a). FStar.Sequence.Util.count x s = 0) | {
"end_col": 38,
"end_line": 72,
"start_col": 4,
"start_line": 72
} |
Prims.Tot | val un_build (#a: _) (s: seq a {length s > 0}) : seq a & a | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1) | val un_build (#a: _) (s: seq a {length s > 0}) : seq a & a
let un_build (#a: _) (s: seq a {length s > 0}) : seq a & a = | false | null | false | take s (length s - 1), s $@ (length s - 1) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total"
] | [
"FStar.Sequence.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Sequence.Base.length",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Sequence.Base.take",
"Prims.op_Subtraction",
"FStar.Sequence.Base.op_Dollar_At",
"FStar.Pervasives.Native.tuple2"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0}) | false | false | FStar.Sequence.Util.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 un_build (#a: _) (s: seq a {length s > 0}) : seq a & a | [] | FStar.Sequence.Util.un_build | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0} -> FStar.Sequence.Base.seq a * a | {
"end_col": 23,
"end_line": 41,
"start_col": 4,
"start_line": 40
} |
FStar.Pervasives.Lemma | val count_head (#a: eqtype) (s: seq a {length s > 0}) : Lemma (count (head s) s > 0) | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 count_head (#a:eqtype) (s:seq a{length s > 0})
: Lemma (count (head s) s > 0)
= reveal_opaque (`%count) (count #a) | val count_head (#a: eqtype) (s: seq a {length s > 0}) : Lemma (count (head s) s > 0)
let count_head (#a: eqtype) (s: seq a {length s > 0}) : Lemma (count (head s) s > 0) = | false | null | true | reveal_opaque (`%count) (count #a) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"lemma"
] | [
"Prims.eqtype",
"FStar.Sequence.Base.seq",
"Prims.b2t",
"Prims.op_GreaterThan",
"FStar.Sequence.Base.length",
"FStar.Pervasives.reveal_opaque",
"Prims.nat",
"FStar.Sequence.Util.count",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"FStar.Sequence.Util.head",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s)
/// count_matches on an empty sequence is always zero
let count_matches_empty (a:Type) (f:a -> bool) (s:seq a{length s = 0})
: Lemma (count_matches f s = 0)
= ()
/// count is a specialization of count_matches
/// to count the number of occurrences of a given element `x` in `s`.
///
/// It is opaque to give control over its unrollings in specific proofs
[@@"opaque_to_smt"]
let count (#a:eqtype) (x:a) (s:seq a) = count_matches (fun y -> x = y) s
/// A specializtion of count_matches_empty
let count_empty (#a:eqtype) (s:seq a{length s = 0})
: Lemma (forall x. count x s = 0)
= reveal_opaque (`%count) (count #a)
/// The head element always occurs in a non-empty list
let count_head (#a:eqtype) (s:seq a{length s > 0}) | false | false | FStar.Sequence.Util.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 count_head (#a: eqtype) (s: seq a {length s > 0}) : Lemma (count (head s) s > 0) | [] | FStar.Sequence.Util.count_head | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: FStar.Sequence.Base.seq a {FStar.Sequence.Base.length s > 0}
-> FStar.Pervasives.Lemma (ensures FStar.Sequence.Util.count (FStar.Sequence.Util.head s) s > 0) | {
"end_col": 38,
"end_line": 77,
"start_col": 4,
"start_line": 77
} |
Prims.Tot | val fold_back (#a #b: Type) (f: (b -> a -> Tot a)) (s: seq b) (init: a)
: Tot a (decreases (length s)) | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 fold_back (#a #b:Type) (f:b -> a -> Tot a) (s:seq b) (init:a)
: Tot a (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then init
else let last = s $@ (length s - 1) in
let s = take s (length s - 1) in
f last (fold_back f s init) | val fold_back (#a #b: Type) (f: (b -> a -> Tot a)) (s: seq b) (init: a)
: Tot a (decreases (length s))
let rec fold_back (#a #b: Type) (f: (b -> a -> Tot a)) (s: seq b) (init: a)
: Tot a (decreases (length s)) = | false | null | false | all_seq_facts_lemma ();
if length s = 0
then init
else
let last = s $@ (length s - 1) in
let s = take s (length s - 1) in
f last (fold_back f s init) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total",
""
] | [
"FStar.Sequence.Base.seq",
"Prims.op_Equality",
"Prims.int",
"FStar.Sequence.Base.length",
"Prims.bool",
"FStar.Sequence.Util.fold_back",
"FStar.Sequence.Base.take",
"Prims.op_Subtraction",
"FStar.Sequence.Base.op_Dollar_At",
"Prims.unit",
"FStar.Sequence.Base.all_seq_facts_lemma"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s)
/// count_matches on an empty sequence is always zero
let count_matches_empty (a:Type) (f:a -> bool) (s:seq a{length s = 0})
: Lemma (count_matches f s = 0)
= ()
/// count is a specialization of count_matches
/// to count the number of occurrences of a given element `x` in `s`.
///
/// It is opaque to give control over its unrollings in specific proofs
[@@"opaque_to_smt"]
let count (#a:eqtype) (x:a) (s:seq a) = count_matches (fun y -> x = y) s
/// A specializtion of count_matches_empty
let count_empty (#a:eqtype) (s:seq a{length s = 0})
: Lemma (forall x. count x s = 0)
= reveal_opaque (`%count) (count #a)
/// The head element always occurs in a non-empty list
let count_head (#a:eqtype) (s:seq a{length s > 0})
: Lemma (count (head s) s > 0)
= reveal_opaque (`%count) (count #a)
/// count sums over append
let rec lemma_append_count_aux (#a:eqtype) (x:a) (lo hi:seq a)
: Lemma
(ensures (count x (append lo hi) = (count x lo + count x hi)))
(decreases (length lo))
= all_seq_facts_lemma();
reveal_opaque (`%count) (count #a);
if length lo = 0
then assert (append lo hi `equal` hi)
else (
lemma_append_count_aux x (tail lo) hi;
assert (append (tail lo) hi `equal` tail (append lo hi))
)
/// Folding a function over a sequence, starting from its
/// last element, hence fold_back
let rec fold_back (#a #b:Type) (f:b -> a -> Tot a) (s:seq b) (init:a) | false | false | FStar.Sequence.Util.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 fold_back (#a #b: Type) (f: (b -> a -> Tot a)) (s: seq b) (init: a)
: Tot a (decreases (length s)) | [
"recursion"
] | FStar.Sequence.Util.fold_back | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: b -> _: a -> a) -> s: FStar.Sequence.Base.seq b -> init: a -> Prims.Tot a | {
"end_col": 36,
"end_line": 102,
"start_col": 4,
"start_line": 98
} |
Prims.Tot | val count_matches (#a: Type) (f: (a -> bool)) (s: seq a) : Tot nat (decreases (length s)) | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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 count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s) | val count_matches (#a: Type) (f: (a -> bool)) (s: seq a) : Tot nat (decreases (length s))
let rec count_matches (#a: Type) (f: (a -> bool)) (s: seq a) : Tot nat (decreases (length s)) = | false | null | false | all_seq_facts_lemma ();
if length s = 0
then 0
else if f (head s) then 1 + count_matches f (tail s) else count_matches f (tail s) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"total",
""
] | [
"Prims.bool",
"FStar.Sequence.Base.seq",
"Prims.op_Equality",
"Prims.int",
"FStar.Sequence.Base.length",
"FStar.Sequence.Util.head",
"Prims.op_Addition",
"FStar.Sequence.Util.count_matches",
"FStar.Sequence.Util.tail",
"Prims.nat",
"Prims.unit",
"FStar.Sequence.Base.all_seq_facts_lemma"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a) | false | false | FStar.Sequence.Util.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 count_matches (#a: Type) (f: (a -> bool)) (s: seq a) : Tot nat (decreases (length s)) | [
"recursion"
] | FStar.Sequence.Util.count_matches | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | f: (_: a -> Prims.bool) -> s: FStar.Sequence.Base.seq a -> Prims.Tot Prims.nat | {
"end_col": 33,
"end_line": 55,
"start_col": 4,
"start_line": 52
} |
FStar.Pervasives.Lemma | val lemma_append_count_aux (#a: eqtype) (x: a) (lo hi: seq a)
: Lemma (ensures (count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) | [
{
"abbrev": false,
"full_module": "FStar.Sequence.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Sequence",
"short_module": null
},
{
"abbrev": 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_append_count_aux (#a:eqtype) (x:a) (lo hi:seq a)
: Lemma
(ensures (count x (append lo hi) = (count x lo + count x hi)))
(decreases (length lo))
= all_seq_facts_lemma();
reveal_opaque (`%count) (count #a);
if length lo = 0
then assert (append lo hi `equal` hi)
else (
lemma_append_count_aux x (tail lo) hi;
assert (append (tail lo) hi `equal` tail (append lo hi))
) | val lemma_append_count_aux (#a: eqtype) (x: a) (lo hi: seq a)
: Lemma (ensures (count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo))
let rec lemma_append_count_aux (#a: eqtype) (x: a) (lo hi: seq a)
: Lemma (ensures (count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) = | false | null | true | all_seq_facts_lemma ();
reveal_opaque (`%count) (count #a);
if length lo = 0
then assert ((append lo hi) `equal` hi)
else
(lemma_append_count_aux x (tail lo) hi;
assert ((append (tail lo) hi) `equal` (tail (append lo hi)))) | {
"checked_file": "FStar.Sequence.Util.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Sequence.Base.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.Sequence.Util.fst"
} | [
"lemma",
""
] | [
"Prims.eqtype",
"FStar.Sequence.Base.seq",
"Prims.op_Equality",
"Prims.int",
"FStar.Sequence.Base.length",
"Prims._assert",
"FStar.Sequence.Base.equal",
"FStar.Sequence.Base.append",
"Prims.bool",
"FStar.Sequence.Util.tail",
"Prims.unit",
"FStar.Sequence.Util.lemma_append_count_aux",
"FStar.Pervasives.reveal_opaque",
"Prims.nat",
"FStar.Sequence.Util.count",
"FStar.Sequence.Base.all_seq_facts_lemma",
"Prims.l_True",
"Prims.squash",
"Prims.b2t",
"Prims.op_Addition",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2021 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: N. Swamy
*)
(** This module provides some utilities on top of FStar.Sequence *)
module FStar.Sequence.Util
open FStar.Sequence.Base
/// For convenience, we define `slice` to represent Dafny sequence slices.
let slice (#ty: Type) (s: seq ty) (i: nat) (j: nat{j >= i && j <= length s})
: seq ty
= all_seq_facts_lemma();
drop (take s j) i
let cons #a (x:a) (s:seq a) = singleton x `append` s
let head #a (s:seq a{length s > 0}) = s $@ 0
let tail #a (s:seq a{length s > 0}) = drop s 1
/// Split a sequences into a prefix and the last element
/// This is the inverse of the Sequence.build
let un_build (#a:_) (s:seq a{length s > 0})
: seq a & a
= take s (length s - 1),
s $@ (length s - 1)
let split #a (s:seq a) (i:nat{ i <= length s})
: seq a & seq a
= take s i,
drop s i
/// Counts the number of elements of `s` that
/// satisfy the predicate [f]
let rec count_matches (#a:Type) (f:a -> bool) (s:seq a)
: Tot nat (decreases (length s))
= all_seq_facts_lemma();
if length s = 0 then 0
else if f (head s) then 1 + count_matches f (tail s)
else count_matches f (tail s)
/// count_matches on an empty sequence is always zero
let count_matches_empty (a:Type) (f:a -> bool) (s:seq a{length s = 0})
: Lemma (count_matches f s = 0)
= ()
/// count is a specialization of count_matches
/// to count the number of occurrences of a given element `x` in `s`.
///
/// It is opaque to give control over its unrollings in specific proofs
[@@"opaque_to_smt"]
let count (#a:eqtype) (x:a) (s:seq a) = count_matches (fun y -> x = y) s
/// A specializtion of count_matches_empty
let count_empty (#a:eqtype) (s:seq a{length s = 0})
: Lemma (forall x. count x s = 0)
= reveal_opaque (`%count) (count #a)
/// The head element always occurs in a non-empty list
let count_head (#a:eqtype) (s:seq a{length s > 0})
: Lemma (count (head s) s > 0)
= reveal_opaque (`%count) (count #a)
/// count sums over append
let rec lemma_append_count_aux (#a:eqtype) (x:a) (lo hi:seq a)
: Lemma
(ensures (count x (append lo hi) = (count x lo + count x hi))) | false | false | FStar.Sequence.Util.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 lemma_append_count_aux (#a: eqtype) (x: a) (lo hi: seq a)
: Lemma (ensures (count x (append lo hi) = (count x lo + count x hi))) (decreases (length lo)) | [
"recursion"
] | FStar.Sequence.Util.lemma_append_count_aux | {
"file_name": "ulib/experimental/FStar.Sequence.Util.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: a -> lo: FStar.Sequence.Base.seq a -> hi: FStar.Sequence.Base.seq a
-> FStar.Pervasives.Lemma
(ensures
FStar.Sequence.Util.count x (FStar.Sequence.Base.append lo hi) =
FStar.Sequence.Util.count x lo + FStar.Sequence.Util.count x hi)
(decreases FStar.Sequence.Base.length lo) | {
"end_col": 5,
"end_line": 91,
"start_col": 4,
"start_line": 84
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": 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_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin)) | let add_carry_st (t: inttype{t = U32 \/ t = U64}) = | false | null | false | cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1)
-> Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures
fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin)) | {
"checked_file": "Lib.IntTypes.Intrinsics.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.Intrinsics.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.index",
"Lib.Buffer.as_seq"
] | [] | module Lib.IntTypes.Intrinsics
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
inline_for_extraction | false | false | Lib.IntTypes.Intrinsics.fsti | {
"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_carry_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | [] | Lib.IntTypes.Intrinsics.add_carry_st | {
"file_name": "lib/Lib.IntTypes.Intrinsics.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | {
"end_col": 52,
"end_line": 24,
"start_col": 4,
"start_line": 15
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": 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_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin)) | let sub_borrow_st (t: inttype{t = U32 \/ t = U64}) = | false | null | false | cin: uint_t t SEC -> x: uint_t t SEC -> y: uint_t t SEC -> r: lbuffer (uint_t t SEC) (size 1)
-> Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures
fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin)) | {
"checked_file": "Lib.IntTypes.Intrinsics.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.Intrinsics.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.size",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.v",
"Lib.Buffer.modifies1",
"Prims.eq2",
"Prims.int",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.bits",
"Lib.IntTypes.int_t",
"FStar.Seq.Base.index",
"Lib.Buffer.as_seq"
] | [] | module Lib.IntTypes.Intrinsics
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
inline_for_extraction
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
val add_carry_u64: add_carry_st U64
inline_for_extraction
let add_carry (#t:inttype{t = U32 \/ t = U64}) : add_carry_st t =
match t with
| U32 -> add_carry_u32
| U64 -> add_carry_u64
inline_for_extraction | false | false | Lib.IntTypes.Intrinsics.fsti | {
"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_borrow_st : t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | [] | Lib.IntTypes.Intrinsics.sub_borrow_st | {
"file_name": "lib/Lib.IntTypes.Intrinsics.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntTypes.inttype{t = Lib.IntTypes.U32 \/ t = Lib.IntTypes.U64} -> Type0 | {
"end_col": 52,
"end_line": 50,
"start_col": 4,
"start_line": 41
} |
|
Prims.Tot | val add_carry (#t: inttype{t = U32 \/ t = U64}) : add_carry_st t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": 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_carry (#t:inttype{t = U32 \/ t = U64}) : add_carry_st t =
match t with
| U32 -> add_carry_u32
| U64 -> add_carry_u64 | val add_carry (#t: inttype{t = U32 \/ t = U64}) : add_carry_st t
let add_carry (#t: inttype{t = U32 \/ t = U64}) : add_carry_st t = | false | null | false | match t with
| U32 -> add_carry_u32
| U64 -> add_carry_u64 | {
"checked_file": "Lib.IntTypes.Intrinsics.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.Intrinsics.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.Intrinsics.add_carry_u32",
"Lib.IntTypes.Intrinsics.add_carry_u64",
"Lib.IntTypes.Intrinsics.add_carry_st"
] | [] | module Lib.IntTypes.Intrinsics
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
inline_for_extraction
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
val add_carry_u64: add_carry_st U64
inline_for_extraction | false | false | Lib.IntTypes.Intrinsics.fsti | {
"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_carry (#t: inttype{t = U32 \/ t = U64}) : add_carry_st t | [] | Lib.IntTypes.Intrinsics.add_carry | {
"file_name": "lib/Lib.IntTypes.Intrinsics.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.IntTypes.Intrinsics.add_carry_st t | {
"end_col": 24,
"end_line": 36,
"start_col": 2,
"start_line": 34
} |
Prims.Tot | val sub_borrow (#t: inttype{t = U32 \/ t = U64}) : sub_borrow_st t | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": 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_borrow (#t:inttype{t = U32 \/ t = U64}) : sub_borrow_st t =
match t with
| U32 -> sub_borrow_u32
| U64 -> sub_borrow_u64 | val sub_borrow (#t: inttype{t = U32 \/ t = U64}) : sub_borrow_st t
let sub_borrow (#t: inttype{t = U32 \/ t = U64}) : sub_borrow_st t = | false | null | false | match t with
| U32 -> sub_borrow_u32
| U64 -> sub_borrow_u64 | {
"checked_file": "Lib.IntTypes.Intrinsics.fsti.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntTypes.Intrinsics.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Lib.IntTypes.U32",
"Lib.IntTypes.U64",
"Lib.IntTypes.Intrinsics.sub_borrow_u32",
"Lib.IntTypes.Intrinsics.sub_borrow_u64",
"Lib.IntTypes.Intrinsics.sub_borrow_st"
] | [] | module Lib.IntTypes.Intrinsics
open FStar.HyperStack
open FStar.HyperStack.All
open Lib.IntTypes
open Lib.Buffer
open FStar.Mul
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
inline_for_extraction
let add_carry_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r + v c * pow2 (bits t) == v x + v y + v cin))
val add_carry_u32: add_carry_st U32
val add_carry_u64: add_carry_st U64
inline_for_extraction
let add_carry (#t:inttype{t = U32 \/ t = U64}) : add_carry_st t =
match t with
| U32 -> add_carry_u32
| U64 -> add_carry_u64
inline_for_extraction
let sub_borrow_st (t:inttype{t = U32 \/ t = U64}) =
cin:uint_t t SEC
-> x:uint_t t SEC
-> y:uint_t t SEC
-> r:lbuffer (uint_t t SEC) (size 1) ->
Stack (uint_t t SEC)
(requires fun h -> live h r /\ v cin <= 1)
(ensures fun h0 c h1 ->
modifies1 r h0 h1 /\ v c <= 1 /\
(let r = Seq.index (as_seq h1 r) 0 in
v r - v c * pow2 (bits t) == v x - v y - v cin))
val sub_borrow_u32: sub_borrow_st U32
val sub_borrow_u64: sub_borrow_st U64
inline_for_extraction | false | false | Lib.IntTypes.Intrinsics.fsti | {
"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_borrow (#t: inttype{t = U32 \/ t = U64}) : sub_borrow_st t | [] | Lib.IntTypes.Intrinsics.sub_borrow | {
"file_name": "lib/Lib.IntTypes.Intrinsics.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.IntTypes.Intrinsics.sub_borrow_st t | {
"end_col": 25,
"end_line": 62,
"start_col": 2,
"start_line": 60
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32} | let width = | false | null | false | n: size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32} | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntTypes.size_nat",
"Prims.l_or",
"Prims.eq2",
"Prims.int"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)} | false | true | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val width : Type0 | [] | Lib.IntVector.width | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 82,
"end_line": 11,
"start_col": 12,
"start_line": 11
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vec_index (w:width) = n:size_t{v n < w} | let vec_index (w: width) = | false | null | false | n: size_t{v n < w} | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.width",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)} | false | true | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vec_index : w: Lib.IntVector.width -> Type0 | [] | Lib.IntVector.vec_index | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | w: Lib.IntVector.width -> Type0 | {
"end_col": 43,
"end_line": 12,
"start_col": 26,
"start_line": 12
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v_inttype = t:inttype{unsigned t /\ ~(U1? t)} | let v_inttype = | false | null | false | t: inttype{unsigned t /\ ~(U1? t)} | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntTypes.inttype",
"Prims.l_and",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Prims.l_not",
"Lib.IntTypes.uu___is_U1"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0" | false | true | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val v_inttype : Type0 | [] | Lib.IntVector.v_inttype | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 49,
"end_line": 9,
"start_col": 16,
"start_line": 9
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( +| ) #t #w = vec_add_mod #t #w | let op_Plus_Bar #t #w = | false | null | false | vec_add_mod #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_add_mod",
"Lib.IntVector.vec_t"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1 | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Plus_Bar : v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Plus_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 36,
"end_line": 320,
"start_col": 19,
"start_line": 320
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( ^| ) #t #w = vec_xor #t #w | let op_Hat_Bar #t #w = | false | null | false | vec_xor #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_xor",
"Lib.IntVector.vec_t"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Hat_Bar : v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Hat_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 32,
"end_line": 326,
"start_col": 19,
"start_line": 326
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >>>| ) #t #w = vec_rotate_right #t #w | let op_Greater_Greater_Greater_Bar #t #w = | false | null | false | vec_rotate_right #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_rotate_right",
"Lib.IntVector.vec_t",
"Lib.IntTypes.rotval",
"Prims.l_or",
"Prims.b2t",
"Prims.op_disEquality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U128",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w
inline_for_extraction
let ( &| ) #t #w = vec_and #t #w
//inline_for_extraction
//let ( || ) #t #w = vec_or #t #w
inline_for_extraction
let ( ~| ) #t #w = vec_not #t #w
inline_for_extraction
let ( >>| ) #t #w = vec_shift_right #t #w
inline_for_extraction
let ( <<| ) #t #w = vec_shift_left #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Greater_Greater_Bar : v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.rotval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Greater_Greater_Greater_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.rotval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> Lib.IntVector.vec_t t w | {
"end_col": 43,
"end_line": 338,
"start_col": 21,
"start_line": 338
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( ~| ) #t #w = vec_not #t #w | let op_Tilde_Bar #t #w = | false | null | false | vec_not #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_not",
"Lib.IntVector.vec_t"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w
inline_for_extraction
let ( &| ) #t #w = vec_and #t #w
//inline_for_extraction
//let ( || ) #t #w = vec_or #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Tilde_Bar : v1: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Tilde_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 32,
"end_line": 332,
"start_col": 19,
"start_line": 332
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( >>| ) #t #w = vec_shift_right #t #w | let op_Greater_Greater_Bar #t #w = | false | null | false | vec_shift_right #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_shift_right",
"Lib.IntVector.vec_t",
"Lib.IntTypes.shiftval",
"Prims.l_or",
"Prims.b2t",
"Prims.op_disEquality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U128",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntVector.vec_v",
"Lib.Sequence.map",
"Lib.IntTypes.shift_right_i"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w
inline_for_extraction
let ( &| ) #t #w = vec_and #t #w
//inline_for_extraction
//let ( || ) #t #w = vec_or #t #w
inline_for_extraction
let ( ~| ) #t #w = vec_not #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Greater_Greater_Bar : v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.shiftval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> v2:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v2 ==
Lib.Sequence.map (Lib.IntTypes.shift_right_i s) (Lib.IntVector.vec_v v1) } | [] | Lib.IntVector.op_Greater_Greater_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.shiftval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> v2:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v2 ==
Lib.Sequence.map (Lib.IntTypes.shift_right_i s) (Lib.IntVector.vec_v v1) } | {
"end_col": 41,
"end_line": 334,
"start_col": 20,
"start_line": 334
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( -| ) #t #w = vec_sub_mod #t #w | let op_Subtraction_Bar #t #w = | false | null | false | vec_sub_mod #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_sub_mod",
"Lib.IntVector.vec_t",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntVector.vec_v",
"Lib.Sequence.map2",
"Lib.IntTypes.sub_mod"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Subtraction_Bar : v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w
-> v3:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v3 ==
Lib.Sequence.map2 Lib.IntTypes.sub_mod (Lib.IntVector.vec_v v1) (Lib.IntVector.vec_v v2) } | [] | Lib.IntVector.op_Subtraction_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w
-> v3:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v3 ==
Lib.Sequence.map2 Lib.IntTypes.sub_mod (Lib.IntVector.vec_v v1) (Lib.IntVector.vec_v v2) } | {
"end_col": 36,
"end_line": 322,
"start_col": 19,
"start_line": 322
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( &| ) #t #w = vec_and #t #w | let op_Amp_Bar #t #w = | false | null | false | vec_and #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_and",
"Lib.IntVector.vec_t"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Amp_Bar : v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Amp_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 32,
"end_line": 328,
"start_col": 19,
"start_line": 328
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <<| ) #t #w = vec_shift_left #t #w | let op_Less_Less_Bar #t #w = | false | null | false | vec_shift_left #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_shift_left",
"Lib.IntVector.vec_t",
"Lib.IntTypes.shiftval",
"Prims.l_or",
"Prims.b2t",
"Prims.op_disEquality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U128",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntVector.vec_v",
"Lib.Sequence.map",
"Lib.IntTypes.shift_left_i"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w
inline_for_extraction
let ( &| ) #t #w = vec_and #t #w
//inline_for_extraction
//let ( || ) #t #w = vec_or #t #w
inline_for_extraction
let ( ~| ) #t #w = vec_not #t #w
inline_for_extraction
let ( >>| ) #t #w = vec_shift_right #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Less_Bar : v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.shiftval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> v2:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v2 ==
Lib.Sequence.map (Lib.IntTypes.shift_left_i s) (Lib.IntVector.vec_v v1) } | [] | Lib.IntVector.op_Less_Less_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.shiftval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> v2:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v2 ==
Lib.Sequence.map (Lib.IntTypes.shift_left_i s) (Lib.IntVector.vec_v v1) } | {
"end_col": 40,
"end_line": 336,
"start_col": 20,
"start_line": 336
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( <<<| ) #t #w = vec_rotate_left #t #w | let op_Less_Less_Less_Bar #t #w = | false | null | false | vec_rotate_left #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_rotate_left",
"Lib.IntVector.vec_t",
"Lib.IntTypes.rotval",
"Prims.l_or",
"Prims.b2t",
"Prims.op_disEquality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U128",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w
inline_for_extraction
let ( *| ) #t #w = vec_mul_mod #t #w
inline_for_extraction
let ( ^| ) #t #w = vec_xor #t #w
inline_for_extraction
let ( &| ) #t #w = vec_and #t #w
//inline_for_extraction
//let ( || ) #t #w = vec_or #t #w
inline_for_extraction
let ( ~| ) #t #w = vec_not #t #w
inline_for_extraction
let ( >>| ) #t #w = vec_shift_right #t #w
inline_for_extraction
let ( <<| ) #t #w = vec_shift_left #t #w
inline_for_extraction
let ( >>>| ) #t #w = vec_rotate_right #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Less_Less_Less_Bar : v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.rotval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> Lib.IntVector.vec_t t w | [] | Lib.IntVector.op_Less_Less_Less_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
v1: Lib.IntVector.vec_t t w ->
s: Lib.IntTypes.rotval t {t <> Lib.IntTypes.U128 \/ Lib.IntTypes.v s % 8 == 0}
-> Lib.IntVector.vec_t t w | {
"end_col": 42,
"end_line": 340,
"start_col": 21,
"start_line": 340
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w | let vec_v_t (t: v_inttype{unsigned t}) (w: width) = | false | null | false | lseq (uint_t t SEC) w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.b2t",
"Lib.IntTypes.unsigned",
"Lib.IntVector.width",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.SEC"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32} | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vec_v_t : t: Lib.IntVector.v_inttype{Lib.IntTypes.unsigned t} -> w: Lib.IntVector.width -> Type0 | [] | Lib.IntVector.vec_v_t | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Lib.IntVector.v_inttype{Lib.IntTypes.unsigned t} -> w: Lib.IntVector.width -> Type0 | {
"end_col": 71,
"end_line": 13,
"start_col": 50,
"start_line": 13
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ( *| ) #t #w = vec_mul_mod #t #w | let op_Star_Bar #t #w = | false | null | false | vec_mul_mod #t #w | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Prims.b2t",
"Prims.op_disEquality",
"Lib.IntTypes.inttype",
"Lib.IntTypes.U128",
"Lib.IntVector.width",
"Lib.IntVector.vec_mul_mod",
"Lib.IntVector.vec_t",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntVector.vec_v",
"Lib.Sequence.map2",
"Lib.IntTypes.mul_mod"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2
val vec_interleave_high_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create2 (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_high_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_high_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) ==
create8 (vec_v v1).[2] (vec_v v2).[2] (vec_v v1).[3] (vec_v v2).[3] (vec_v v1).[6] (vec_v v2).[6] (vec_v v1).[7] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) ==
create8 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_high_n 4 v1 v2) ==
create8 (vec_v v1).[4] (vec_v v1).[5] (vec_v v1).[6] (vec_v v1).[7] (vec_v v2).[4] (vec_v v2).[5] (vec_v v2).[6] (vec_v v2).[7]))
val vec_interleave_high_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high v1 v2) == create4 (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[3] (vec_v v2).[3]))
val vec_interleave_high_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_high_n 2 v1 v2) == create4 (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[2] (vec_v v2).[3]))
val vec_shift_right_uint128_small2: v1:vec_t U64 4 -> s:shiftval U128{uint_v s % 8 == 0 /\ 0 < uint_v s /\ uint_v s < 64} -> Lemma
(let v2 = cast U64 4 (vec_shift_right (cast U128 2 v1) s) in
vec_v v2 == create4
(((vec_v v1).[0] >>. s) |. ((vec_v v1).[1] <<. (64ul -! s)))
((vec_v v1).[1] >>. s)
(((vec_v v1).[2] >>. s) |. ((vec_v v1).[3] <<. (64ul -! s)))
((vec_v v1).[3] >>. s))
inline_for_extraction
val vec_rotate_right_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_right_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create2 (vec_v v1).[(v s)% 2] (vec_v v1).[(v s + 1)%2]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
val vec_rotate_right_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_right_lanes v1 s) ==
create4 (vec_v v1).[(v s) % 4] (vec_v v1).[(v s + 1) % 4] (vec_v v1).[(v s + 2) % 4] (vec_v v1).[(v s + 3) % 4]))
[SMTPat (vec_v (vec_rotate_right_lanes #t v1 s))]
inline_for_extraction
val vec_rotate_left_lanes: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:size_t{v s <= w} -> vec_t t w
val vec_rotate_left_lanes2_lemma: #t:v_inttype -> v1:vec_t t 2 -> s:size_t{v s <= 2} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (2ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
val vec_rotate_left_lanes4_lemma: #t:v_inttype -> v1:vec_t t 4 -> s:size_t{v s <= 4} ->
Lemma (ensures (vec_v (vec_rotate_left_lanes v1 s) ==
vec_v (vec_rotate_right_lanes v1 (4ul -. s))))
[SMTPat (vec_v (vec_rotate_left_lanes #t v1 s))]
type uint128x1 = vec_t U128 1
type uint128x2 = vec_t U128 2
type uint64x2 = vec_t U64 2
type uint64x4 = vec_t U64 4
type uint32x4 = vec_t U32 4
type uint32x8 = vec_t U32 8
type uint16x8 = vec_t U16 8
type uint16x16 = vec_t U16 16
type uint8x16 = vec_t U8 16
type uint8x32 = vec_t U8 32
inline_for_extraction
val vec_aes_enc: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc key state) == Spec.AES.aes_enc (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc key state))]
inline_for_extraction
val vec_aes_enc_last: key:uint8x16 -> state:uint8x16 -> uint8x16
val vec_aes_enc_last_lemma: key:uint8x16 -> state:uint8x16 -> Lemma
(ensures (vec_v (vec_aes_enc_last key state) == Spec.AES.aes_enc_last (vec_v key) (vec_v state)))
[SMTPat (vec_v (vec_aes_enc_last key state))]
inline_for_extraction
val vec_aes_keygen_assist: s:uint8x16 -> rcon:uint8 -> uint8x16
val vec_aes_keygen_assist_lemma: s:uint8x16 -> rcon:uint8 -> Lemma
(ensures (vec_v (vec_aes_keygen_assist s rcon) == Spec.AES.aes_keygen_assist rcon (vec_v s)))
[SMTPat (vec_v (vec_aes_keygen_assist s rcon))]
inline_for_extraction
val vec_clmul_lo_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_lo_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_lo: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
val vec_clmul_hi_hi: uint128x1 -> uint128x1 -> uint128x1
inline_for_extraction
let ( +| ) #t #w = vec_add_mod #t #w
inline_for_extraction
let ( -| ) #t #w = vec_sub_mod #t #w | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_Star_Bar : v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w
-> v3:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v3 ==
Lib.Sequence.map2 Lib.IntTypes.mul_mod (Lib.IntVector.vec_v v1) (Lib.IntVector.vec_v v2) } | [] | Lib.IntVector.op_Star_Bar | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w
-> v3:
Lib.IntVector.vec_t t w
{ Lib.IntVector.vec_v v3 ==
Lib.Sequence.map2 Lib.IntTypes.mul_mod (Lib.IntVector.vec_v v1) (Lib.IntVector.vec_v v2) } | {
"end_col": 36,
"end_line": 324,
"start_col": 19,
"start_line": 324
} |
|
Prims.Tot | val vec_interleave_low (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2 | val vec_interleave_low (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w
let vec_interleave_low (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w = | false | null | false | vec_interleave_low_n 1 v1 v2 | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_t",
"Lib.IntVector.vec_interleave_low_n"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vec_interleave_low (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w | [] | Lib.IntVector.vec_interleave_low | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 30,
"end_line": 174,
"start_col": 2,
"start_line": 174
} |
Prims.Tot | val vec_interleave_high (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w | [
{
"abbrev": false,
"full_module": "Lib.IntVector.Intrinsics",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.IntTypes",
"short_module": "Ints"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let vec_interleave_high (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_high_n 1 v1 v2 | val vec_interleave_high (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w
let vec_interleave_high (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w = | false | null | false | vec_interleave_high_n 1 v1 v2 | {
"checked_file": "Lib.IntVector.fsti.checked",
"dependencies": [
"Spec.AES.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Lib.IntVector.fsti"
} | [
"total"
] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntVector.vec_t",
"Lib.IntVector.vec_interleave_high_n"
] | [] | module Lib.IntVector
open FStar.Mul
open Lib.Sequence
open Lib.IntTypes
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
let v_inttype = t:inttype{unsigned t /\ ~(U1? t)}
let width = n:size_nat{n == 1 \/ n == 2 \/ n == 4 \/ n == 8 \/ n == 16 \/ n == 32}
let vec_index (w:width) = n:size_t{v n < w}
let vec_v_t (t:v_inttype{unsigned t}) (w:width) = lseq (uint_t t SEC) w
inline_for_extraction
val vec_t: t:v_inttype -> w:width -> Type0
val reveal_vec_1: t:v_inttype -> Lemma
(requires t <> U128)
(ensures vec_t t 1 == sec_int_t t)
inline_for_extraction
val vec_v: #t:v_inttype -> #w:width -> vec_t t w -> vec_v_t t w
val vecv_extensionality: #t:v_inttype -> #w:width -> f1:vec_t t w -> f2:vec_t t w -> Lemma
(requires vec_v f1 == vec_v f2)
(ensures f1 == f2)
val reveal_vec_v_1: #t:v_inttype -> f:vec_t t 1 -> Lemma
(requires t <> U128)
(ensures (
reveal_vec_1 t;
f == index (vec_v f) 0))
inline_for_extraction
val vec_zero: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == create w (mk_int 0)}
inline_for_extraction
val vec_counter: t:v_inttype -> w:width -> v:vec_t t w{vec_v v == createi w mk_int}
inline_for_extraction
val vec_load: #t:v_inttype
-> i:uint_t t SEC -> w:width ->
v:vec_t t w{vec_v v == create w i}
inline_for_extraction
val vec_load2: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC ->
v:vec_t t 2{vec_v v == create2 i0 i1}
inline_for_extraction
val vec_load4: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC ->
v:vec_t t 4{vec_v v == create4 i0 i1 i2 i3}
inline_for_extraction
val vec_load8: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC ->
v:vec_t t 8{vec_v v == create8 i0 i1 i2 i3 i4 i5 i6 i7}
inline_for_extraction
val vec_load16: #t:v_inttype
-> i0:uint_t t SEC -> i1:uint_t t SEC -> i2:uint_t t SEC -> i3:uint_t t SEC
-> i4:uint_t t SEC -> i5:uint_t t SEC -> i6:uint_t t SEC -> i7:uint_t t SEC
-> i8:uint_t t SEC -> i9:uint_t t SEC -> i10:uint_t t SEC -> i11:uint_t t SEC
-> i12:uint_t t SEC -> i13:uint_t t SEC -> i14:uint_t t SEC -> i15:uint_t t SEC ->
v:vec_t t 16{vec_v v == create16 i0 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15}
inline_for_extraction
val vec_set: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w -> x:uint_t t SEC ->
v':vec_t t w{vec_v v' == upd (vec_v v) (size_v i) x}
inline_for_extraction
val vec_get: #t:v_inttype -> #w:width
-> v:vec_t t w -> i:vec_index w ->
x:uint_t t SEC{x == index (vec_v v) (size_v i)}
inline_for_extraction
val vec_add_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_add_mod_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_add_mod v1 v2) == map2 ( +. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v (vec_add_mod #t #w v1 v2))]
inline_for_extraction
val vec_sub_mod: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( -. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_mul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( *. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_smul_mod: #t:v_inttype{t <> U128} -> #w:width -> v1:vec_t t w -> v2:uint_t t SEC -> v3:vec_t t w{vec_v v3 == map ( mul_mod v2 ) (vec_v v1)}
inline_for_extraction
val vec_xor: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_xor_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_xor v1 v2) == map2 ( ^. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_xor v1 v2))]
inline_for_extraction
val vec_and: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> vec_t t w
val vec_and_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> Lemma
(ensures (vec_v (vec_and v1 v2) == map2 ( &. ) (vec_v v1) (vec_v v2)))
[SMTPat (vec_v #t #w (vec_and v1 v2))]
inline_for_extraction
val vec_or: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 ( |. ) (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_not: #t:v_inttype -> #w:width -> v1:vec_t t w -> vec_t t w
val vec_not_lemma: #t:v_inttype -> #w:width -> v1:vec_t t w -> Lemma
(ensures (vec_v (vec_not v1) == map lognot (vec_v v1)))
[SMTPat (vec_v #t #w (vec_not v1))]
inline_for_extraction
val vec_shift_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_right_i s) (vec_v v1)}
inline_for_extraction
val vec_shift_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:shiftval t{t <> U128 \/ uint_v s % 8 == 0} ->
v2:vec_t t w{vec_v v2 == map (shift_left_i s) (vec_v v1)}
inline_for_extraction
val vec_rotate_right: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_right_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_right v1 s) == map (rotate_right_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_right #t #w v1 s))]
inline_for_extraction
val vec_rotate_left: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} -> vec_t t w
val vec_rotate_left_lemma: #t:v_inttype -> #w:width
-> v1:vec_t t w -> s:rotval t{t <> U128 \/ uint_v s % 8 == 0} ->
Lemma (ensures (vec_v (vec_rotate_left v1 s) == map (rotate_left_i s) (vec_v v1)))
[SMTPat (vec_v (vec_rotate_left v1 s))]
inline_for_extraction
val vec_eq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 eq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_neq_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 neq_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gt_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gt_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_lte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 lte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val vec_gte_mask: #t:v_inttype -> #w:width -> v1:vec_t t w -> v2:vec_t t w -> v3:vec_t t w{vec_v v3 == map2 gte_mask (vec_v v1) (vec_v v2)}
inline_for_extraction
val cast: #t:v_inttype -> #w:width -> t':v_inttype -> w':width{bits t * w == bits t' * w'} -> vec_t t w -> vec_t t' w'
inline_for_extraction
val vec_interleave_low_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction
let vec_interleave_low (#t:v_inttype) (#w:width) (v1:vec_t t w) (v2:vec_t t w) : vec_t t w =
vec_interleave_low_n 1 v1 v2
val vec_interleave_low_lemma2: #t:v_inttype -> v1:vec_t t 2 -> v2:vec_t t 2 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create2 (vec_v v1).[0] (vec_v v2).[0]))
val vec_interleave_low_lemma_uint32_4: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1]))
val vec_interleave_low_n_lemma_uint32_4_2: v1:vec_t U32 4 -> v2:vec_t U32 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
val vec_interleave_low_lemma_uint32_8: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) ==
create8 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[1] (vec_v v2).[1] (vec_v v1).[4] (vec_v v2).[4] (vec_v v1).[5] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_2: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1] (vec_v v1).[4] (vec_v v1).[5] (vec_v v2).[4] (vec_v v2).[5]))
val vec_interleave_low_n_lemma_uint32_8_4: v1:vec_t U32 8 -> v2:vec_t U32 8 -> Lemma
(ensures (vec_v (vec_interleave_low_n 4 v1 v2) ==
create8 (vec_v v1).[0] (vec_v v1).[1] (vec_v v1).[2] (vec_v v1).[3] (vec_v v2).[0] (vec_v v2).[1] (vec_v v2).[2] (vec_v v2).[3]))
val vec_interleave_low_lemma_uint64_4: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low v1 v2) == create4 (vec_v v1).[0] (vec_v v2).[0] (vec_v v1).[2] (vec_v v2).[2]))
val vec_interleave_low_n_lemma_uint64_4_2: v1:vec_t U64 4 -> v2:vec_t U64 4 -> Lemma
(ensures (vec_v (vec_interleave_low_n 2 v1 v2) == create4 (vec_v v1).[0] (vec_v v1).[1] (vec_v v2).[0] (vec_v v2).[1]))
inline_for_extraction
val vec_interleave_high_n: #t:v_inttype -> #w:width -> n:width{w % n == 0} -> vec_t t w -> vec_t t w -> vec_t t w
inline_for_extraction | false | false | Lib.IntVector.fsti | {
"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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val vec_interleave_high (#t: v_inttype) (#w: width) (v1 v2: vec_t t w) : vec_t t w | [] | Lib.IntVector.vec_interleave_high | {
"file_name": "lib/Lib.IntVector.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | v1: Lib.IntVector.vec_t t w -> v2: Lib.IntVector.vec_t t w -> Lib.IntVector.vec_t t w | {
"end_col": 31,
"end_line": 209,
"start_col": 2,
"start_line": 209
} |
FStar.HyperStack.ST.Stack | val load_acc1:
acc:felem 1
-> b:lbuffer uint8 16ul
-> Stack unit
(requires fun h ->
live h acc /\ live h b /\ disjoint acc b /\
felem_fits h acc (2, 2, 2, 2, 2))
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc == Vec.load_acc1 (as_seq h0 b) (feval h0 acc).[0]) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": 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 load_acc1 acc b =
push_frame();
let h0 = ST.get () in
LSeq.eq_intro (feval h0 acc) (LSeq.create 1 (feval h0 acc).[0]);
let e = create 5ul (zero 1) in
load_blocks e b;
fadd acc acc e;
pop_frame() | val load_acc1:
acc:felem 1
-> b:lbuffer uint8 16ul
-> Stack unit
(requires fun h ->
live h acc /\ live h b /\ disjoint acc b /\
felem_fits h acc (2, 2, 2, 2, 2))
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc == Vec.load_acc1 (as_seq h0 b) (feval h0 acc).[0])
let load_acc1 acc b = | true | null | false | push_frame ();
let h0 = ST.get () in
LSeq.eq_intro (feval h0 acc) (LSeq.create 1 (feval h0 acc).[ 0 ]);
let e = create 5ul (zero 1) in
load_blocks e b;
fadd acc acc e;
pop_frame () | {
"checked_file": "Hacl.Impl.Poly1305.Field32xN_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Poly1305.Field32xN_32.fst"
} | [] | [
"Hacl.Impl.Poly1305.Field32xN.felem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Impl.Poly1305.Field32xN.fadd",
"Hacl.Impl.Poly1305.Field32xN.load_blocks",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Hacl.Spec.Poly1305.Field32xN.zero",
"Lib.Sequence.eq_intro",
"Hacl.Spec.Poly1305.Vec.pfelem",
"Hacl.Impl.Poly1305.Field32xN.feval",
"Lib.Sequence.create",
"Hacl.Impl.Poly1305.Field32xN.op_String_Access",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Poly1305.Field32xN_32
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Poly1305.Field32xN
open Hacl.Spec.Poly1305.Field32xN.Lemmas
module Vec = Hacl.Spec.Poly1305.Vec
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
open Hacl.Impl.Poly1305.Field32xN
/// See comments in Hacl.Impl.Poly1305.Field32xN_256
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'"
val load_acc1:
acc:felem 1
-> b:lbuffer uint8 16ul
-> Stack unit
(requires fun h ->
live h acc /\ live h b /\ disjoint acc b /\
felem_fits h acc (2, 2, 2, 2, 2))
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc == Vec.load_acc1 (as_seq h0 b) (feval h0 acc).[0])
[@CInline] | false | false | Hacl.Impl.Poly1305.Field32xN_32.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_acc1:
acc:felem 1
-> b:lbuffer uint8 16ul
-> Stack unit
(requires fun h ->
live h acc /\ live h b /\ disjoint acc b /\
felem_fits h acc (2, 2, 2, 2, 2))
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc == Vec.load_acc1 (as_seq h0 b) (feval h0 acc).[0]) | [] | Hacl.Impl.Poly1305.Field32xN_32.load_acc1 | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | acc: Hacl.Impl.Poly1305.Field32xN.felem 1 -> b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 13,
"end_line": 44,
"start_col": 2,
"start_line": 38
} |
FStar.HyperStack.ST.Stack | val fmul_r1_normalize:
out:felem 1
-> p:precomp_r 1
-> Stack unit
(requires fun h ->
live h out /\ live h p /\
felem_fits h out (3, 3, 3, 3, 3) /\
load_precompute_r_post h p)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (2, 2, 2, 2, 2) /\
(let r = feval h0 (gsub p 0ul 5ul) in
(feval h1 out).[0] == Vec.normalize_1 r.[0] (feval h0 out))) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Poly1305.Vec",
"short_module": "Vec"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Poly1305.Field32xN",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": 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 fmul_r1_normalize out p =
let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
fmul_r out out r r5 | val fmul_r1_normalize:
out:felem 1
-> p:precomp_r 1
-> Stack unit
(requires fun h ->
live h out /\ live h p /\
felem_fits h out (3, 3, 3, 3, 3) /\
load_precompute_r_post h p)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (2, 2, 2, 2, 2) /\
(let r = feval h0 (gsub p 0ul 5ul) in
(feval h1 out).[0] == Vec.normalize_1 r.[0] (feval h0 out)))
let fmul_r1_normalize out p = | true | null | false | let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
fmul_r out out r r5 | {
"checked_file": "Hacl.Impl.Poly1305.Field32xN_32.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Poly1305.Vec.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.Lemmas.fst.checked",
"Hacl.Spec.Poly1305.Field32xN.fst.checked",
"Hacl.Impl.Poly1305.Field32xN.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Poly1305.Field32xN_32.fst"
} | [] | [
"Hacl.Impl.Poly1305.Field32xN.felem",
"Hacl.Impl.Poly1305.Field32xN.precomp_r",
"Hacl.Impl.Poly1305.Field32xN.fmul_r",
"Prims.unit",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Spec.Poly1305.Field32xN.uint64xN",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.sub",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Poly1305.Field32xN_32
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
include Hacl.Spec.Poly1305.Field32xN
open Hacl.Spec.Poly1305.Field32xN.Lemmas
module Vec = Hacl.Spec.Poly1305.Vec
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
open Hacl.Impl.Poly1305.Field32xN
/// See comments in Hacl.Impl.Poly1305.Field32xN_256
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'"
val load_acc1:
acc:felem 1
-> b:lbuffer uint8 16ul
-> Stack unit
(requires fun h ->
live h acc /\ live h b /\ disjoint acc b /\
felem_fits h acc (2, 2, 2, 2, 2))
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (3, 3, 3, 3, 3) /\
feval h1 acc == Vec.load_acc1 (as_seq h0 b) (feval h0 acc).[0])
[@CInline]
let load_acc1 acc b =
push_frame();
let h0 = ST.get () in
LSeq.eq_intro (feval h0 acc) (LSeq.create 1 (feval h0 acc).[0]);
let e = create 5ul (zero 1) in
load_blocks e b;
fadd acc acc e;
pop_frame()
val fmul_r1_normalize:
out:felem 1
-> p:precomp_r 1
-> Stack unit
(requires fun h ->
live h out /\ live h p /\
felem_fits h out (3, 3, 3, 3, 3) /\
load_precompute_r_post h p)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (2, 2, 2, 2, 2) /\
(let r = feval h0 (gsub p 0ul 5ul) in
(feval h1 out).[0] == Vec.normalize_1 r.[0] (feval h0 out))) | false | false | Hacl.Impl.Poly1305.Field32xN_32.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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val fmul_r1_normalize:
out:felem 1
-> p:precomp_r 1
-> Stack unit
(requires fun h ->
live h out /\ live h p /\
felem_fits h out (3, 3, 3, 3, 3) /\
load_precompute_r_post h p)
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (2, 2, 2, 2, 2) /\
(let r = feval h0 (gsub p 0ul 5ul) in
(feval h1 out).[0] == Vec.normalize_1 r.[0] (feval h0 out))) | [] | Hacl.Impl.Poly1305.Field32xN_32.fmul_r1_normalize | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN_32.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | out: Hacl.Impl.Poly1305.Field32xN.felem 1 -> p: Hacl.Impl.Poly1305.Field32xN.precomp_r 1
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 21,
"end_line": 64,
"start_col": 29,
"start_line": 61
} |
Prims.Tot | val mk_be_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (be_to_n_t u len) (decreases len) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1)) | val mk_be_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (be_to_n_t u len) (decreases len)
let rec mk_be_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (be_to_n_t u len) (decreases len) = | false | null | false | if len = 0 then be_to_n_0 u else be_to_n_S (mk_be_to_n u (len - 1)) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total",
""
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"LowParse.SLow.Endianness.be_to_n_0",
"Prims.bool",
"LowParse.SLow.Endianness.be_to_n_S",
"Prims.op_Subtraction",
"LowParse.SLow.Endianness.mk_be_to_n",
"LowParse.SLow.Endianness.be_to_n_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len) | false | false | LowParse.SLow.Endianness.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 mk_be_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (be_to_n_t u len) (decreases len) | [
"recursion"
] | LowParse.SLow.Endianness.mk_be_to_n | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u19: LowParse.Spec.Endianness.uinttype t tot -> len: Prims.nat{len <= tot}
-> Prims.Tot (LowParse.SLow.Endianness.be_to_n_t u19 len) | {
"end_col": 41,
"end_line": 79,
"start_col": 2,
"start_line": 77
} |
Prims.Tot | val mk_n_to_be (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len) (decreases len) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1)) | val mk_n_to_be (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len) (decreases len)
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len) (decreases len) = | false | null | false | if len = 0 then n_to_be_0 u else n_to_be_S (mk_n_to_be u (len - 1)) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total",
""
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Equality",
"Prims.int",
"LowParse.SLow.Endianness.n_to_be_0",
"Prims.bool",
"LowParse.SLow.Endianness.n_to_be_S",
"Prims.op_Subtraction",
"LowParse.SLow.Endianness.mk_n_to_be",
"LowParse.SLow.Endianness.n_to_be_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len) | false | false | LowParse.SLow.Endianness.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 mk_n_to_be (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len) (decreases len) | [
"recursion"
] | LowParse.SLow.Endianness.mk_n_to_be | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u35: LowParse.Spec.Endianness.uinttype t tot -> len: Prims.nat{len <= tot /\ tot < Prims.pow2 32}
-> Prims.Tot (LowParse.SLow.Endianness.n_to_be_t u35 len) | {
"end_col": 41,
"end_line": 129,
"start_col": 2,
"start_line": 127
} |
Prims.Tot | val be_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (be_to_n_t u 0) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero | val be_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (be_to_n_t u 0)
let be_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (be_to_n_t u 0) = | false | null | false | fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"FStar.Bytes.lbytes",
"LowParse.Spec.Endianness.__proj__UIntType__item__zero",
"Prims.unit",
"FStar.Endianness.reveal_be_to_n",
"FStar.Bytes.reveal",
"Prims.eq2",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.Endianness.be_to_n",
"LowParse.SLow.Endianness.be_to_n_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot) | false | false | LowParse.SLow.Endianness.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 be_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (be_to_n_t u 0) | [] | LowParse.SLow.Endianness.be_to_n_0 | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u9: LowParse.Spec.Endianness.uinttype t tot -> LowParse.SLow.Endianness.be_to_n_t u9 0 | {
"end_col": 8,
"end_line": 31,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | val mk_le_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (le_to_n_t u len) (decreases len) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_le_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (le_to_n_t u len)
(decreases len)
= if len = 0
then le_to_n_0 u
else le_to_n_S (mk_le_to_n u (len - 1)) | val mk_le_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (le_to_n_t u len) (decreases len)
let rec mk_le_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (le_to_n_t u len) (decreases len) = | false | null | false | if len = 0 then le_to_n_0 u else le_to_n_S (mk_le_to_n u (len - 1)) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total",
""
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Equality",
"Prims.int",
"LowParse.SLow.Endianness.le_to_n_0",
"Prims.bool",
"LowParse.SLow.Endianness.le_to_n_S",
"Prims.op_Subtraction",
"LowParse.SLow.Endianness.mk_le_to_n",
"LowParse.SLow.Endianness.le_to_n_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
[@must_reduce]
noextract
let rec mk_le_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (le_to_n_t u len) | false | false | LowParse.SLow.Endianness.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 mk_le_to_n (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot})
: Tot (le_to_n_t u len) (decreases len) | [
"recursion"
] | LowParse.SLow.Endianness.mk_le_to_n | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u51: LowParse.Spec.Endianness.uinttype t tot -> len: Prims.nat{len <= tot}
-> Prims.Tot (LowParse.SLow.Endianness.le_to_n_t u51 len) | {
"end_col": 41,
"end_line": 194,
"start_col": 2,
"start_line": 192
} |
Prims.Tot | val n_to_be_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_be_t u 0) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes | val n_to_be_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_be_t u 0)
let n_to_be_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_be_t u 0) = | false | null | false | fun _ -> B.empty_bytes | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Bytes.empty_bytes",
"FStar.Bytes.bytes",
"FStar.Seq.Base.equal",
"FStar.Bytes.byte",
"FStar.Bytes.reveal",
"FStar.Endianness.n_to_be",
"LowParse.SLow.Endianness.n_to_be_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot) | false | false | LowParse.SLow.Endianness.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 n_to_be_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_be_t u 0) | [] | LowParse.SLow.Endianness.n_to_be_0 | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u26: LowParse.Spec.Endianness.uinttype t tot -> LowParse.SLow.Endianness.n_to_be_t u26 0 | {
"end_col": 24,
"end_line": 99,
"start_col": 2,
"start_line": 99
} |
Prims.Tot | val le_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (le_to_n_t u 0) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero | val le_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (le_to_n_t u 0)
let le_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (le_to_n_t u 0) = | false | null | false | fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"FStar.Bytes.lbytes",
"LowParse.Spec.Endianness.__proj__UIntType__item__zero",
"Prims.unit",
"FStar.Endianness.reveal_le_to_n",
"FStar.Bytes.reveal",
"Prims.eq2",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.Endianness.le_to_n",
"LowParse.SLow.Endianness.le_to_n_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot) | false | false | LowParse.SLow.Endianness.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 le_to_n_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (le_to_n_t u 0) | [] | LowParse.SLow.Endianness.le_to_n_0 | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u42: LowParse.Spec.Endianness.uinttype t tot -> LowParse.SLow.Endianness.le_to_n_t u42 0 | {
"end_col": 8,
"end_line": 151,
"start_col": 2,
"start_line": 149
} |
Prims.Tot | val mk_n_to_le (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len) (decreases len) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec mk_n_to_le
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len)
(decreases len)
= if len = 0
then n_to_le_0 u
else n_to_le_S (mk_n_to_le u (len - 1)) | val mk_n_to_le (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len) (decreases len)
let rec mk_n_to_le
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len) (decreases len) = | false | null | false | if len = 0 then n_to_le_0 u else n_to_le_S (mk_n_to_le u (len - 1)) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total",
""
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Equality",
"Prims.int",
"LowParse.SLow.Endianness.n_to_le_0",
"Prims.bool",
"LowParse.SLow.Endianness.n_to_le_S",
"Prims.op_Subtraction",
"LowParse.SLow.Endianness.mk_n_to_le",
"LowParse.SLow.Endianness.n_to_le_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
[@must_reduce]
noextract
let rec mk_le_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (le_to_n_t u len)
(decreases len)
= if len = 0
then le_to_n_0 u
else le_to_n_S (mk_le_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_le_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_le len (u.v n) })
inline_for_extraction
noextract
let n_to_le_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_le_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1))
= fun n ->
reveal_n_to_le (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_lo `B.append` seq_hi
[@must_reduce]
noextract
let rec mk_n_to_le
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len) | false | false | LowParse.SLow.Endianness.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 mk_n_to_le (#t: Type) (#tot: nat) (u: uinttype t tot) (len: nat{len <= tot /\ tot < pow2 32})
: Tot (n_to_le_t u len) (decreases len) | [
"recursion"
] | LowParse.SLow.Endianness.mk_n_to_le | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u67: LowParse.Spec.Endianness.uinttype t tot -> len: Prims.nat{len <= tot /\ tot < Prims.pow2 32}
-> Prims.Tot (LowParse.SLow.Endianness.n_to_le_t u67 len) | {
"end_col": 41,
"end_line": 244,
"start_col": 2,
"start_line": 242
} |
Prims.Tot | val n_to_le_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_le_t u 0) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let n_to_le_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_le_t u 0)
= fun _ -> B.empty_bytes | val n_to_le_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_le_t u 0)
let n_to_le_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_le_t u 0) = | false | null | false | fun _ -> B.empty_bytes | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThan",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Bytes.empty_bytes",
"FStar.Bytes.bytes",
"FStar.Seq.Base.equal",
"FStar.Bytes.byte",
"FStar.Bytes.reveal",
"FStar.Endianness.n_to_le",
"LowParse.SLow.Endianness.n_to_le_t"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
[@must_reduce]
noextract
let rec mk_le_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (le_to_n_t u len)
(decreases len)
= if len = 0
then le_to_n_0 u
else le_to_n_S (mk_le_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_le_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_le len (u.v n) })
inline_for_extraction
noextract
let n_to_le_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot) | false | false | LowParse.SLow.Endianness.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 n_to_le_0 (#t: Type) (#tot: nat) (u: uinttype t tot) : Tot (n_to_le_t u 0) | [] | LowParse.SLow.Endianness.n_to_le_0 | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | u58: LowParse.Spec.Endianness.uinttype t tot -> LowParse.SLow.Endianness.n_to_le_t u58 0 | {
"end_col": 24,
"end_line": 214,
"start_col": 2,
"start_line": 214
} |
Prims.Tot | val be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n | val be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1)) = | false | null | false | fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@@ inline_let ]let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` (u.mul256 n) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"LowParse.SLow.Endianness.be_to_n_t",
"FStar.Bytes.lbytes",
"LowParse.Spec.Endianness.__proj__UIntType__item__add",
"LowParse.Spec.Endianness.__proj__UIntType__item__mul256",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Multiply",
"FStar.UInt.size",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.UInt8.v",
"LowParse.Spec.Endianness.__proj__UIntType__item__from_byte",
"Prims.unit",
"Prims._assert",
"FStar.Mul.op_Star",
"FStar.Endianness.lemma_be_to_n_is_bounded",
"FStar.Bytes.reveal",
"FStar.Endianness.be_to_n",
"FStar.Bytes.bytes",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"FStar.Bytes.slice",
"FStar.UInt32.__uint_to_t",
"FStar.Bytes.get",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Endianness.reveal_be_to_n",
"FStar.Pervasives.assert_norm"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len) | false | false | LowParse.SLow.Endianness.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 be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1)) | [] | LowParse.SLow.Endianness.be_to_n_S | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ih: LowParse.SLow.Endianness.be_to_n_t u14 len -> LowParse.SLow.Endianness.be_to_n_t u14 (len + 1) | {
"end_col": 26,
"end_line": 61,
"start_col": 2,
"start_line": 45
} |
Prims.Tot | val n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo | val n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1)) = | false | null | false | fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_LessThan",
"Prims.pow2",
"LowParse.SLow.Endianness.n_to_be_t",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.Mul.op_Star",
"FStar.Bytes.append",
"FStar.Bytes.lbytes",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.l_Forall",
"FStar.UInt32.lt",
"Prims.eq2",
"FStar.UInt8.t",
"FStar.Bytes.get",
"FStar.Bytes.create",
"FStar.UInt32.__uint_to_t",
"FStar.Bytes.bytes",
"FStar.Seq.Base.equal",
"FStar.Bytes.reveal",
"FStar.Endianness.n_to_be",
"LowParse.Spec.Endianness.__proj__UIntType__item__div256",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"LowParse.Spec.Endianness.__proj__UIntType__item__to_byte",
"Prims.unit",
"LowParse.Endianness.reveal_n_to_be",
"FStar.Bytes.byte"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len) | false | false | LowParse.SLow.Endianness.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 n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1)) | [] | LowParse.SLow.Endianness.n_to_be_S | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ih: LowParse.SLow.Endianness.n_to_be_t u31 len -> LowParse.SLow.Endianness.n_to_be_t u31 (len + 1) | {
"end_col": 26,
"end_line": 116,
"start_col": 2,
"start_line": 110
} |
Prims.Tot | val n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1))
= fun n ->
reveal_n_to_le (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_lo `B.append` seq_hi | val n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1))
let n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1)) = | false | null | false | fun n ->
reveal_n_to_le (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_lo `B.append` seq_hi | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Prims.op_LessThan",
"Prims.pow2",
"LowParse.SLow.Endianness.n_to_le_t",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.Mul.op_Star",
"FStar.Bytes.append",
"FStar.Bytes.lbytes",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Prims.l_Forall",
"FStar.UInt32.lt",
"Prims.eq2",
"FStar.UInt8.t",
"FStar.Bytes.get",
"FStar.Bytes.create",
"FStar.UInt32.__uint_to_t",
"FStar.Bytes.bytes",
"FStar.Seq.Base.equal",
"FStar.Bytes.reveal",
"FStar.Endianness.n_to_le",
"LowParse.Spec.Endianness.__proj__UIntType__item__div256",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"LowParse.Spec.Endianness.__proj__UIntType__item__to_byte",
"Prims.unit",
"LowParse.Endianness.reveal_n_to_le",
"FStar.Bytes.byte"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
[@must_reduce]
noextract
let rec mk_le_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (le_to_n_t u len)
(decreases len)
= if len = 0
then le_to_n_0 u
else le_to_n_S (mk_le_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_le_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_le len (u.v n) })
inline_for_extraction
noextract
let n_to_le_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_le_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len) | false | false | LowParse.SLow.Endianness.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 n_to_le_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_le_t u len)
: Tot (n_to_le_t u (len + 1)) | [] | LowParse.SLow.Endianness.n_to_le_S | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ih: LowParse.SLow.Endianness.n_to_le_t u63 len -> LowParse.SLow.Endianness.n_to_le_t u63 (len + 1) | {
"end_col": 26,
"end_line": 231,
"start_col": 2,
"start_line": 225
} |
Prims.Tot | val le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "LowParse.Endianness",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n | val le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1))
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1)) = | false | null | false | fun x ->
assert_norm (pow2 8 == 256);
E.reveal_le_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@@ inline_let ]let ulen = U32.uint_to_t len in
let last = B.get x 0ul in
let first = B.slice x 1ul (ulen `U32.add` 1ul) in
let n = ih first in
E.lemma_le_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` (u.mul256 n) | {
"checked_file": "LowParse.SLow.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Endianness.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.Endianness.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Endianness.uinttype",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"LowParse.SLow.Endianness.le_to_n_t",
"FStar.Bytes.lbytes",
"LowParse.Spec.Endianness.__proj__UIntType__item__add",
"LowParse.Spec.Endianness.__proj__UIntType__item__mul256",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThan",
"Prims.pow2",
"Prims.op_Multiply",
"FStar.UInt.size",
"LowParse.Spec.Endianness.__proj__UIntType__item__v",
"FStar.UInt8.v",
"LowParse.Spec.Endianness.__proj__UIntType__item__from_byte",
"Prims.unit",
"Prims._assert",
"FStar.Mul.op_Star",
"FStar.Endianness.lemma_le_to_n_is_bounded",
"FStar.Bytes.reveal",
"FStar.Endianness.le_to_n",
"FStar.Bytes.bytes",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"FStar.UInt32.add",
"FStar.Bytes.slice",
"FStar.UInt32.__uint_to_t",
"FStar.Bytes.get",
"FStar.Math.Lemmas.pow2_plus",
"FStar.Math.Lemmas.pow2_le_compat",
"FStar.Endianness.reveal_le_to_n",
"FStar.Pervasives.assert_norm"
] | [] | module LowParse.SLow.Endianness
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
module E = LowParse.Endianness
module B = LowParse.Bytes32
module U32 = FStar.UInt32
open FStar.Mul
inline_for_extraction
noextract
let be_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.be_to_n (B.reveal x) })
inline_for_extraction
noextract
let be_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (be_to_n_t u 0)
= fun x ->
E.reveal_be_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let be_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: be_to_n_t u len)
: Tot (be_to_n_t u (len + 1))
= fun x ->
assert_norm (pow2 8 == 256);
E.reveal_be_to_n (B.reveal x);
pow2_le_compat (8 * tot) (8 * (len + 1));
pow2_le_compat (8 * (len + 1)) (8 * len);
pow2_plus (8 * len) 8;
[@inline_let]
let ulen = U32.uint_to_t len in
let last = B.get x ulen in
let first = B.slice x 0ul ulen in
let n = ih first in
E.lemma_be_to_n_is_bounded (B.reveal first);
assert (u.v n * 256 < 256 * pow2 (8 * len));
assert (0 <= u.v n * 256);
assert (u.v n * 256 < pow2 (8 * tot));
let blast = u.from_byte last in
blast `u.add` u.mul256 n
// attribute for use with delta_attr
noextract
noeq
type must_reduce = | MustReduce_dummy_do_not_use
[@must_reduce]
noextract
let rec mk_be_to_n
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot})
: Tot (be_to_n_t u len)
(decreases len)
= if len = 0
then be_to_n_0 u
else be_to_n_S (mk_be_to_n u (len - 1))
inline_for_extraction
noextract
let n_to_be_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (n: t { u.v n < pow2 (8 * len) }) ->
Tot (b: B.bytes { B.reveal b `Seq.equal` E.n_to_be len (u.v n) })
inline_for_extraction
noextract
let n_to_be_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (n_to_be_t u 0)
= fun _ -> B.empty_bytes
inline_for_extraction
noextract
let n_to_be_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat {len + 1 <= tot /\ tot < pow2 32})
(ih: n_to_be_t u len)
: Tot (n_to_be_t u (len + 1))
= fun n ->
reveal_n_to_be (len + 1) (u.v n);
let lo = u.to_byte n in
let hi = u.div256 n in
let seq_hi = ih hi in
let seq_lo = B.create 1ul lo in
seq_hi `B.append` seq_lo
[@must_reduce]
noextract
let rec mk_n_to_be
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat {len <= tot /\ tot < pow2 32})
: Tot (n_to_be_t u len)
(decreases len)
= if len = 0
then n_to_be_0 u
else n_to_be_S (mk_n_to_be u (len - 1))
inline_for_extraction
noextract
let le_to_n_t
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
(len: nat { len <= tot })
: Tot Type
= (x: B.lbytes len) ->
Tot (y: t { u.v y == E.le_to_n (B.reveal x) })
inline_for_extraction
noextract
let le_to_n_0
(#t: Type)
(#tot: nat)
(u: uinttype t tot)
: Tot (le_to_n_t u 0)
= fun x ->
E.reveal_le_to_n (B.reveal x);
u.zero
open FStar.Math.Lemmas
module U32 = FStar.UInt32
inline_for_extraction
noextract
let le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat { len + 1 <= tot })
(ih: le_to_n_t u len) | false | false | LowParse.SLow.Endianness.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 le_to_n_S
(#t: Type)
(#tot: nat)
(#u: uinttype t tot)
(#len: nat{len + 1 <= tot})
(ih: le_to_n_t u len)
: Tot (le_to_n_t u (len + 1)) | [] | LowParse.SLow.Endianness.le_to_n_S | {
"file_name": "src/lowparse/LowParse.SLow.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | ih: LowParse.SLow.Endianness.le_to_n_t u47 len -> LowParse.SLow.Endianness.le_to_n_t u47 (len + 1) | {
"end_col": 26,
"end_line": 181,
"start_col": 2,
"start_line": 165
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModReduction",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mod_slow_st (t:limb_t) (len:BN.meta_len t) =
nBits:size_t
-> n:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\
1 < bn_v h n /\ bn_v h n % 2 = 1 /\
v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n) | let bn_mod_slow_st (t: limb_t) (len: BN.meta_len t) = | false | null | false | nBits: size_t -> n: lbignum t len -> a: lbignum t (len +! len) -> res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h res /\ disjoint res n /\ disjoint res a /\ 1 < bn_v h n /\
bn_v h n % 2 = 1 /\ v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res == bn_v h0 a % bn_v h0 n) | {
"checked_file": "Hacl.Bignum.ModReduction.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.ModReduction.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModReduction.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.bn_v",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_Division",
"Lib.IntTypes.v",
"Lib.IntTypes.bits",
"Prims.pow2",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2"
] | [] | module Hacl.Bignum.ModReduction
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModReduction
module BN = Hacl.Bignum
module AM = Hacl.Bignum.AlmostMontgomery
module BM = Hacl.Bignum.Montgomery
module SM = Hacl.Spec.Bignum.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mod_slow_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h r2 /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint res r2 /\ disjoint r2 n /\
SM.bn_mont_pre (as_seq h n) mu /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n)
inline_for_extraction noextract
val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len
let bn_mod_slow_precomp #t k n mu r2 a res =
let h0 = ST.get () in
S.bn_mod_slow_precomp_lemma (as_seq h0 n) mu (as_seq h0 r2) (as_seq h0 a);
[@inline_let] let len = k.AM.bn.BN.len in
push_frame ();
let a_mod = create len (uint #t #SEC 0) in
let a1 = create (len +! len) (uint #t #SEC 0) in
copy a1 a;
AM.reduction n mu a1 a_mod;
AM.to n mu r2 a_mod res;
pop_frame ()
inline_for_extraction noextract | false | false | Hacl.Bignum.ModReduction.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mod_slow_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | [] | Hacl.Bignum.ModReduction.bn_mod_slow_st | {
"file_name": "code/bignum/Hacl.Bignum.ModReduction.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | {
"end_col": 41,
"end_line": 75,
"start_col": 4,
"start_line": 63
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModReduction",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mod_slow_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h r2 /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint res r2 /\ disjoint r2 n /\
SM.bn_mont_pre (as_seq h n) mu /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n) | let bn_mod_slow_precomp_st (t: limb_t) (len: BN.meta_len t) = | false | null | false |
n: lbignum t len ->
mu: limb t ->
r2: lbignum t len ->
a: lbignum t (len +! len) ->
res: lbignum t len
-> Stack unit
(requires
fun h ->
live h n /\ live h a /\ live h r2 /\ live h res /\ disjoint res n /\ disjoint res a /\
disjoint res r2 /\ disjoint r2 n /\ SM.bn_mont_pre (as_seq h n) mu /\
bn_v h r2 == pow2 ((2 * bits t) * v len) % bn_v h n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ bn_v h1 res == bn_v h0 a % bn_v h0 n) | {
"checked_file": "Hacl.Bignum.ModReduction.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.ModReduction.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModReduction.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.Buffer.disjoint",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Lib.IntTypes.v",
"Lib.Buffer.as_seq",
"Prims.eq2",
"Prims.int",
"Hacl.Bignum.Definitions.bn_v",
"Prims.op_Modulus",
"Prims.pow2",
"FStar.Mul.op_Star",
"Lib.IntTypes.bits",
"Lib.Buffer.modifies",
"Lib.Buffer.loc"
] | [] | module Hacl.Bignum.ModReduction
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModReduction
module BN = Hacl.Bignum
module AM = Hacl.Bignum.AlmostMontgomery
module BM = Hacl.Bignum.Montgomery
module SM = Hacl.Spec.Bignum.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract | false | false | Hacl.Bignum.ModReduction.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mod_slow_precomp_st : t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | [] | Hacl.Bignum.ModReduction.bn_mod_slow_precomp_st | {
"file_name": "code/bignum/Hacl.Bignum.ModReduction.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> len: Hacl.Bignum.meta_len t -> Type0 | {
"end_col": 41,
"end_line": 39,
"start_col": 5,
"start_line": 26
} |
|
Prims.Tot | val mk_bn_mod_slow:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:BM.bn_precomp_r2_mod_n_st t len
-> bn_mod_slow_precomp:bn_mod_slow_precomp_st t len ->
bn_mod_slow_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModReduction",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_bn_mod_slow #t len precompr2 bn_mod_slow_precomp nBits n a res =
push_frame ();
let r2 = create len (uint #t #SEC 0) in
let mu = BM.bn_mont_precomp len precompr2 nBits n r2 in
bn_mod_slow_precomp n mu r2 a res;
pop_frame () | val mk_bn_mod_slow:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:BM.bn_precomp_r2_mod_n_st t len
-> bn_mod_slow_precomp:bn_mod_slow_precomp_st t len ->
bn_mod_slow_st t len
let mk_bn_mod_slow #t len precompr2 bn_mod_slow_precomp nBits n a res = | false | null | false | push_frame ();
let r2 = create len (uint #t #SEC 0) in
let mu = BM.bn_mont_precomp len precompr2 nBits n r2 in
bn_mod_slow_precomp n mu r2 a res;
pop_frame () | {
"checked_file": "Hacl.Bignum.ModReduction.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.ModReduction.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModReduction.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st",
"Hacl.Bignum.ModReduction.bn_mod_slow_precomp_st",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.Montgomery.bn_mont_precomp",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Bignum.ModReduction
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModReduction
module BN = Hacl.Bignum
module AM = Hacl.Bignum.AlmostMontgomery
module BM = Hacl.Bignum.Montgomery
module SM = Hacl.Spec.Bignum.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mod_slow_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h r2 /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint res r2 /\ disjoint r2 n /\
SM.bn_mont_pre (as_seq h n) mu /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n)
inline_for_extraction noextract
val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len
let bn_mod_slow_precomp #t k n mu r2 a res =
let h0 = ST.get () in
S.bn_mod_slow_precomp_lemma (as_seq h0 n) mu (as_seq h0 r2) (as_seq h0 a);
[@inline_let] let len = k.AM.bn.BN.len in
push_frame ();
let a_mod = create len (uint #t #SEC 0) in
let a1 = create (len +! len) (uint #t #SEC 0) in
copy a1 a;
AM.reduction n mu a1 a_mod;
AM.to n mu r2 a_mod res;
pop_frame ()
inline_for_extraction noextract
let bn_mod_slow_st (t:limb_t) (len:BN.meta_len t) =
nBits:size_t
-> n:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\
1 < bn_v h n /\ bn_v h n % 2 = 1 /\
v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n)
inline_for_extraction noextract
val mk_bn_mod_slow:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:BM.bn_precomp_r2_mod_n_st t len
-> bn_mod_slow_precomp:bn_mod_slow_precomp_st t len ->
bn_mod_slow_st t len | false | false | Hacl.Bignum.ModReduction.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 mk_bn_mod_slow:
#t:limb_t
-> len:BN.meta_len t
-> precompr2:BM.bn_precomp_r2_mod_n_st t len
-> bn_mod_slow_precomp:bn_mod_slow_precomp_st t len ->
bn_mod_slow_st t len | [] | Hacl.Bignum.ModReduction.mk_bn_mod_slow | {
"file_name": "code/bignum/Hacl.Bignum.ModReduction.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
len: Hacl.Bignum.meta_len t ->
precompr2: Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t len ->
bn_mod_slow_precomp: Hacl.Bignum.ModReduction.bn_mod_slow_precomp_st t len
-> Hacl.Bignum.ModReduction.bn_mod_slow_st t len | {
"end_col": 14,
"end_line": 91,
"start_col": 2,
"start_line": 87
} |
Prims.Tot | val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.AlmostMontgomery",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModReduction",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mod_slow_precomp #t k n mu r2 a res =
let h0 = ST.get () in
S.bn_mod_slow_precomp_lemma (as_seq h0 n) mu (as_seq h0 r2) (as_seq h0 a);
[@inline_let] let len = k.AM.bn.BN.len in
push_frame ();
let a_mod = create len (uint #t #SEC 0) in
let a1 = create (len +! len) (uint #t #SEC 0) in
copy a1 a;
AM.reduction n mu a1 a_mod;
AM.to n mu r2 a_mod res;
pop_frame () | val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len
let bn_mod_slow_precomp #t k n mu r2 a res = | false | null | false | let h0 = ST.get () in
S.bn_mod_slow_precomp_lemma (as_seq h0 n) mu (as_seq h0 r2) (as_seq h0 a);
[@@ inline_let ]let len = k.AM.bn.BN.len in
push_frame ();
let a_mod = create len (uint #t #SEC 0) in
let a1 = create (len +! len) (uint #t #SEC 0) in
copy a1 a;
AM.reduction n mu a1 a_mod;
AM.to n mu r2 a_mod res;
pop_frame () | {
"checked_file": "Hacl.Bignum.ModReduction.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.ModReduction.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModReduction.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.AlmostMontgomery.almost_mont",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.__proj__Mkbn__item__len",
"Hacl.Bignum.AlmostMontgomery.__proj__Mkalmost_mont__item__bn",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.AlmostMontgomery.to",
"Hacl.Bignum.AlmostMontgomery.reduction",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.add",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame",
"Hacl.Bignum.meta_len",
"Hacl.Spec.Bignum.ModReduction.bn_mod_slow_precomp_lemma",
"Lib.IntTypes.v",
"Lib.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Bignum.ModReduction
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModReduction
module BN = Hacl.Bignum
module AM = Hacl.Bignum.AlmostMontgomery
module BM = Hacl.Bignum.Montgomery
module SM = Hacl.Spec.Bignum.Montgomery
module BD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mod_slow_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t (len +! len)
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h r2 /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint res r2 /\ disjoint r2 n /\
SM.bn_mont_pre (as_seq h n) mu /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res == bn_v h0 a % bn_v h0 n)
inline_for_extraction noextract
val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len | false | false | Hacl.Bignum.ModReduction.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mod_slow_precomp:
#t:limb_t
-> k:AM.almost_mont t ->
bn_mod_slow_precomp_st t k.AM.bn.BN.len | [] | Hacl.Bignum.ModReduction.bn_mod_slow_precomp | {
"file_name": "code/bignum/Hacl.Bignum.ModReduction.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Hacl.Bignum.AlmostMontgomery.almost_mont t
-> Hacl.Bignum.ModReduction.bn_mod_slow_precomp_st t (Mkbn?.len (Mkalmost_mont?.bn k)) | {
"end_col": 14,
"end_line": 58,
"start_col": 44,
"start_line": 48
} |
Prims.GTot | val modified_arg_mloc (x: arg) : GTot ME.loc | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none | val modified_arg_mloc (x: arg) : GTot ME.loc
let modified_arg_mloc (x: arg) : GTot ME.loc = | false | null | false | match x with
| (| TD_Buffer src t { modified = true } , x |) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"sometrivial"
] | [
"Vale.Interop.Base.arg",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapTypes_s.taint",
"Prims.bool",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Vale.Interop.Base.Mkbuffer_qualifiers",
"Vale.X64.Memory.loc_buffer",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Vale.X64.Memory.loc_none",
"Vale.X64.Memory.loc"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__] | false | false | Vale.AsLowStar.ValeSig.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 modified_arg_mloc (x: arg) : GTot ME.loc | [] | Vale.AsLowStar.ValeSig.modified_arg_mloc | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Vale.Interop.Base.arg -> Prims.GTot Vale.X64.Memory.loc | {
"end_col": 22,
"end_line": 60,
"start_col": 4,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 disjoint_or_eq (l:list arg) =
BigOps.pairwise_and' disjoint_or_eq_1 l | let disjoint_or_eq (l: list arg) = | false | null | false | BigOps.pairwise_and' disjoint_or_eq_1 l | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.Interop.Base.arg",
"FStar.BigOps.pairwise_and'",
"Vale.AsLowStar.ValeSig.disjoint_or_eq_1"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__]
let mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none
let state_of (x:(V.va_state & V.va_fuel)) = fst x
let fuel_of (x:(V.va_state & V.va_fuel)) = snd x
let sprop = VS.vale_state -> prop
[@__reduce__]
let readable_one (s:ME.vale_heap) (arg:arg) : prop =
match arg with
| (|TD_Buffer src bt _, x |) ->
ME.buffer_readable s (as_vale_buffer #src #bt x) /\
ME.buffer_writeable (as_vale_buffer #src #bt x)
/\ True //promote to prop
| (|TD_ImmBuffer src bt _, x |) ->
ME.buffer_readable s (as_vale_immbuffer #src #bt x) /\
True
| _ -> True
[@__reduce__]
let readable (args:list arg) (s:ME.vale_heap) : prop =
BigOps.big_and' (readable_one s) args
[@__reduce__]
let disjoint_or_eq_1 (a:arg) (b:arg) =
match a, b with
| (| TD_Buffer srcx tx {strict_disjointness=true}, xb |), (| TD_Buffer srcy ty _, yb |)
| (| TD_Buffer srcx tx _, xb |), (| TD_Buffer srcy ty {strict_disjointness=true}, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_buffer #srcx #tx xb)) (ME.loc_buffer (as_vale_buffer #srcy #ty yb))
| (| TD_ImmBuffer srcx tx {strict_disjointness=true}, xb |), (| TD_ImmBuffer srcy ty _, yb |)
| (| TD_ImmBuffer srcx tx _, xb |), (| TD_ImmBuffer srcy ty {strict_disjointness=true}, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_immbuffer #srcx #tx xb)) (ME.loc_buffer (as_vale_immbuffer #srcy #ty yb))
// An immutable buffer and a trivial buffer should not be equal
| (| TD_ImmBuffer srcx tx _, xb |), (| TD_Buffer srcy ty _, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_immbuffer #srcx #tx xb)) (ME.loc_buffer (as_vale_buffer #srcy #ty yb))
| (| TD_Buffer srcx tx _, xb |), (| TD_ImmBuffer srcy ty _, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_buffer #srcx #tx xb)) (ME.loc_buffer (as_vale_immbuffer #srcy #ty yb))
| (| TD_Buffer srcx tx _, xb |), (| TD_Buffer srcy ty _, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_buffer #srcx #tx xb)) (ME.loc_buffer (as_vale_buffer #srcy #ty yb)) \/
xb === yb
| (| TD_ImmBuffer srcx tx _, xb |), (| TD_ImmBuffer srcy ty _, yb |) ->
ME.loc_disjoint (ME.loc_buffer (as_vale_immbuffer #srcx #tx xb)) (ME.loc_buffer (as_vale_immbuffer #srcy #ty yb)) \/
xb === yb
| _ -> True
[@__reduce__] | false | true | Vale.AsLowStar.ValeSig.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 disjoint_or_eq : l: Prims.list Vale.Interop.Base.arg -> Type0 | [] | Vale.AsLowStar.ValeSig.disjoint_or_eq | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Prims.list Vale.Interop.Base.arg -> Type0 | {
"end_col": 42,
"end_line": 112,
"start_col": 2,
"start_line": 112
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1 | let vale_save_reg (r: MS.reg_64) (s0 s1: V.va_state) = | false | null | false | VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1 | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Vale.X64.Machine_s.reg_64",
"Vale.X64.Decls.va_state",
"Prims.eq2",
"Vale.X64.Memory.nat64",
"Vale.X64.State.eval_reg_64",
"Prims.logical"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom | false | true | Vale.AsLowStar.ValeSig.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 vale_save_reg : r: Vale.X64.Machine_s.reg_64 -> s0: Vale.X64.Decls.va_state -> s1: Vale.X64.Decls.va_state
-> Prims.logical | [] | Vale.AsLowStar.ValeSig.vale_save_reg | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r: Vale.X64.Machine_s.reg_64 -> s0: Vale.X64.Decls.va_state -> s1: Vale.X64.Decls.va_state
-> Prims.logical | {
"end_col": 44,
"end_line": 39,
"start_col": 2,
"start_line": 39
} |
|
Prims.Tot | val readable_one (s: ME.vale_heap) (arg: arg) : prop | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 readable_one (s:ME.vale_heap) (arg:arg) : prop =
match arg with
| (|TD_Buffer src bt _, x |) ->
ME.buffer_readable s (as_vale_buffer #src #bt x) /\
ME.buffer_writeable (as_vale_buffer #src #bt x)
/\ True //promote to prop
| (|TD_ImmBuffer src bt _, x |) ->
ME.buffer_readable s (as_vale_immbuffer #src #bt x) /\
True
| _ -> True | val readable_one (s: ME.vale_heap) (arg: arg) : prop
let readable_one (s: ME.vale_heap) (arg: arg) : prop = | false | null | false | match arg with
| (| TD_Buffer src bt _ , x |) ->
ME.buffer_readable s (as_vale_buffer #src #bt x) /\
ME.buffer_writeable (as_vale_buffer #src #bt x) /\ True
| (| TD_ImmBuffer src bt _ , x |) -> ME.buffer_readable s (as_vale_immbuffer #src #bt x) /\ True
| _ -> True | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Vale.X64.Memory.vale_heap",
"Vale.Interop.Base.arg",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Base.buffer_qualifiers",
"Vale.Interop.Base.td_as_type",
"Vale.Interop.Base.TD_Buffer",
"Prims.l_and",
"Vale.X64.Memory.buffer_readable",
"Vale.X64.MemoryAdapters.as_vale_buffer",
"Vale.X64.Memory.buffer_writeable",
"Prims.l_True",
"Vale.Interop.Base.TD_ImmBuffer",
"Vale.X64.MemoryAdapters.as_vale_immbuffer",
"Prims.dtuple2",
"Vale.Interop.Base.td",
"Prims.prop"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__]
let mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none
let state_of (x:(V.va_state & V.va_fuel)) = fst x
let fuel_of (x:(V.va_state & V.va_fuel)) = snd x
let sprop = VS.vale_state -> prop
[@__reduce__] | false | true | Vale.AsLowStar.ValeSig.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 readable_one (s: ME.vale_heap) (arg: arg) : prop | [] | Vale.AsLowStar.ValeSig.readable_one | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.X64.Memory.vale_heap -> arg: Vale.Interop.Base.arg -> Prims.prop | {
"end_col": 13,
"end_line": 81,
"start_col": 2,
"start_line": 73
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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_of (x:(V.va_state & V.va_fuel)) = fst x | let state_of (x: (V.va_state & V.va_fuel)) = | false | null | false | fst x | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.fst",
"Vale.X64.State.vale_state"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__]
let mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none | false | true | Vale.AsLowStar.ValeSig.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 state_of : x: (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) -> Vale.X64.State.vale_state | [] | Vale.AsLowStar.ValeSig.state_of | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) -> Vale.X64.State.vale_state | {
"end_col": 49,
"end_line": 66,
"start_col": 44,
"start_line": 66
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 sprop = VS.vale_state -> prop | let sprop = | false | null | false | VS.vale_state -> prop | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Vale.X64.State.vale_state",
"Prims.prop"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__]
let mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none
let state_of (x:(V.va_state & V.va_fuel)) = fst x | false | true | Vale.AsLowStar.ValeSig.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 sprop : Type | [] | Vale.AsLowStar.ValeSig.sprop | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type | {
"end_col": 33,
"end_line": 68,
"start_col": 12,
"start_line": 68
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop) | let vale_pre_tl (dom: list td) = | false | null | false | n_arrow dom (V.va_state -> prop) | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.Interop.Base.td",
"Vale.Interop.Base.n_arrow",
"Vale.X64.Decls.va_state",
"Prims.prop"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__] | false | true | Vale.AsLowStar.ValeSig.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 vale_pre_tl : dom: Prims.list Vale.Interop.Base.td -> Type | [] | Vale.AsLowStar.ValeSig.vale_pre_tl | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dom: Prims.list Vale.Interop.Base.td -> Type | {
"end_col": 36,
"end_line": 21,
"start_col": 4,
"start_line": 21
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 fuel_of (x:(V.va_state & V.va_fuel)) = snd x | let fuel_of (x: (V.va_state & V.va_fuel)) = | false | null | false | snd x | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.snd"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__]
let mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none | false | true | Vale.AsLowStar.ValeSig.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 fuel_of : x: (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) -> Vale.X64.Decls.va_fuel | [] | Vale.AsLowStar.ValeSig.fuel_of | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) -> Vale.X64.Decls.va_fuel | {
"end_col": 48,
"end_line": 67,
"start_col": 43,
"start_line": 67
} |
|
Prims.GTot | val mloc_modified_args (args: list arg) : GTot ME.loc | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 mloc_modified_args (args:list arg) : GTot ME.loc =
List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none | val mloc_modified_args (args: list arg) : GTot ME.loc
let mloc_modified_args (args: list arg) : GTot ME.loc = | false | null | false | List.fold_right_gtot (List.map_gtot modified_arg_mloc args) ME.loc_union ME.loc_none | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"sometrivial"
] | [
"Prims.list",
"Vale.Interop.Base.arg",
"FStar.List.Tot.Base.fold_right_gtot",
"Vale.X64.Memory.loc",
"FStar.List.Tot.Base.map_gtot",
"Vale.AsLowStar.ValeSig.modified_arg_mloc",
"Vale.X64.Memory.loc_union",
"Vale.X64.Memory.loc_none"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__]
let vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop)
[@__reduce__]
let vale_post (dom:list td) =
code:V.va_code ->
vale_post_tl dom
let vale_save_reg (r:MS.reg_64) (s0 s1:V.va_state) =
VS.eval_reg_64 r s0 == VS.eval_reg_64 r s1
let vale_save_xmm (r:MS.reg_xmm) (s0 s1:V.va_state) =
VS.eval_reg_xmm r s0 == VS.eval_reg_xmm r s1
let vale_calling_conventions
(s0 s1:V.va_state)
(regs_modified:MS.reg_64 -> bool)
(xmms_modified:MS.reg_xmm -> bool) =
let open MS in
s1.VS.vs_ok /\
vale_save_reg MS.rRsp s0 s1 /\
(forall (r:MS.reg_64).
not (regs_modified r) ==> vale_save_reg r s0 s1) /\
(forall (x:MS.reg_xmm).
not (xmms_modified x) ==> vale_save_xmm x s0 s1)
[@__reduce__]
let modified_arg_mloc (x:arg) : GTot ME.loc =
match x with
| (|TD_Buffer src t {modified=true}, x|) -> ME.loc_buffer (as_vale_buffer #src #t x)
| _ -> ME.loc_none
[@__reduce__] | false | false | Vale.AsLowStar.ValeSig.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 mloc_modified_args (args: list arg) : GTot ME.loc | [] | Vale.AsLowStar.ValeSig.mloc_modified_args | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | args: Prims.list Vale.Interop.Base.arg -> Prims.GTot Vale.X64.Memory.loc | {
"end_col": 88,
"end_line": 64,
"start_col": 4,
"start_line": 64
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "List"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_Semantics_s",
"short_module": "BS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AsLowStar",
"short_module": null
},
{
"abbrev": 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 vale_post_tl (dom:list td) =
n_arrow dom
(s0:V.va_state -> s1:V.va_state -> f:V.va_fuel -> prop) | let vale_post_tl (dom: list td) = | false | null | false | n_arrow dom (s0: V.va_state -> s1: V.va_state -> f: V.va_fuel -> prop) | {
"checked_file": "Vale.AsLowStar.ValeSig.fst.checked",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_Semantics_s.fst.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.BigOps.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.AsLowStar.ValeSig.fst"
} | [
"total"
] | [
"Prims.list",
"Vale.Interop.Base.td",
"Vale.Interop.Base.n_arrow",
"Vale.X64.Decls.va_state",
"Vale.X64.Decls.va_fuel",
"Prims.prop"
] | [] | module Vale.AsLowStar.ValeSig
open FStar.Mul
open Vale.Arch.HeapImpl
open Vale.Interop.Base
module B = LowStar.Buffer
module BS = Vale.X64.Machine_Semantics_s
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module ME = Vale.X64.Memory
module MS = Vale.X64.Machine_s
module IA = Vale.Interop.Assumptions
module V = Vale.X64.Decls
module VS = Vale.X64.State
module IX64 = Vale.Interop.X64
module List = FStar.List.Tot
module Map16 = Vale.Lib.Map16
open Vale.X64.MemoryAdapters
[@__reduce__]
let vale_pre_tl (dom:list td) =
n_arrow dom (V.va_state -> prop)
[@__reduce__]
let vale_pre (dom:list td) =
code:V.va_code ->
vale_pre_tl dom
[@__reduce__] | false | true | Vale.AsLowStar.ValeSig.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 vale_post_tl : dom: Prims.list Vale.Interop.Base.td -> Type | [] | Vale.AsLowStar.ValeSig.vale_post_tl | {
"file_name": "vale/code/arch/x64/interop/Vale.AsLowStar.ValeSig.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | dom: Prims.list Vale.Interop.Base.td -> Type | {
"end_col": 67,
"end_line": 31,
"start_col": 4,
"start_line": 30
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.