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.HyperStack.ST.Stack | val load_precompute_r2:
p:precomp_r 2
-> r0:uint64
-> r1:uint64
-> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
load_precompute_r_post h1 p /\
(assert_norm (pow2 64 * pow2 64 = pow2 128);
feval h1 (gsub p 0ul 5ul) ==
LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0))) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"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.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"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_precompute_r2 p r0 r1 =
let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
let rn = sub p 10ul 5ul in
let rn_5 = sub p 15ul 5ul in
let r_vec0 = vec_load r0 2 in
let r_vec1 = vec_load r1 2 in
let h0 = ST.get () in
load_felem r r_vec0 r_vec1;
let h1 = ST.get () in
LSeq.eq_intro
(LSeq.createi #Vec.pfelem 2 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i]))
(LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0));
assert (feval h1 r == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0));
precompute_shift_reduce r5 r;
let h2 = ST.get () in
fmul_r rn r r r5;
let h3 = ST.get () in
LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h2 r).[0]);
precompute_shift_reduce rn_5 rn | val load_precompute_r2:
p:precomp_r 2
-> r0:uint64
-> r1:uint64
-> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
load_precompute_r_post h1 p /\
(assert_norm (pow2 64 * pow2 64 = pow2 128);
feval h1 (gsub p 0ul 5ul) ==
LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0)))
let load_precompute_r2 p r0 r1 = | true | null | false | let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
let rn = sub p 10ul 5ul in
let rn_5 = sub p 15ul 5ul in
let r_vec0 = vec_load r0 2 in
let r_vec1 = vec_load r1 2 in
let h0 = ST.get () in
load_felem r r_vec0 r_vec1;
let h1 = ST.get () in
LSeq.eq_intro (LSeq.createi #Vec.pfelem
2
(fun i -> (uint64xN_v r_vec1).[ i ] * pow2 64 + (uint64xN_v r_vec0).[ i ]))
(LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0));
assert (feval h1 r == LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0));
precompute_shift_reduce r5 r;
let h2 = ST.get () in
fmul_r rn r r r5;
let h3 = ST.get () in
LSeq.eq_intro (feval h3 rn) (Vec.compute_rw (feval h2 r).[ 0 ]);
precompute_shift_reduce rn_5 rn | {
"checked_file": "Hacl.Impl.Poly1305.Field32xN.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntVector.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.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.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Poly1305.Field32xN.fst"
} | [] | [
"Hacl.Impl.Poly1305.Field32xN.precomp_r",
"Lib.IntTypes.uint64",
"Hacl.Impl.Poly1305.Field32xN.precompute_shift_reduce",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Hacl.Spec.Poly1305.Vec.pfelem",
"Hacl.Impl.Poly1305.Field32xN.feval",
"Hacl.Spec.Poly1305.Vec.compute_rw",
"Hacl.Impl.Poly1305.Field32xN.op_String_Access",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Impl.Poly1305.Field32xN.fmul_r",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.lseq",
"Lib.Sequence.create",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Lib.IntTypes.uint_v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Lib.Sequence.createi",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Poly1305.Field32xN.uint64xN_v",
"Hacl.Impl.Poly1305.Field32xN.load_felem",
"Lib.IntVector.vec_t",
"Lib.IntTypes.int_t",
"Lib.IntVector.vec_v",
"Lib.IntVector.vec_load",
"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
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Lib.IntVector
include Hacl.Spec.Poly1305.Field32xN
open Hacl.Spec.Poly1305.Field32xN.Lemmas
open Hacl.Impl.Poly1305.Lemmas
module Vec = Hacl.Spec.Poly1305.Vec
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 50 --using_facts_from '* -FStar.Seq'"
inline_for_extraction noextract
let felem (w:lanes) = lbuffer (uint64xN w) 5ul
inline_for_extraction noextract
let felem_wide (w:lanes) = felem w
inline_for_extraction noextract
let precomp_r (w:lanes) = lbuffer (uint64xN w) 20ul
unfold noextract
let op_String_Access #a #len = LSeq.index #a #len
noextract
val as_tup5: #w:lanes -> h:mem -> f:felem w -> GTot (felem5 w)
let as_tup5 #w h f =
let s = as_seq h f in
let s0 = s.[0] in
let s1 = s.[1] in
let s2 = s.[2] in
let s3 = s.[3] in
let s4 = s.[4] in
(s0,s1,s2,s3,s4)
noextract
val felem_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0
let felem_fits #w h f m =
felem_fits5 (as_tup5 h f) m
noextract
val felem_wide_fits: #w:lanes -> h:mem -> f:felem w -> m:scale32_5 -> Type0
let felem_wide_fits #w h f m =
felem_wide_fits5 (as_tup5 h f) m
noextract
let feval (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq Vec.pfelem w) =
feval5 (as_tup5 h f)
noextract
let fas_nat (#w:lanes) (h:mem) (f:felem w) : GTot (LSeq.lseq nat w) =
fas_nat5 (as_tup5 h f)
noextract
let felem_less (#w:lanes) (h:mem) (f:felem w) (max:nat) : Type0 =
felem_less5 (as_tup5 h f) max
val lemma_feval_is_fas_nat:
#w:lanes
-> h:mem
-> f:felem w
-> Lemma
(requires felem_less h f (pow2 128))
(ensures (forall (i:nat). i < w ==> (feval h f).[i] == (fas_nat h f).[i]))
let lemma_feval_is_fas_nat #w h f =
lemma_feval_is_fas_nat (as_tup5 h f)
inline_for_extraction noextract
val fmul_precomp_r_pre:
#w:lanes
-> h:mem
-> precomp:precomp_r w
-> Type0
let fmul_precomp_r_pre #w h precomp =
let r = gsub precomp 0ul 5ul in
let r_5 = gsub precomp 5ul 5ul in
felem_fits h r (1, 1, 1, 1, 1) /\
felem_fits h r_5 (5, 5, 5, 5, 5) /\
as_tup5 h r_5 == precomp_r5 (as_tup5 h r)
noextract
val load_precompute_r_post:
#w:lanes
-> h:mem
-> p:precomp_r w
-> Type0
let load_precompute_r_post #w h p =
assert_norm (pow2 128 < Vec.prime);
let r = gsub p 0ul 5ul in
let rn = gsub p 10ul 5ul in
let rn_5 = gsub p 15ul 5ul in
fmul_precomp_r_pre h p /\
felem_fits h rn (2, 2, 2, 2, 2) /\
felem_fits h rn_5 (10, 10, 10, 10, 10) /\
as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn) /\
feval h rn == Vec.compute_rw (feval h r).[0]
inline_for_extraction noextract
val create_felem:
w:lanes
-> StackInline (felem w)
(requires fun h -> True)
(ensures fun h0 b h1 ->
stack_allocated b h0 h1 (LSeq.create 5 (zero w)) /\
feval h1 b == LSeq.create w 0)
let create_felem w =
let r = create 5ul (zero w) in
let h1 = ST.get () in
LSeq.eq_intro (feval h1 r) (LSeq.create w 0);
r
#push-options "--z3rlimit 100"
inline_for_extraction noextract
val set_bit:
#w:lanes
-> f:felem w
-> i:size_t{size_v i <= 128}
-> Stack unit
(requires fun h ->
live h f /\
felem_fits h f (1, 1, 1, 1, 1) /\
felem_less #w h f (pow2 (v i)))
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(Math.Lemmas.pow2_le_compat 128 (v i);
feval h1 f == LSeq.map (Vec.pfadd (pow2 (v i))) (feval h0 f)))
let set_bit #w f i =
let b = u64 1 <<. (i %. 26ul) in
let mask = vec_load b w in
let fi = f.(i /. 26ul) in
let h0 = ST.get () in
f.(i /. 26ul) <- vec_or fi mask;
set_bit5_lemma (as_seq h0 f) (v i)
#pop-options
inline_for_extraction noextract
val set_bit128:
#w:lanes
-> f:felem w
-> Stack unit
(requires fun h ->
live h f /\
felem_fits h f (1, 1, 1, 1, 1) /\
felem_less #w h f (pow2 128))
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
feval h1 f == LSeq.map (Vec.pfadd (pow2 128)) (feval h0 f))
let set_bit128 #w f =
let b = u64 0x1000000 in
assert_norm (0x1000000 = pow2 24);
assert (v b == v (u64 1 <<. 24ul));
let mask = vec_load b w in
let f4 = f.(4ul) in
let h0 = ST.get () in
f.(4ul) <- vec_or f4 mask;
set_bit5_lemma (as_seq h0 f) 128
inline_for_extraction noextract
val set_zero:
#w:lanes
-> f:felem w
-> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (0, 0, 0, 0, 0) /\
feval h1 f == LSeq.create w 0)
let set_zero #w f =
f.(0ul) <- zero w;
f.(1ul) <- zero w;
f.(2ul) <- zero w;
f.(3ul) <- zero w;
f.(4ul) <- zero w;
let h1 = ST.get () in
LSeq.eq_intro (feval h1 f) (LSeq.create w 0)
inline_for_extraction noextract
val copy_felem:
#w:lanes
-> #m:scale32_5
-> f1:felem w
-> f2:felem w
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ disjoint f1 f2 /\
felem_fits h f2 m)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
felem_fits h1 f1 m /\
as_tup5 h1 f1 == as_tup5 h0 f2)
let copy_felem #w #m f1 f2 =
f1.(0ul) <- f2.(0ul);
f1.(1ul) <- f2.(1ul);
f1.(2ul) <- f2.(2ul);
f1.(3ul) <- f2.(3ul);
f1.(4ul) <- f2.(4ul)
inline_for_extraction noextract
val fadd:
#w:lanes
-> out:felem w
-> f1:felem w
-> f2:felem w
-> Stack unit
(requires fun h ->
live h f1 /\ live h f2 /\ live h out /\
felem_fits h f1 (2,2,2,2,2) /\
felem_fits h f2 (1,1,1,1,1))
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
//as_tup5 h1 out == fadd5 (as_tup5 h0 f1) (as_tup5 h0 f2) /\
felem_fits h1 out (3,3,3,3,3) /\
feval h1 out == LSeq.map2 Vec.pfadd (feval h0 f1) (feval h0 f2))
let fadd #w out f1 f2 =
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
let (o0,o1,o2,o3,o4) =
fadd5 #w (f10,f11,f12,f13,f14) (f20,f21,f22,f23,f24) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
#push-options "--max_fuel 1"
inline_for_extraction noextract
val fmul_r:
#w:lanes
-> out:felem w
-> f1:felem w
-> r:felem w
-> r5:felem w
-> Stack unit
(requires fun h ->
live h out /\ live h f1 /\
live h r /\ live h r5 /\
felem_fits h f1 (3,3,3,3,3) /\
felem_fits h r (2,2,2,2,2) /\
felem_fits h r5 (10,10,10,10,10) /\
as_tup5 h r5 == precomp_r5 (as_tup5 h r))
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (1,2,1,1,2) /\
feval h1 out == LSeq.map2 (Vec.pfmul) (feval h0 f1) (feval h0 r))
let fmul_r #w out f1 r r5 =
let r0 = r.(0ul) in
let r1 = r.(1ul) in
let r2 = r.(2ul) in
let r3 = r.(3ul) in
let r4 = r.(4ul) in
let r50 = r5.(0ul) in
let r51 = r5.(1ul) in
let r52 = r5.(2ul) in
let r53 = r5.(3ul) in
let r54 = r5.(4ul) in
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let (o0, o1, o2, o3, o4) =
fmul_r5 #w (f10, f11, f12, f13, f14)
(r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
#pop-options
inline_for_extraction noextract
val fadd_mul_r:
#w:lanes
-> acc:felem w
-> f1:felem w
-> p:precomp_r w
-> Stack unit
(requires fun h ->
live h acc /\ live h f1 /\ live h p /\
felem_fits h acc (2,2,2,2,2) /\
felem_fits h f1 (1,1,1,1,1) /\
fmul_precomp_r_pre h p)
(ensures fun h0 _ h1 ->
modifies (loc acc) h0 h1 /\
felem_fits h1 acc (1,2,1,1,2) /\
feval h1 acc == LSeq.map2 (Vec.pfmul)
(LSeq.map2 (Vec.pfadd) (feval h0 acc) (feval h0 f1)) (feval h0 (gsub p 0ul 5ul)))
let fadd_mul_r #w out f1 p =
let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
let r0 = r.(0ul) in
let r1 = r.(1ul) in
let r2 = r.(2ul) in
let r3 = r.(3ul) in
let r4 = r.(4ul) in
let r50 = r5.(0ul) in
let r51 = r5.(1ul) in
let r52 = r5.(2ul) in
let r53 = r5.(3ul) in
let r54 = r5.(4ul) in
let f10 = f1.(0ul) in
let f11 = f1.(1ul) in
let f12 = f1.(2ul) in
let f13 = f1.(3ul) in
let f14 = f1.(4ul) in
let a0 = out.(0ul) in
let a1 = out.(1ul) in
let a2 = out.(2ul) in
let a3 = out.(3ul) in
let a4 = out.(4ul) in
let (o0, o1, o2, o3, o4) =
fadd_mul_r5 #w (a0, a1, a2, a3, a4) (f10, f11, f12, f13, f14)
(r0, r1, r2, r3, r4) (r50, r51, r52, r53, r54) in
out.(0ul) <- o0;
out.(1ul) <- o1;
out.(2ul) <- o2;
out.(3ul) <- o3;
out.(4ul) <- o4
inline_for_extraction noextract
val fmul_rn:
#w:lanes
-> out:felem w
-> f1:felem w
-> p:precomp_r w
-> Stack unit
(requires fun h ->
live h out /\ live h f1 /\ live h p /\
(let rn = gsub p 10ul 5ul in
let rn_5 = gsub p 15ul 5ul in
felem_fits h f1 (3,3,3,3,3) /\
felem_fits h rn (2,2,2,2,2) /\
felem_fits h rn_5 (10,10,10,10,10) /\
as_tup5 h rn_5 == precomp_r5 (as_tup5 h rn)))
(ensures fun h0 _ h1 ->
modifies (loc out) h0 h1 /\
felem_fits h1 out (1,2,1,1,2) /\
feval h1 out == LSeq.map2 Vec.pfmul (feval h0 f1) (feval h0 (gsub p 10ul 5ul)))
let fmul_rn #w out f1 p =
let rn = sub p 10ul 5ul in
let rn5 = sub p 15ul 5ul in
fmul_r #w out f1 rn rn5
inline_for_extraction noextract
val reduce_felem:
#w:lanes
-> f:felem w
-> Stack unit
(requires fun h ->
live h f /\ felem_fits h f (2,2,2,2,2))
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
(fas_nat h1 f).[0] == (feval h0 f).[0])
let reduce_felem #w f =
let f0 = f.(0ul) in
let f1 = f.(1ul) in
let f2 = f.(2ul) in
let f3 = f.(3ul) in
let f4 = f.(4ul) in
let (f0, f1, f2, f3, f4) =
reduce_felem5 (f0, f1, f2, f3, f4) in
f.(0ul) <- f0;
f.(1ul) <- f1;
f.(2ul) <- f2;
f.(3ul) <- f3;
f.(4ul) <- f4
inline_for_extraction noextract
val precompute_shift_reduce:
#w:lanes
-> f1:felem w
-> f2:felem w
-> Stack unit
(requires fun h -> live h f1 /\ live h f2)
(ensures fun h0 _ h1 ->
modifies (loc f1) h0 h1 /\
as_tup5 h1 f1 == precomp_r5 (as_tup5 h0 f2))
let precompute_shift_reduce #w f1 f2 =
let f20 = f2.(0ul) in
let f21 = f2.(1ul) in
let f22 = f2.(2ul) in
let f23 = f2.(3ul) in
let f24 = f2.(4ul) in
f1.(0ul) <- vec_smul_mod f20 (u64 5);
f1.(1ul) <- vec_smul_mod f21 (u64 5);
f1.(2ul) <- vec_smul_mod f22 (u64 5);
f1.(3ul) <- vec_smul_mod f23 (u64 5);
f1.(4ul) <- vec_smul_mod f24 (u64 5)
inline_for_extraction noextract
val load_felem:
#w:lanes
-> f:felem w
-> lo:uint64xN w
-> hi:uint64xN w
-> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 ->
modifies (loc f) h0 h1 /\
felem_fits h1 f (1, 1, 1, 1, 1) /\
felem_less h1 f (pow2 128) /\
feval h1 f == LSeq.createi #Vec.pfelem w
(fun i -> (uint64xN_v hi).[i] * pow2 64 + (uint64xN_v lo).[i]))
let load_felem #w f lo hi =
let (f0, f1, f2, f3, f4) = load_felem5 #w lo hi in
load_felem5_lemma #w lo hi;
f.(0ul) <- f0;
f.(1ul) <- f1;
f.(2ul) <- f2;
f.(3ul) <- f3;
f.(4ul) <- f4
#push-options "--max_fuel 2"
inline_for_extraction noextract
val load_precompute_r1:
p:precomp_r 1
-> r0:uint64
-> r1:uint64
-> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
load_precompute_r_post h1 p /\
(assert_norm (pow2 64 * pow2 64 = pow2 128);
feval h1 (gsub p 0ul 5ul) ==
LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0)))
let load_precompute_r1 p r0 r1 =
let r = sub p 0ul 5ul in
let r5 = sub p 5ul 5ul in
let rn = sub p 10ul 5ul in
let rn_5 = sub p 15ul 5ul in
let r_vec0 = vec_load r0 1 in
let r_vec1 = vec_load r1 1 in
let h0 = ST.get () in
load_felem r r_vec0 r_vec1;
let h1 = ST.get () in
LSeq.eq_intro
(LSeq.createi #Vec.pfelem 1 (fun i -> (uint64xN_v r_vec1).[i] * pow2 64 + (uint64xN_v r_vec0).[i]))
(LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0));
assert (feval h1 r == LSeq.create 1 (uint_v r1 * pow2 64 + uint_v r0));
precompute_shift_reduce r5 r;
copy_felem #_ #(1,1,1,1,1) rn r;
copy_felem #_ #(5,5,5,5,5) rn_5 r5
inline_for_extraction noextract
val load_precompute_r2:
p:precomp_r 2
-> r0:uint64
-> r1:uint64
-> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
load_precompute_r_post h1 p /\
(assert_norm (pow2 64 * pow2 64 = pow2 128);
feval h1 (gsub p 0ul 5ul) == | false | false | Hacl.Impl.Poly1305.Field32xN.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 2,
"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_precompute_r2:
p:precomp_r 2
-> r0:uint64
-> r1:uint64
-> Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 ->
modifies (loc p) h0 h1 /\
load_precompute_r_post h1 p /\
(assert_norm (pow2 64 * pow2 64 = pow2 128);
feval h1 (gsub p 0ul 5ul) ==
LSeq.create 2 (uint_v r1 * pow2 64 + uint_v r0))) | [] | Hacl.Impl.Poly1305.Field32xN.load_precompute_r2 | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Field32xN.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Hacl.Impl.Poly1305.Field32xN.precomp_r 2 -> r0: Lib.IntTypes.uint64 -> r1: Lib.IntTypes.uint64
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 33,
"end_line": 512,
"start_col": 32,
"start_line": 490
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16_view = Vale.Interop.Views.up_view16 | let uint16_view = | false | null | false | Vale.Interop.Views.up_view16 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Views.up_view16"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
() | false | true | Vale.PPC64LE.Memory.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 uint16_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt16.t | [] | Vale.PPC64LE.Memory.uint16_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt16.t | {
"end_col": 46,
"end_line": 59,
"start_col": 18,
"start_line": 59
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tuint8 = UInt8.t | let tuint8 = | false | null | false | UInt8.t | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.UInt8.t"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId | false | true | Vale.PPC64LE.Memory.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 tuint8 : Prims.eqtype | [] | Vale.PPC64LE.Memory.tuint8 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 20,
"end_line": 31,
"start_col": 13,
"start_line": 31
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tuint32 = UInt32.t | let tuint32 = | false | null | false | UInt32.t | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.UInt32.t"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t | false | true | Vale.PPC64LE.Memory.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 tuint32 : Prims.eqtype | [] | Vale.PPC64LE.Memory.tuint32 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 22,
"end_line": 33,
"start_col": 14,
"start_line": 33
} |
|
Prims.GTot | val loc_union (s1 s2:loc) : GTot loc | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_union = M.loc_union | val loc_union (s1 s2:loc) : GTot loc
let loc_union = | false | null | false | M.loc_union | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"LowStar.Monotonic.Buffer.loc_union"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc | false | false | Vale.PPC64LE.Memory.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 loc_union (s1 s2:loc) : GTot loc | [] | Vale.PPC64LE.Memory.loc_union | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> Prims.GTot Vale.PPC64LE.Memory.loc | {
"end_col": 27,
"end_line": 81,
"start_col": 16,
"start_line": 81
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tuint64 = UInt64.t | let tuint64 = | false | null | false | UInt64.t | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.UInt64.t"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t | false | true | Vale.PPC64LE.Memory.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 tuint64 : Prims.eqtype | [] | Vale.PPC64LE.Memory.tuint64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 22,
"end_line": 34,
"start_col": 14,
"start_line": 34
} |
|
Prims.GTot | val writeable_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable | val writeable_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool
let writeable_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool = | false | null | false | valid_buffer t addr b h && b.writeable | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_AmpAmp",
"Vale.PPC64LE.Memory.valid_buffer",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h | false | false | Vale.PPC64LE.Memory.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": 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 writeable_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.writeable_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
b: Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | {
"end_col": 40,
"end_line": 345,
"start_col": 2,
"start_line": 345
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let b8 = IB.b8 | let b8 = | false | null | false | IB.b8 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Types.b8"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1" | false | true | Vale.PPC64LE.Memory.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 b8 : Type0 | [] | Vale.PPC64LE.Memory.b8 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 14,
"end_line": 23,
"start_col": 9,
"start_line": 23
} |
|
Prims.Tot | val scale_t (t: base_typ) (index: int) : int | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index | val scale_t (t: base_typ) (index: int) : int
let scale_t (t: base_typ) (index: int) : int = | false | null | false | scale_by (view_n t) index | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.PPC64LE.Memory.scale_by",
"Vale.Interop.Types.view_n"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end | false | true | Vale.PPC64LE.Memory.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": 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 scale_t (t: base_typ) (index: int) : int | [] | Vale.PPC64LE.Memory.scale_t | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> index: Prims.int -> Prims.int | {
"end_col": 77,
"end_line": 310,
"start_col": 52,
"start_line": 310
} |
Prims.GTot | val loc_includes (s1 s2:loc) : GTot prop0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes = M.loc_includes | val loc_includes (s1 s2:loc) : GTot prop0
let loc_includes = | false | null | false | M.loc_includes | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"LowStar.Monotonic.Buffer.loc_includes"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc | false | false | Vale.PPC64LE.Memory.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 loc_includes (s1 s2:loc) : GTot prop0 | [] | Vale.PPC64LE.Memory.loc_includes | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 33,
"end_line": 84,
"start_col": 19,
"start_line": 84
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2 | let sub_list (p1 p2: list 'a) = | false | null | false | forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Prims.list",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub_list : p1: Prims.list 'a -> p2: Prims.list 'a -> Prims.logical | [] | Vale.PPC64LE.Memory.sub_list | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p1: Prims.list 'a -> p2: Prims.list 'a -> Prims.logical | {
"end_col": 100,
"end_line": 348,
"start_col": 31,
"start_line": 348
} |
|
Prims.GTot | val writeable_mem64 (ptr:int) (h:vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h | val writeable_mem64 (ptr:int) (h:vale_heap) : GTot bool
let writeable_mem64 ptr h = | false | null | false | writeable_mem (TUInt64) ptr h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.writeable_mem",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val writeable_mem64 (ptr:int) (h:vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.writeable_mem64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.bool | {
"end_col": 57,
"end_line": 410,
"start_col": 28,
"start_line": 410
} |
Prims.GTot | val store_mem64 (ptr:int) (v:nat64) (h:vale_heap) : GTot vale_heap | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h | val store_mem64 (ptr:int) (v:nat64) (h:vale_heap) : GTot vale_heap
let store_mem64 i v h = | false | null | false | if not (valid_mem64 i h) then h else store_mem (TUInt64) i v h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Def.Types_s.nat64",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.valid_mem64",
"Prims.bool",
"Vale.PPC64LE.Memory.store_mem",
"Vale.Arch.HeapTypes_s.TUInt64"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_mem64 (ptr:int) (v:nat64) (h:vale_heap) : GTot vale_heap | [] | Vale.PPC64LE.Memory.store_mem64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.Def.Types_s.nat64 -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Arch.HeapImpl.vale_heap | {
"end_col": 32,
"end_line": 475,
"start_col": 2,
"start_line": 474
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32_view = Vale.Interop.Views.up_view32 | let uint32_view = | false | null | false | Vale.Interop.Views.up_view32 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Views.up_view32"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8 | false | true | Vale.PPC64LE.Memory.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 uint32_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt32.t | [] | Vale.PPC64LE.Memory.uint32_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt32.t | {
"end_col": 46,
"end_line": 60,
"start_col": 18,
"start_line": 60
} |
|
Prims.GTot | val loc_disjoint (s1 s2:loc) : GTot prop0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_disjoint = M.loc_disjoint | val loc_disjoint (s1 s2:loc) : GTot prop0
let loc_disjoint = | false | null | false | M.loc_disjoint | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"LowStar.Monotonic.Buffer.loc_disjoint"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union | false | false | Vale.PPC64LE.Memory.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 loc_disjoint (s1 s2:loc) : GTot prop0 | [] | Vale.PPC64LE.Memory.loc_disjoint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 33,
"end_line": 83,
"start_col": 19,
"start_line": 83
} |
Prims.GTot | val store_mem128 (ptr:int) (v:quad32) (h:vale_heap) : GTot vale_heap | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h | val store_mem128 (ptr:int) (v:quad32) (h:vale_heap) : GTot vale_heap
let store_mem128 ptr v h = | false | null | false | if not (valid_mem128 ptr h) then h else store_mem (TUInt128) ptr v h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Def.Types_s.quad32",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.valid_mem128",
"Prims.bool",
"Vale.PPC64LE.Memory.store_mem",
"Vale.Arch.HeapTypes_s.TUInt128"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_mem128 (ptr:int) (v:quad32) (h:vale_heap) : GTot vale_heap | [] | Vale.PPC64LE.Memory.store_mem128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> v: Vale.Def.Types_s.quad32 -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Arch.HeapImpl.vale_heap | {
"end_col": 35,
"end_line": 498,
"start_col": 2,
"start_line": 497
} |
Prims.Tot | val layout_heaplets_initialized (layout:vale_heap_layout_inner) : bool | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let layout_heaplets_initialized layout = layout.vl_heaplets_initialized | val layout_heaplets_initialized (layout:vale_heap_layout_inner) : bool
let layout_heaplets_initialized layout = | false | null | false | layout.vl_heaplets_initialized | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplets_initialized",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized
let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
) | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val layout_heaplets_initialized (layout:vale_heap_layout_inner) : bool | [] | Vale.PPC64LE.Memory.layout_heaplets_initialized | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | layout: Vale.Arch.HeapImpl.vale_heap_layout_inner -> Prims.bool | {
"end_col": 71,
"end_line": 753,
"start_col": 41,
"start_line": 753
} |
Prims.GTot | val valid_mem64 (ptr:int) (h:vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_mem64 ptr h = valid_mem (TUInt64) ptr h | val valid_mem64 (ptr:int) (h:vale_heap) : GTot bool
let valid_mem64 ptr h = | false | null | false | valid_mem (TUInt64) ptr h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.valid_mem",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_mem64 (ptr:int) (h:vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.valid_mem64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.bool | {
"end_col": 49,
"end_line": 360,
"start_col": 24,
"start_line": 360
} |
Prims.GTot | val valid_taint_buf (#t:base_typ) (b:buffer t) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn | val valid_taint_buf (#t:base_typ) (b:buffer t) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0
let valid_taint_buf #t b h mt tn = | false | null | false | valid_taint_b8 b h mt tn | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Vale.Arch.HeapTypes_s.taint",
"Vale.PPC64LE.Memory.valid_taint_b8",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_taint_buf (#t:base_typ) (b:buffer t) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 | [] | Vale.PPC64LE.Memory.valid_taint_buf | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer t ->
h: Vale.Arch.HeapImpl.vale_heap ->
mt: Vale.PPC64LE.Memory.memtaint ->
tn: Vale.Arch.HeapTypes_s.taint
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 26,
"end_line": 568,
"start_col": 2,
"start_line": 568
} |
Prims.Tot | val layout_old_heap (layout:vale_heap_layout_inner) : vale_heap | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let layout_old_heap layout = layout.vl_old_heap | val layout_old_heap (layout:vale_heap_layout_inner) : vale_heap
let layout_old_heap layout = | false | null | false | layout.vl_old_heap | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_old_heap",
"Vale.Arch.HeapImpl.vale_heap"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized
let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
) | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val layout_old_heap (layout:vale_heap_layout_inner) : vale_heap | [] | Vale.PPC64LE.Memory.layout_old_heap | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | layout: Vale.Arch.HeapImpl.vale_heap_layout_inner -> Vale.Arch.HeapImpl.vale_heap | {
"end_col": 47,
"end_line": 754,
"start_col": 29,
"start_line": 754
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let tuint16 = UInt16.t | let tuint16 = | false | null | false | UInt16.t | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.UInt16.t"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId | false | true | Vale.PPC64LE.Memory.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 tuint16 : Prims.eqtype | [] | Vale.PPC64LE.Memory.tuint16 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 22,
"end_line": 32,
"start_col": 14,
"start_line": 32
} |
|
Prims.Tot | val get_heaplet_id (h:vale_heap) : option heaplet_id | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_heaplet_id h =
h.heapletId | val get_heaplet_id (h:vale_heap) : option heaplet_id
let get_heaplet_id h = | false | null | false | h.heapletId | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd | false | true | Vale.PPC64LE.Memory.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 get_heaplet_id (h:vale_heap) : option heaplet_id | [] | Vale.PPC64LE.Memory.get_heaplet_id | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.Arch.HeapImpl.vale_heap -> FStar.Pervasives.Native.option Vale.Arch.HeapImpl.heaplet_id | {
"end_col": 13,
"end_line": 29,
"start_col": 2,
"start_line": 29
} |
Prims.Tot | val mem_inv (h:vale_full_heap) : prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
) | val mem_inv (h:vale_full_heap) : prop0
let mem_inv h = | false | null | false | h.vf_heap.heapletId == None /\ inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then inv_heaplets h.vf_layout.vl_inner h.vf_heap h.vf_heaplets h.vf_layout.vl_taint
else h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_full_heap",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heap",
"FStar.Pervasives.Native.None",
"Vale.PPC64LE.Memory.inv_heaplet_ids",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplets_initialized",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_inner",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout",
"Vale.PPC64LE.Memory.inv_heaplets",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_taint",
"Prims.bool",
"Vale.Arch.HeapImpl.vale_heaplets",
"Vale.Arch.HeapImpl.empty_vale_heaplets",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_old_heap",
"Prims.logical",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mem_inv (h:vale_full_heap) : prop0 | [] | Vale.PPC64LE.Memory.mem_inv | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.Arch.HeapImpl.vale_full_heap -> Vale.Def.Prop_s.prop0 | {
"end_col": 3,
"end_line": 751,
"start_col": 2,
"start_line": 743
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_view = Vale.Interop.Views.up_view64 | let uint64_view = | false | null | false | Vale.Interop.Views.up_view64 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Views.up_view64"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16 | false | true | Vale.PPC64LE.Memory.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 uint64_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt64.t | [] | Vale.PPC64LE.Memory.uint64_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt64.t | {
"end_col": 46,
"end_line": 61,
"start_col": 18,
"start_line": 61
} |
|
Prims.GTot | val buffer_writeable (#t:base_typ) (b:buffer t) : GTot prop0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_writeable #t b = b.writeable | val buffer_writeable (#t:base_typ) (b:buffer t) : GTot prop0
let buffer_writeable #t b = | false | null | false | b.writeable | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Prims.b2t",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | false | false | Vale.PPC64LE.Memory.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 buffer_writeable (#t:base_typ) (b:buffer t) : GTot prop0 | [] | Vale.PPC64LE.Memory.buffer_writeable | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.PPC64LE.Memory.buffer t -> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 39,
"end_line": 77,
"start_col": 28,
"start_line": 77
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8_view = Vale.Interop.Views.up_view8 | let uint8_view = | false | null | false | Vale.Interop.Views.up_view8 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Views.up_view8"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
() | false | true | Vale.PPC64LE.Memory.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 uint8_view : LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt8.t | [] | Vale.PPC64LE.Memory.uint8_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | LowStar.BufferView.Up.view FStar.UInt8.t FStar.UInt8.t | {
"end_col": 44,
"end_line": 58,
"start_col": 17,
"start_line": 58
} |
|
Prims.GTot | val buffer_readable (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot prop0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h)) | val buffer_readable (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot prop0
let buffer_readable #t h b = | false | null | false | List.memP b (IB.ptrs_of_mem (_ih h)) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.buffer",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.ptrs_of_mem",
"Vale.Arch.HeapImpl._ih",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | false | false | Vale.PPC64LE.Memory.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 buffer_readable (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot prop0 | [] | Vale.PPC64LE.Memory.buffer_readable | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.PPC64LE.Memory.buffer t
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 65,
"end_line": 76,
"start_col": 29,
"start_line": 76
} |
Prims.Tot | val loc_none : loc | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_none = M.loc_none | val loc_none : loc
let loc_none = | false | null | false | M.loc_none | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"LowStar.Monotonic.Buffer.loc_none"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | false | true | Vale.PPC64LE.Memory.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 loc_none : loc | [] | Vale.PPC64LE.Memory.loc_none | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Vale.PPC64LE.Memory.loc | {
"end_col": 25,
"end_line": 80,
"start_col": 15,
"start_line": 80
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint128_view = Vale.Interop.Views.up_view128 | let uint128_view = | false | null | false | Vale.Interop.Views.up_view128 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Interop.Views.up_view128"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32 | false | true | Vale.PPC64LE.Memory.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 uint128_view : LowStar.BufferView.Up.view FStar.UInt8.t Vale.Def.Types_s.quad32 | [] | Vale.PPC64LE.Memory.uint128_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | LowStar.BufferView.Up.view FStar.UInt8.t Vale.Def.Types_s.quad32 | {
"end_col": 48,
"end_line": 62,
"start_col": 19,
"start_line": 62
} |
|
Prims.Ghost | val get_addr_in_ptr (t: base_typ) (n base addr i: nat)
: Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i]) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1) | val get_addr_in_ptr (t: base_typ) (n base addr i: nat)
: Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
let rec get_addr_in_ptr (t: base_typ) (n base addr i: nat)
: Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i]) = | false | null | false | if base + scale_t t i = addr then i else get_addr_in_ptr t n base addr (i + 1) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
""
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Addition",
"Vale.PPC64LE.Memory.scale_t",
"Prims.bool",
"Vale.PPC64LE.Memory.get_addr_in_ptr",
"Vale.PPC64LE.Memory.valid_offset",
"Prims.eq2"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i]) | false | false | Vale.PPC64LE.Memory.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": 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 get_addr_in_ptr (t: base_typ) (n base addr i: nat)
: Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i]) | [
"recursion"
] | Vale.PPC64LE.Memory.get_addr_in_ptr | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
n: Prims.nat ->
base: Prims.nat ->
addr: Prims.nat ->
i: Prims.nat
-> Prims.Ghost Prims.nat | {
"end_col": 44,
"end_line": 338,
"start_col": 2,
"start_line": 337
} |
Prims.GTot | val loc_buffer (#t:base_typ) (b:buffer t) : GTot loc | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_buffer #t b = M.loc_buffer b.bsrc | val loc_buffer (#t:base_typ) (b:buffer t) : GTot loc
let loc_buffer #t b = | false | null | false | M.loc_buffer b.bsrc | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"LowStar.Monotonic.Buffer.loc_buffer",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.PPC64LE.Memory.loc"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none | false | false | Vale.PPC64LE.Memory.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 loc_buffer (#t:base_typ) (b:buffer t) : GTot loc | [] | Vale.PPC64LE.Memory.loc_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.PPC64LE.Memory.buffer t -> Prims.GTot Vale.PPC64LE.Memory.loc | {
"end_col": 41,
"end_line": 82,
"start_col": 22,
"start_line": 82
} |
Prims.GTot | val buffer_length (#t:base_typ) (b:buffer t) : GTot nat | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | val buffer_length (#t:base_typ) (b:buffer t) : GTot nat
let buffer_length #t b = | false | null | false | UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"LowStar.BufferView.Up.length",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.PPC64LE.Memory.uint_view",
"Prims.nat"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h)) | false | false | Vale.PPC64LE.Memory.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 buffer_length (#t:base_typ) (b:buffer t) : GTot nat | [] | Vale.PPC64LE.Memory.buffer_length | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.PPC64LE.Memory.buffer t -> Prims.GTot Prims.nat | {
"end_col": 85,
"end_line": 78,
"start_col": 25,
"start_line": 78
} |
Prims.Ghost | val find_valid_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h | val find_valid_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
let rec find_valid_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps) = | false | null | false | match ps with
| [] -> None
| a :: q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"FStar.Pervasives.Native.None",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.valid_buffer",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"Vale.PPC64LE.Memory.find_valid_buffer_aux",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.sub_list",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.b2t",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.valid_mem_aux",
"Prims.l_and",
"FStar.List.Tot.Base.memP"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_valid_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps) | [
"recursion"
] | Vale.PPC64LE.Memory.find_valid_buffer_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | {
"end_col": 88,
"end_line": 371,
"start_col": 2,
"start_line": 369
} |
Prims.Tot | val loc : Type u#0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc = M.loc | val loc : Type u#0
let loc = | false | null | false | M.loc | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"LowStar.Monotonic.Buffer.loc"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable | false | true | Vale.PPC64LE.Memory.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 loc : Type u#0 | [] | Vale.PPC64LE.Memory.loc | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 15,
"end_line": 79,
"start_col": 10,
"start_line": 79
} |
Prims.GTot | val buffer_addr (#t:base_typ) (b:buffer t) (h:vale_heap) : GTot int | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b | val buffer_addr (#t:base_typ) (b:buffer t) (h:vale_heap) : GTot int
let buffer_addr #t b h = | false | null | false | IB.addrs_of_mem (_ih h) b | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Interop.Heap_s.addrs_of_mem",
"Vale.Arch.HeapImpl._ih",
"Prims.int"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs | false | false | Vale.PPC64LE.Memory.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 buffer_addr (#t:base_typ) (b:buffer t) (h:vale_heap) : GTot int | [] | Vale.PPC64LE.Memory.buffer_addr | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.PPC64LE.Memory.buffer t -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.int | {
"end_col": 50,
"end_line": 92,
"start_col": 25,
"start_line": 92
} |
FStar.Pervasives.Lemma | val loc_includes_union_l_buffer (#t:base_typ) (s1 s2:loc) (b:buffer t) : Lemma
(requires (loc_includes s1 (loc_buffer b) \/ loc_includes s2 (loc_buffer b)))
(ensures (loc_includes (loc_union s1 s2) (loc_buffer b)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_buffer b))] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b) | val loc_includes_union_l_buffer (#t:base_typ) (s1 s2:loc) (b:buffer t) : Lemma
(requires (loc_includes s1 (loc_buffer b) \/ loc_includes s2 (loc_buffer b)))
(ensures (loc_includes (loc_union s1 s2) (loc_buffer b)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_buffer b))]
let loc_includes_union_l_buffer #t s1 s2 b = | false | null | true | M.loc_includes_union_l s1 s2 (loc_buffer b) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.loc",
"Vale.PPC64LE.Memory.buffer",
"LowStar.Monotonic.Buffer.loc_includes_union_l",
"Vale.PPC64LE.Memory.loc_buffer",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2 | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_union_l_buffer (#t:base_typ) (s1 s2:loc) (b:buffer t) : Lemma
(requires (loc_includes s1 (loc_buffer b) \/ loc_includes s2 (loc_buffer b)))
(ensures (loc_includes (loc_union s1 s2) (loc_buffer b)))
[SMTPat (loc_includes (loc_union s1 s2) (loc_buffer b))] | [] | Vale.PPC64LE.Memory.loc_includes_union_l_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> b: Vale.PPC64LE.Memory.buffer t
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.loc_includes s1 (Vale.PPC64LE.Memory.loc_buffer b) \/
Vale.PPC64LE.Memory.loc_includes s2 (Vale.PPC64LE.Memory.loc_buffer b))
(ensures
Vale.PPC64LE.Memory.loc_includes (Vale.PPC64LE.Memory.loc_union s1 s2)
(Vale.PPC64LE.Memory.loc_buffer b))
[
SMTPat (Vale.PPC64LE.Memory.loc_includes (Vale.PPC64LE.Memory.loc_union s1 s2)
(Vale.PPC64LE.Memory.loc_buffer b))
] | {
"end_col": 88,
"end_line": 239,
"start_col": 45,
"start_line": 239
} |
FStar.Pervasives.Lemma | val loc_disjoint_none_r (s:loc) : Lemma
(ensures (loc_disjoint s loc_none))
[SMTPat (loc_disjoint s loc_none)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_disjoint_none_r s = M.loc_disjoint_none_r s | val loc_disjoint_none_r (s:loc) : Lemma
(ensures (loc_disjoint s loc_none))
[SMTPat (loc_disjoint s loc_none)]
let loc_disjoint_none_r s = | false | null | true | M.loc_disjoint_none_r s | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_disjoint_none_r",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = () | false | false | Vale.PPC64LE.Memory.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": 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 loc_disjoint_none_r (s:loc) : Lemma
(ensures (loc_disjoint s loc_none))
[SMTPat (loc_disjoint s loc_none)] | [] | Vale.PPC64LE.Memory.loc_disjoint_none_r | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(ensures Vale.PPC64LE.Memory.loc_disjoint s Vale.PPC64LE.Memory.loc_none)
[SMTPat (Vale.PPC64LE.Memory.loc_disjoint s Vale.PPC64LE.Memory.loc_none)] | {
"end_col": 51,
"end_line": 233,
"start_col": 28,
"start_line": 233
} |
FStar.Pervasives.Lemma | val loc_includes_trans (s1 s2 s3:loc) : Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3 | val loc_includes_trans (s1 s2 s3:loc) : Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3))
let loc_includes_trans s1 s2 s3 = | false | null | true | M.loc_includes_trans s1 s2 s3 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_includes_trans",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2 | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_trans (s1 s2 s3:loc) : Lemma
(requires (loc_includes s1 s2 /\ loc_includes s2 s3))
(ensures (loc_includes s1 s3)) | [] | Vale.PPC64LE.Memory.loc_includes_trans | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> s3: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.loc_includes s1 s2 /\ Vale.PPC64LE.Memory.loc_includes s2 s3)
(ensures Vale.PPC64LE.Memory.loc_includes s1 s3) | {
"end_col": 63,
"end_line": 236,
"start_col": 34,
"start_line": 236
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h | let find_writeable_buffer (t: base_typ) (addr: int) (h: vale_heap) = | false | null | false | find_writeable_buffer_aux t addr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.find_writeable_buffer_aux",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.buffer"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_writeable_buffer : t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | [] | Vale.PPC64LE.Memory.find_writeable_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | {
"end_col": 49,
"end_line": 425,
"start_col": 2,
"start_line": 425
} |
|
FStar.Pervasives.Lemma | val find_valid_buffer_ps (t: base_typ) (addr: int) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2 | val find_valid_buffer_ps (t: base_typ) (addr: int) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
let find_valid_buffer_ps (t: base_typ) (addr: int) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2) = | false | null | true | find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.find_valid_buffer_aux_ps",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.unit",
"Prims.eq2",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Prims.squash",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.find_valid_buffer",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_valid_buffer_ps (t: base_typ) (addr: int) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2) | [] | Vale.PPC64LE.Memory.find_valid_buffer_ps | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h1) ==
InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h2))
(ensures
Vale.PPC64LE.Memory.find_valid_buffer t addr h1 ==
Vale.PPC64LE.Memory.find_valid_buffer t addr h2) | {
"end_col": 53,
"end_line": 387,
"start_col": 2,
"start_line": 387
} |
Prims.GTot | val modifies_goal_directed (s:loc) (h1 h2:vale_heap) : GTot prop0 | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_goal_directed s h1 h2 = modifies s h1 h2 | val modifies_goal_directed (s:loc) (h1 h2:vale_heap) : GTot prop0
let modifies_goal_directed s h1 h2 = | false | null | false | modifies s h1 h2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.modifies",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap | false | false | Vale.PPC64LE.Memory.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": 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 modifies_goal_directed (s:loc) (h1 h2:vale_heap) : GTot prop0 | [] | Vale.PPC64LE.Memory.modifies_goal_directed | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> h1: Vale.Arch.HeapImpl.vale_heap -> h2: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 53,
"end_line": 198,
"start_col": 37,
"start_line": 198
} |
FStar.Pervasives.Lemma | val modifies_goal_directed_refl (s:loc) (h:vale_heap) : Lemma
(modifies_goal_directed s h h)
[SMTPat (modifies_goal_directed s h h)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs | val modifies_goal_directed_refl (s:loc) (h:vale_heap) : Lemma
(modifies_goal_directed s h h)
[SMTPat (modifies_goal_directed s h h)]
let modifies_goal_directed_refl s h = | false | null | true | M.modifies_refl s (_ih h).hs | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"LowStar.Monotonic.Buffer.modifies_refl",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s | false | false | Vale.PPC64LE.Memory.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": 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 modifies_goal_directed_refl (s:loc) (h:vale_heap) : Lemma
(modifies_goal_directed s h h)
[SMTPat (modifies_goal_directed s h h)] | [] | Vale.PPC64LE.Memory.modifies_goal_directed_refl | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> h: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Memory.modifies_goal_directed s h h)
[SMTPat (Vale.PPC64LE.Memory.modifies_goal_directed s h h)] | {
"end_col": 66,
"end_line": 242,
"start_col": 38,
"start_line": 242
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h | let valid_mem (t: base_typ) addr (h: vale_heap) = | false | null | false | valid_mem_aux t addr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.valid_mem_aux",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_mem : t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | [] | Vale.PPC64LE.Memory.valid_mem | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | {
"end_col": 83,
"end_line": 359,
"start_col": 48,
"start_line": 359
} |
|
Prims.Tot | val default_of_typ (t: base_typ) : base_typ_as_vale_type t | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0 | val default_of_typ (t: base_typ) : base_typ_as_vale_type t
let default_of_typ (t: base_typ) : base_typ_as_vale_type t = | false | null | false | allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Prims.unit",
"FStar.Pervasives.allow_inversion"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3 | false | false | Vale.PPC64LE.Memory.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": 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 default_of_typ (t: base_typ) : base_typ_as_vale_type t | [] | Vale.PPC64LE.Memory.default_of_typ | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> Vale.PPC64LE.Memory.base_typ_as_vale_type t | {
"end_col": 54,
"end_line": 260,
"start_col": 2,
"start_line": 254
} |
Prims.Tot | val heaps_match (bs:Seq.seq buffer_info) (mt:memtaint) (h1 h2:vale_heap) (id:heaplet_id) : prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let heaps_match bs mt h1 h2 id =
forall (i:nat).{:pattern Seq.index bs i} i < Seq.length bs ==> (
let Mkbuffer_info t b hid tn _ = Seq.index bs i in
hid == id ==>
buffer_as_seq h1 b == buffer_as_seq h2 b /\
buffer_addr b h1 == buffer_addr b h2 /\
buffer_readable h1 b == buffer_readable h2 b /\
(t == TUInt64 ==> (valid_taint_buf64 b h1 mt tn <==> valid_taint_buf64 b h2 mt tn)) /\
(t == TUInt128 ==> (valid_taint_buf128 b h1 mt tn <==> valid_taint_buf128 b h2 mt tn)) /\
(forall (i:int).{:pattern (buffer_read b i h1) \/ (buffer_read b i h2)}
buffer_read b i h1 == buffer_read b i h2)) | val heaps_match (bs:Seq.seq buffer_info) (mt:memtaint) (h1 h2:vale_heap) (id:heaplet_id) : prop0
let heaps_match bs mt h1 h2 id = | false | null | false | forall (i: nat). {:pattern Seq.index bs i}
i < Seq.length bs ==>
(let Mkbuffer_info t b hid tn _ = Seq.index bs i in
hid == id ==>
buffer_as_seq h1 b == buffer_as_seq h2 b /\ buffer_addr b h1 == buffer_addr b h2 /\
buffer_readable h1 b == buffer_readable h2 b /\
(t == TUInt64 ==> (valid_taint_buf64 b h1 mt tn <==> valid_taint_buf64 b h2 mt tn)) /\
(t == TUInt128 ==> (valid_taint_buf128 b h1 mt tn <==> valid_taint_buf128 b h2 mt tn)) /\
(forall (i: int). {:pattern (buffer_read b i h1)\/(buffer_read b i h2)}
buffer_read b i h1 == buffer_read b i h2)) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.PPC64LE.Memory.memtaint",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.buffer",
"Vale.Arch.HeapTypes_s.taint",
"Vale.Arch.HeapImpl.mutability",
"Prims.eq2",
"Prims.l_and",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.buffer_as_seq",
"Prims.int",
"Vale.PPC64LE.Memory.buffer_addr",
"Vale.Def.Prop_s.prop0",
"Vale.PPC64LE.Memory.buffer_readable",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.l_iff",
"Vale.PPC64LE.Memory.valid_taint_buf64",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.PPC64LE.Memory.valid_taint_buf128",
"Vale.PPC64LE.Memory.buffer_read",
"Prims.logical",
"FStar.Seq.Base.index"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized
let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
)
let layout_heaplets_initialized layout = layout.vl_heaplets_initialized
let layout_old_heap layout = layout.vl_old_heap
let layout_modifies_loc layout = layout.vl_mod_loc
let layout_buffers layout = layout.vl_buffers | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val heaps_match (bs:Seq.seq buffer_info) (mt:memtaint) (h1 h2:vale_heap) (id:heaplet_id) : prop0 | [] | Vale.PPC64LE.Memory.heaps_match | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
bs: FStar.Seq.Base.seq Vale.Arch.HeapImpl.buffer_info ->
mt: Vale.PPC64LE.Memory.memtaint ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap ->
id: Vale.Arch.HeapImpl.heaplet_id
-> Vale.Def.Prop_s.prop0 | {
"end_col": 48,
"end_line": 768,
"start_col": 2,
"start_line": 759
} |
Prims.GTot | val buffer_as_seq (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot (Seq.seq (base_typ_as_vale_type t)) | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | val buffer_as_seq (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot (Seq.seq (base_typ_as_vale_type t))
let buffer_as_seq #t h b = | false | null | false | let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.buffer",
"Vale.Lib.Seqs_s.seq_map",
"Vale.Interop.Types.base_typ_as_type",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.v_to_typ",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Up.length",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.PPC64LE.Memory.uint_view",
"LowStar.BufferView.Up.as_seq",
"Vale.Interop.Heap_s.hs_of_mem",
"Vale.Arch.HeapImpl._ih",
"FStar.Seq.Base.seq"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | false | false | Vale.PPC64LE.Memory.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 buffer_as_seq (#t:base_typ) (h:vale_heap) (b:buffer t) : GTot (Seq.seq (base_typ_as_vale_type t)) | [] | Vale.PPC64LE.Memory.buffer_as_seq | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: Vale.Arch.HeapImpl.vale_heap -> b: Vale.PPC64LE.Memory.buffer t
-> Prims.GTot (FStar.Seq.Base.seq (Vale.PPC64LE.Memory.base_typ_as_vale_type t)) | {
"end_col": 40,
"end_line": 74,
"start_col": 26,
"start_line": 72
} |
Prims.Tot | val v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v | val v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t
let v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t = | false | null | false | match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Interop.Types.base_typ_as_type",
"FStar.UInt8.v",
"FStar.UInt16.v",
"FStar.UInt32.v",
"FStar.UInt64.v",
"Vale.PPC64LE.Memory.base_typ_as_vale_type"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | false | false | Vale.PPC64LE.Memory.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 v_to_typ (t: base_typ) (v: base_typ_as_type t) : base_typ_as_vale_type t | [] | Vale.PPC64LE.Memory.v_to_typ | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> v: Vale.Interop.Types.base_typ_as_type t
-> Vale.PPC64LE.Memory.base_typ_as_vale_type t | {
"end_col": 17,
"end_line": 50,
"start_col": 2,
"start_line": 45
} |
Prims.Tot | val v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | val v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t
let v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t = | false | null | false | match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"FStar.UInt8.uint_to_t",
"FStar.UInt16.uint_to_t",
"FStar.UInt32.uint_to_t",
"FStar.UInt64.uint_to_t",
"Vale.Interop.Types.base_typ_as_type"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t | false | false | Vale.PPC64LE.Memory.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 v_of_typ (t: base_typ) (v: base_typ_as_vale_type t) : base_typ_as_type t | [] | Vale.PPC64LE.Memory.v_of_typ | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> v: Vale.PPC64LE.Memory.base_typ_as_vale_type t
-> Vale.Interop.Types.base_typ_as_type t | {
"end_col": 17,
"end_line": 42,
"start_col": 2,
"start_line": 37
} |
Prims.Ghost | val find_writeable_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
(match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h | val find_writeable_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
(match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps))
let rec find_writeable_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
(match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps)) = | false | null | false | match ps with
| [] -> None
| a :: q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"FStar.Pervasives.Native.None",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.writeable_buffer",
"FStar.Pervasives.Native.Some",
"Prims.bool",
"Vale.PPC64LE.Memory.find_writeable_buffer_aux",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.sub_list",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.b2t",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.writeable_mem_aux",
"Prims.l_and",
"FStar.List.Tot.Base.memP"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
)) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_writeable_buffer_aux (t: base_typ) (addr: int) (ps: list b8) (h: vale_heap)
: Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures
fun o ->
(match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps)) | [
"recursion"
] | Vale.PPC64LE.Memory.find_writeable_buffer_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | {
"end_col": 96,
"end_line": 422,
"start_col": 2,
"start_line": 420
} |
Prims.Tot | val uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | val uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t})
let uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) = | false | null | false | match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.uint8_view",
"Vale.PPC64LE.Memory.uint16_view",
"Vale.PPC64LE.Memory.uint32_view",
"Vale.PPC64LE.Memory.uint64_view",
"Vale.PPC64LE.Memory.uint128_view",
"LowStar.BufferView.Up.view",
"FStar.UInt8.t",
"Vale.Interop.Types.base_typ_as_type",
"Prims.eq2",
"Prims.pos",
"LowStar.BufferView.Up.__proj__View__item__n",
"Vale.Interop.Types.view_n"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128 | false | false | Vale.PPC64LE.Memory.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 uint_view (t: base_typ)
: (v: UV.view UInt8.t (IB.base_typ_as_type t) {UV.View?.n v == view_n t}) | [] | Vale.PPC64LE.Memory.uint_view | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ
-> v:
LowStar.BufferView.Up.view FStar.UInt8.t (Vale.Interop.Types.base_typ_as_type t)
{View?.n v == Vale.Interop.Types.view_n t} | {
"end_col": 28,
"end_line": 70,
"start_col": 2,
"start_line": 65
} |
FStar.Pervasives.Lemma | val index64_heap_aux (s: Seq.lseq UInt8.t 8) (heap: S.machine_heap) (ptr: int)
: Lemma (requires forall (j: nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ ptr + j ])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal () | val index64_heap_aux (s: Seq.lseq UInt8.t 8) (heap: S.machine_heap) (ptr: int)
: Lemma (requires forall (j: nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ ptr + j ])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap)
let index64_heap_aux (s: Seq.lseq UInt8.t 8) (heap: S.machine_heap) (ptr: int)
: Lemma (requires forall (j: nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ ptr + j ])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) = | false | null | true | let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal () | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"Vale.Arch.MachineHeap_s.machine_heap",
"Prims.int",
"Vale.Def.Types_s.le_bytes_to_nat64_reveal",
"Prims.unit",
"Vale.Arch.MachineHeap_s.get_heap_val64_reveal",
"Vale.Interop.Views.get64_reveal",
"FStar.Pervasives.reveal_opaque",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.nat8",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.four",
"Prims.op_Division",
"Vale.Def.Words.Seq_s.seq_to_seq_four_LE",
"Prims.l_Forall",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Vale.Def.Words_s.pow2_8",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Memory.op_String_Access",
"Vale.Def.Types_s.nat8",
"Prims.op_Addition",
"Prims.squash",
"FStar.UInt64.n",
"Vale.Def.Words_s.pow2_64",
"FStar.UInt64.v",
"Vale.Interop.Views.get64",
"Vale.Arch.MachineHeap_s.get_heap_val64",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j]) | false | false | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val index64_heap_aux (s: Seq.lseq UInt8.t 8) (heap: S.machine_heap) (ptr: int)
: Lemma (requires forall (j: nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ ptr + j ])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) | [] | Vale.PPC64LE.Memory.index64_heap_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: FStar.Seq.Properties.lseq FStar.UInt8.t 8 ->
heap: Vale.Arch.MachineHeap_s.machine_heap ->
ptr: Prims.int
-> FStar.Pervasives.Lemma
(requires
forall (j: Prims.nat{j < 8}). FStar.UInt8.v (FStar.Seq.Base.index s j) == heap.[ ptr + j ])
(ensures
FStar.UInt64.v (Vale.Interop.Views.get64 s) ==
Vale.Arch.MachineHeap_s.get_heap_val64 ptr heap) | {
"end_col": 46,
"end_line": 105,
"start_col": 2,
"start_line": 101
} |
Prims.GTot | val modifies (s:loc) (h1 h2:vale_heap) : GTot prop0 | [
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs | val modifies (s:loc) (h1 h2:vale_heap) : GTot prop0
let modifies s h h' = | false | null | false | M.modifies s (_ih h).hs (_ih h').hs /\ h.heapletId == h'.heapletId /\ (_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\ HST.equal_domains (_ih h).hs (_ih h').hs | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Interop.Types.addr_map",
"Vale.Interop.Heap_s.mk_addr_map",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"FStar.HyperStack.ST.equal_domains",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes | false | false | Vale.PPC64LE.Memory.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 modifies (s:loc) (h1 h2:vale_heap) : GTot prop0 | [] | Vale.PPC64LE.Memory.modifies | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> h1: Vale.Arch.HeapImpl.vale_heap -> h2: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 42,
"end_line": 90,
"start_col": 2,
"start_line": 86
} |
FStar.Pervasives.Lemma | val lemma_store_mem128 (b:buffer128) (i:nat) (v:quad32) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem128 (buffer_addr b h + scale16 i) v h == buffer_write b i v h
) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h | val lemma_store_mem128 (b:buffer128) (i:nat) (v:quad32) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem128 (buffer_addr b h + scale16 i) v h == buffer_write b i v h
)
let lemma_store_mem128 b i v h = | false | null | true | lemma_store_mem TUInt128 b i v h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.buffer128",
"Prims.nat",
"Vale.Def.Types_s.quad32",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.lemma_store_mem",
"Vale.Arch.HeapTypes_s.TUInt128",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_store_mem128 (b:buffer128) (i:nat) (v:quad32) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem128 (buffer_addr b h + scale16 i) v h == buffer_write b i v h
) | [] | Vale.PPC64LE.Memory.lemma_store_mem128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer128 ->
i: Prims.nat ->
v: Vale.Def.Types_s.quad32 ->
h: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
i < FStar.Seq.Base.length (Vale.PPC64LE.Memory.buffer_as_seq h b) /\
Vale.PPC64LE.Memory.buffer_readable h b /\ Vale.PPC64LE.Memory.buffer_writeable b)
(ensures
Vale.PPC64LE.Memory.store_mem128 (Vale.PPC64LE.Memory.buffer_addr b h +
Vale.PPC64LE.Memory.scale16 i)
v
h ==
Vale.PPC64LE.Memory.buffer_write b i v h) | {
"end_col": 65,
"end_line": 558,
"start_col": 33,
"start_line": 558
} |
FStar.Pervasives.Lemma | val index128_get_heap_val128_aux (s: Seq.lseq UInt8.t 16) (ptr: int) (heap: S.machine_heap)
: Lemma (requires (forall (j: nat). j < 16 ==> UInt8.v (Seq.index s j) == heap.[ ptr + j ]))
(ensures
Vale.Interop.Views.get128 s ==
Mkfour (S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr + 4) heap)
(S.get_heap_val32 (ptr + 8) heap)
(S.get_heap_val32 (ptr + 12) heap)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal () | val index128_get_heap_val128_aux (s: Seq.lseq UInt8.t 16) (ptr: int) (heap: S.machine_heap)
: Lemma (requires (forall (j: nat). j < 16 ==> UInt8.v (Seq.index s j) == heap.[ ptr + j ]))
(ensures
Vale.Interop.Views.get128 s ==
Mkfour (S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr + 4) heap)
(S.get_heap_val32 (ptr + 8) heap)
(S.get_heap_val32 (ptr + 12) heap))
let index128_get_heap_val128_aux (s: Seq.lseq UInt8.t 16) (ptr: int) (heap: S.machine_heap)
: Lemma (requires (forall (j: nat). j < 16 ==> UInt8.v (Seq.index s j) == heap.[ ptr + j ]))
(ensures
Vale.Interop.Views.get128 s ==
Mkfour (S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr + 4) heap)
(S.get_heap_val32 (ptr + 8) heap)
(S.get_heap_val32 (ptr + 12) heap)) = | false | null | true | reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal () | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"FStar.Seq.Properties.lseq",
"FStar.UInt8.t",
"Prims.int",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Def.Types_s.le_bytes_to_quad32_reveal",
"Prims.unit",
"Vale.Interop.Views.get128_reveal",
"Vale.Arch.MachineHeap_s.get_heap_val32_reveal",
"FStar.Pervasives.reveal_opaque",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Prims.eq2",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.four",
"Prims.op_Division",
"Vale.Def.Words.Seq_s.seq_to_seq_four_LE",
"Prims.l_Forall",
"Prims.nat",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt8.n",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Vale.Def.Words_s.pow2_8",
"FStar.UInt8.v",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Memory.op_String_Access",
"Prims.op_Addition",
"Prims.squash",
"Vale.Def.Types_s.nat32",
"Vale.Interop.Views.get128",
"Vale.Def.Words_s.Mkfour",
"Vale.Arch.MachineHeap_s.get_heap_val32",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap) | false | false | Vale.PPC64LE.Memory.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": 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 index128_get_heap_val128_aux (s: Seq.lseq UInt8.t 16) (ptr: int) (heap: S.machine_heap)
: Lemma (requires (forall (j: nat). j < 16 ==> UInt8.v (Seq.index s j) == heap.[ ptr + j ]))
(ensures
Vale.Interop.Views.get128 s ==
Mkfour (S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr + 4) heap)
(S.get_heap_val32 (ptr + 8) heap)
(S.get_heap_val32 (ptr + 12) heap)) | [] | Vale.PPC64LE.Memory.index128_get_heap_val128_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s: FStar.Seq.Properties.lseq FStar.UInt8.t 16 ->
ptr: Prims.int ->
heap: Vale.Arch.MachineHeap_s.machine_heap
-> FStar.Pervasives.Lemma
(requires
forall (j: Prims.nat).
j < 16 ==> FStar.UInt8.v (FStar.Seq.Base.index s j) == heap.[ ptr + j ])
(ensures
Vale.Interop.Views.get128 s ==
Vale.Def.Words_s.Mkfour (Vale.Arch.MachineHeap_s.get_heap_val32 ptr heap)
(Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 4) heap)
(Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 8) heap)
(Vale.Arch.MachineHeap_s.get_heap_val32 (ptr + 12) heap)) | {
"end_col": 47,
"end_line": 163,
"start_col": 2,
"start_line": 160
} |
Prims.GTot | val load_mem64 (ptr:int) (h:vale_heap) : GTot nat64 | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h | val load_mem64 (ptr:int) (h:vale_heap) : GTot nat64
let load_mem64 ptr h = | false | null | false | if not (valid_mem64 ptr h) then 0 else load_mem (TUInt64) ptr h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.valid_mem64",
"Prims.bool",
"Vale.PPC64LE.Memory.load_mem",
"Vale.Arch.HeapTypes_s.TUInt64",
"Vale.Def.Types_s.nat64"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_mem64 (ptr:int) (h:vale_heap) : GTot nat64 | [] | Vale.PPC64LE.Memory.load_mem64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Vale.Def.Types_s.nat64 | {
"end_col": 31,
"end_line": 436,
"start_col": 2,
"start_line": 435
} |
FStar.Pervasives.Lemma | val write_taint_lemma
(i: nat)
(mem: IB.interop_heap)
(ts: (b8 -> GTot taint))
(b: b8)
(accu: memtaint)
: Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j: int). {:pattern accu.[ j ]}
mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[ j ] = ts b))
(ensures
(let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j. {:pattern m.[ j ]}
addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==> m.[ j ] = ts b) /\
(forall j. {:pattern m.[ j ]}
j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==> m.[ j ] == accu.[ j ])))
(decreases %[DV.length (get_downview b.bsrc) - i]) | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu | val write_taint_lemma
(i: nat)
(mem: IB.interop_heap)
(ts: (b8 -> GTot taint))
(b: b8)
(accu: memtaint)
: Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j: int). {:pattern accu.[ j ]}
mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[ j ] = ts b))
(ensures
(let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j. {:pattern m.[ j ]}
addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==> m.[ j ] = ts b) /\
(forall j. {:pattern m.[ j ]}
j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==> m.[ j ] == accu.[ j ])))
(decreases %[DV.length (get_downview b.bsrc) - i])
let rec write_taint_lemma
(i: nat)
(mem: IB.interop_heap)
(ts: (b8 -> GTot taint))
(b: b8)
(accu: memtaint)
: Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j: int). {:pattern accu.[ j ]}
mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[ j ] = ts b))
(ensures
(let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j. {:pattern m.[ j ]}
addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==> m.[ j ] = ts b) /\
(forall j. {:pattern m.[ j ]}
j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==> m.[ j ] == accu.[ j ])))
(decreases %[DV.length (get_downview b.bsrc) - i]) = | false | null | true | let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc)
then ()
else
let new_accu = accu.[ addr + i ] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j. {:pattern m.[ j ]} addr <= j /\ j < addr + i + 1 ==> new_accu.[ j ] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma",
""
] | [
"Prims.nat",
"Vale.Interop.Heap_s.interop_heap",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapTypes_s.taint",
"Vale.PPC64LE.Memory.memtaint",
"Prims.op_GreaterThanOrEqual",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Prims.bool",
"Vale.PPC64LE.Memory.write_taint_lemma",
"Prims.op_Addition",
"Prims.unit",
"Prims._assert",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2",
"Vale.PPC64LE.Memory.op_String_Access",
"FStar.Set.equal",
"FStar.Map.domain",
"FStar.Set.complement",
"FStar.Set.empty",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.Interop.Base.write_taint",
"FStar.Map.t",
"Vale.PPC64LE.Memory.op_String_Assignment",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Prims.op_Equality",
"Prims.squash",
"Prims.l_or",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j]))) | false | false | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val write_taint_lemma
(i: nat)
(mem: IB.interop_heap)
(ts: (b8 -> GTot taint))
(b: b8)
(accu: memtaint)
: Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j: int). {:pattern accu.[ j ]}
mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[ j ] = ts b))
(ensures
(let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j. {:pattern m.[ j ]}
addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==> m.[ j ] = ts b) /\
(forall j. {:pattern m.[ j ]}
j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==> m.[ j ] == accu.[ j ])))
(decreases %[DV.length (get_downview b.bsrc) - i]) | [
"recursion"
] | Vale.PPC64LE.Memory.write_taint_lemma | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
i: Prims.nat ->
mem: Vale.Interop.Heap_s.interop_heap ->
ts: (_: Vale.PPC64LE.Memory.b8 -> Prims.GTot Vale.Arch.HeapTypes_s.taint) ->
b: Vale.PPC64LE.Memory.b8 ->
accu: Vale.PPC64LE.Memory.memtaint
-> FStar.Pervasives.Lemma
(requires
i <= LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) /\
(forall (j: Prims.int). {:pattern accu.[ j ]}
InteropHeap?.addrs mem b <= j /\ j < InteropHeap?.addrs mem b + i ==> accu.[ j ] = ts b)
)
(ensures
(let m = Vale.Interop.Base.write_taint i mem ts b accu in
let addr = InteropHeap?.addrs mem b in
(forall (j: Prims.int). {:pattern m.[ j ]}
addr <= j /\
j <
addr +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==>
m.[ j ] = ts b) /\
(forall (j: Prims.int). {:pattern m.[ j ]}
j < addr \/
j >=
addr +
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==>
m.[ j ] == accu.[ j ])))
(decreases
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) - i) | {
"end_col": 47,
"end_line": 659,
"start_col": 3,
"start_line": 650
} |
FStar.Pervasives.Lemma | val loc_includes_refl (s:loc) : Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_refl s = M.loc_includes_refl s | val loc_includes_refl (s:loc) : Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)]
let loc_includes_refl s = | false | null | true | M.loc_includes_refl s | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_includes_refl",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_refl (s:loc) : Lemma
(loc_includes s s)
[SMTPat (loc_includes s s)] | [] | Vale.PPC64LE.Memory.loc_includes_refl | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Memory.loc_includes s s)
[SMTPat (Vale.PPC64LE.Memory.loc_includes s s)] | {
"end_col": 47,
"end_line": 235,
"start_col": 26,
"start_line": 235
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr | let valid_offset (t: base_typ) (n base: nat) (addr: int) (i: nat) = | false | null | false | exists j. {:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.nat",
"Prims.int",
"Prims.l_Exists",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.eq2",
"Prims.op_Addition",
"Vale.PPC64LE.Memory.scale_t",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0 | false | true | Vale.PPC64LE.Memory.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": 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 valid_offset : t: Vale.Arch.HeapTypes_s.base_typ ->
n: Prims.nat ->
base: Prims.nat ->
addr: Prims.int ->
i: Prims.nat
-> Prims.logical | [] | Vale.PPC64LE.Memory.valid_offset | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
n: Prims.nat ->
base: Prims.nat ->
addr: Prims.int ->
i: Prims.nat
-> Prims.logical | {
"end_col": 81,
"end_line": 330,
"start_col": 2,
"start_line": 330
} |
|
FStar.Pervasives.Lemma | val loc_disjoint_union_r (s s1 s2:loc) : Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
[SMTPat (loc_disjoint s (loc_union s1 s2))] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2 | val loc_disjoint_union_r (s s1 s2:loc) : Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
[SMTPat (loc_disjoint s (loc_union s1 s2))]
let loc_disjoint_union_r s s1 s2 = | false | null | true | M.loc_disjoint_union_r s s1 s2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_disjoint_union_r",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = () | false | false | Vale.PPC64LE.Memory.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": 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 loc_disjoint_union_r (s s1 s2:loc) : Lemma
(requires (loc_disjoint s s1 /\ loc_disjoint s s2))
(ensures (loc_disjoint s (loc_union s1 s2)))
[SMTPat (loc_disjoint s (loc_union s1 s2))] | [] | Vale.PPC64LE.Memory.loc_disjoint_union_r | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.loc_disjoint s s1 /\ Vale.PPC64LE.Memory.loc_disjoint s s2)
(ensures Vale.PPC64LE.Memory.loc_disjoint s (Vale.PPC64LE.Memory.loc_union s1 s2))
[SMTPat (Vale.PPC64LE.Memory.loc_disjoint s (Vale.PPC64LE.Memory.loc_union s1 s2))] | {
"end_col": 65,
"end_line": 234,
"start_col": 35,
"start_line": 234
} |
FStar.Pervasives.Lemma | val loc_includes_union_r (s s1 s2:loc) : Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
[SMTPat (loc_includes s (loc_union s1 s2))] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2 | val loc_includes_union_r (s s1 s2:loc) : Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
[SMTPat (loc_includes s (loc_union s1 s2))]
let loc_includes_union_r s s1 s2 = | false | null | true | M.loc_includes_union_r s s1 s2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_includes_union_r",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_union_r (s s1 s2:loc) : Lemma
(requires (loc_includes s s1 /\ loc_includes s s2))
(ensures (loc_includes s (loc_union s1 s2)))
[SMTPat (loc_includes s (loc_union s1 s2))] | [] | Vale.PPC64LE.Memory.loc_includes_union_r | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.loc_includes s s1 /\ Vale.PPC64LE.Memory.loc_includes s s2)
(ensures Vale.PPC64LE.Memory.loc_includes s (Vale.PPC64LE.Memory.loc_union s1 s2))
[SMTPat (Vale.PPC64LE.Memory.loc_includes s (Vale.PPC64LE.Memory.loc_union s1 s2))] | {
"end_col": 65,
"end_line": 237,
"start_col": 35,
"start_line": 237
} |
FStar.Pervasives.Lemma | val loc_includes_none (s:loc) : Lemma
(loc_includes s loc_none)
[SMTPat (loc_includes s loc_none)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_none s = M.loc_includes_none s | val loc_includes_none (s:loc) : Lemma
(loc_includes s loc_none)
[SMTPat (loc_includes s loc_none)]
let loc_includes_none s = | false | null | true | M.loc_includes_none s | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_includes_none",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_none (s:loc) : Lemma
(loc_includes s loc_none)
[SMTPat (loc_includes s loc_none)] | [] | Vale.PPC64LE.Memory.loc_includes_none | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(ensures Vale.PPC64LE.Memory.loc_includes s Vale.PPC64LE.Memory.loc_none)
[SMTPat (Vale.PPC64LE.Memory.loc_includes s Vale.PPC64LE.Memory.loc_none)] | {
"end_col": 47,
"end_line": 240,
"start_col": 26,
"start_line": 240
} |
FStar.Pervasives.Lemma | val modifies_buffer_elim (#t1:base_typ) (b:buffer t1) (p:loc) (h h':vale_heap) : Lemma
(requires
loc_disjoint (loc_buffer b) p /\
buffer_readable h b /\
modifies p h h'
)
(ensures
buffer_readable h b /\
buffer_readable h' b /\
buffer_as_seq h b == buffer_as_seq h' b
)
[SMTPatOr [
[SMTPat (modifies p h h'); SMTPat (buffer_readable h' b)];
[SMTPat (modifies p h h'); SMTPat (buffer_as_seq h' b)];
]] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b)) | val modifies_buffer_elim (#t1:base_typ) (b:buffer t1) (p:loc) (h h':vale_heap) : Lemma
(requires
loc_disjoint (loc_buffer b) p /\
buffer_readable h b /\
modifies p h h'
)
(ensures
buffer_readable h b /\
buffer_readable h' b /\
buffer_as_seq h b == buffer_as_seq h' b
)
[SMTPatOr [
[SMTPat (modifies p h h'); SMTPat (buffer_readable h' b)];
[SMTPat (modifies p h h'); SMTPat (buffer_as_seq h' b)];
]]
let modifies_buffer_elim #t1 b p h h' = | false | null | true | let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b)) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.buffer_as_seq",
"Prims.unit",
"Vale.PPC64LE.Memory.same_underlying_seq",
"Vale.Lib.BufferViewHelpers.lemma_dv_equal",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"FStar.UInt8.t",
"Vale.Interop.Types.down_view",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0 | false | false | Vale.PPC64LE.Memory.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": 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 modifies_buffer_elim (#t1:base_typ) (b:buffer t1) (p:loc) (h h':vale_heap) : Lemma
(requires
loc_disjoint (loc_buffer b) p /\
buffer_readable h b /\
modifies p h h'
)
(ensures
buffer_readable h b /\
buffer_readable h' b /\
buffer_as_seq h b == buffer_as_seq h' b
)
[SMTPatOr [
[SMTPat (modifies p h h'); SMTPat (buffer_readable h' b)];
[SMTPat (modifies p h h'); SMTPat (buffer_as_seq h' b)];
]] | [] | Vale.PPC64LE.Memory.modifies_buffer_elim | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer t1 ->
p: Vale.PPC64LE.Memory.loc ->
h: Vale.Arch.HeapImpl.vale_heap ->
h': Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.loc_disjoint (Vale.PPC64LE.Memory.loc_buffer b) p /\
Vale.PPC64LE.Memory.buffer_readable h b /\ Vale.PPC64LE.Memory.modifies p h h')
(ensures
Vale.PPC64LE.Memory.buffer_readable h b /\ Vale.PPC64LE.Memory.buffer_readable h' b /\
Vale.PPC64LE.Memory.buffer_as_seq h b == Vale.PPC64LE.Memory.buffer_as_seq h' b)
[
SMTPatOr [
[
SMTPat (Vale.PPC64LE.Memory.modifies p h h');
SMTPat (Vale.PPC64LE.Memory.buffer_readable h' b)
];
[
SMTPat (Vale.PPC64LE.Memory.modifies p h h');
SMTPat (Vale.PPC64LE.Memory.buffer_as_seq h' b)
]
]
] | {
"end_col": 61,
"end_line": 228,
"start_col": 39,
"start_line": 224
} |
FStar.Pervasives.Lemma | val loc_includes_union_l (s1 s2 s:loc) : Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s | val loc_includes_union_l (s1 s2 s:loc) : Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s))
let loc_includes_union_l s1 s2 s = | false | null | true | M.loc_includes_union_l s1 s2 s | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"LowStar.Monotonic.Buffer.loc_includes_union_l",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3 | false | false | Vale.PPC64LE.Memory.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": 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 loc_includes_union_l (s1 s2 s:loc) : Lemma
(requires (loc_includes s1 s \/ loc_includes s2 s))
(ensures (loc_includes (loc_union s1 s2) s)) | [] | Vale.PPC64LE.Memory.loc_includes_union_l | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s1: Vale.PPC64LE.Memory.loc -> s2: Vale.PPC64LE.Memory.loc -> s: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.loc_includes s1 s \/ Vale.PPC64LE.Memory.loc_includes s2 s)
(ensures Vale.PPC64LE.Memory.loc_includes (Vale.PPC64LE.Memory.loc_union s1 s2) s) | {
"end_col": 65,
"end_line": 238,
"start_col": 35,
"start_line": 238
} |
FStar.Pervasives.Lemma | val modifies_goal_directed_trans2 (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies_goal_directed s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies_goal_directed s13 h1 h3)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3 | val modifies_goal_directed_trans2 (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies_goal_directed s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies_goal_directed s13 h1 h3)]
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = | false | null | true | modifies_goal_directed_trans s12 h1 h2 s13 h3 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.modifies_goal_directed_trans",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
() | false | false | Vale.PPC64LE.Memory.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": 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 modifies_goal_directed_trans2 (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies_goal_directed s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies_goal_directed s13 h1 h3)] | [] | Vale.PPC64LE.Memory.modifies_goal_directed_trans2 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s12: Vale.PPC64LE.Memory.loc ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap ->
s13: Vale.PPC64LE.Memory.loc ->
h3: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.modifies s12 h1 h2 /\
Vale.PPC64LE.Memory.modifies_goal_directed s13 h2 h3 /\
Vale.PPC64LE.Memory.loc_includes s13 s12)
(ensures Vale.PPC64LE.Memory.modifies_goal_directed s13 h1 h3)
[
SMTPat (Vale.PPC64LE.Memory.modifies s12 h1 h2);
SMTPat (Vale.PPC64LE.Memory.modifies_goal_directed s13 h1 h3)
] | {
"end_col": 98,
"end_line": 251,
"start_col": 53,
"start_line": 251
} |
FStar.Pervasives.Lemma | val modifies_refl (s:loc) (h:vale_heap) : Lemma
(modifies s h h)
[SMTPat (modifies s h h)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_refl s h = M.modifies_refl s (_ih h).hs | val modifies_refl (s:loc) (h:vale_heap) : Lemma
(modifies s h h)
[SMTPat (modifies s h h)]
let modifies_refl s h = | false | null | true | M.modifies_refl s (_ih h).hs | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"LowStar.Monotonic.Buffer.modifies_refl",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b) | false | false | Vale.PPC64LE.Memory.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": 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 modifies_refl (s:loc) (h:vale_heap) : Lemma
(modifies s h h)
[SMTPat (modifies s h h)] | [] | Vale.PPC64LE.Memory.modifies_refl | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Vale.PPC64LE.Memory.loc -> h: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma (ensures Vale.PPC64LE.Memory.modifies s h h)
[SMTPat (Vale.PPC64LE.Memory.modifies s h h)] | {
"end_col": 52,
"end_line": 241,
"start_col": 24,
"start_line": 241
} |
Prims.GTot | val valid_taint_b8 (b: b8) (h: vale_heap) (mt: memtaint) (tn: taint) : GTot prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn) | val valid_taint_b8 (b: b8) (h: vale_heap) (mt: memtaint) (tn: taint) : GTot prop0
let valid_taint_b8 (b: b8) (h: vale_heap) (mt: memtaint) (tn: taint) : GTot prop0 = | false | null | false | let addr = (_ih h).addrs b in
(forall (i: int). {:pattern (mt.[ i ])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[ i ] == tn) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Vale.Arch.HeapTypes_s.taint",
"Prims.l_Forall",
"Prims.int",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Prims.eq2",
"Vale.PPC64LE.Memory.op_String_Access",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Vale.Arch.HeapImpl._ih",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_taint_b8 (b: b8) (h: vale_heap) (mt: memtaint) (tn: taint) : GTot prop0 | [] | Vale.PPC64LE.Memory.valid_taint_b8 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap ->
mt: Vale.PPC64LE.Memory.memtaint ->
tn: Vale.Arch.HeapTypes_s.taint
-> Prims.GTot Vale.Def.Prop_s.prop0 | {
"end_col": 77,
"end_line": 565,
"start_col": 79,
"start_line": 562
} |
FStar.Pervasives.Lemma | val modifies_loc_includes (s1:loc) (h h':vale_heap) (s2:loc) : Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h')) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2 | val modifies_loc_includes (s1:loc) (h h':vale_heap) (s2:loc) : Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h'))
let modifies_loc_includes s1 h h' s2 = | false | null | true | M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"LowStar.Monotonic.Buffer.modifies_loc_includes",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs | false | false | Vale.PPC64LE.Memory.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": 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 modifies_loc_includes (s1:loc) (h h':vale_heap) (s2:loc) : Lemma
(requires (modifies s2 h h' /\ loc_includes s1 s2))
(ensures (modifies s1 h h')) | [] | Vale.PPC64LE.Memory.modifies_loc_includes | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s1: Vale.PPC64LE.Memory.loc ->
h: Vale.Arch.HeapImpl.vale_heap ->
h': Vale.Arch.HeapImpl.vale_heap ->
s2: Vale.PPC64LE.Memory.loc
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.modifies s2 h h' /\ Vale.PPC64LE.Memory.loc_includes s1 s2)
(ensures Vale.PPC64LE.Memory.modifies s1 h h') | {
"end_col": 91,
"end_line": 243,
"start_col": 39,
"start_line": 243
} |
Prims.GTot | val load_mem128 (ptr:int) (h:vale_heap) : GTot quad32 | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h | val load_mem128 (ptr:int) (h:vale_heap) : GTot quad32
let load_mem128 ptr h = | false | null | false | if not (valid_mem128 ptr h) then (default_of_typ (TUInt128)) else load_mem (TUInt128) ptr h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_Negation",
"Vale.PPC64LE.Memory.valid_mem128",
"Vale.PPC64LE.Memory.default_of_typ",
"Vale.Arch.HeapTypes_s.TUInt128",
"Prims.bool",
"Vale.PPC64LE.Memory.load_mem",
"Vale.Def.Types_s.quad32"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val load_mem128 (ptr:int) (h:vale_heap) : GTot quad32 | [] | Vale.PPC64LE.Memory.load_mem128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Vale.Def.Types_s.quad32 | {
"end_col": 32,
"end_line": 495,
"start_col": 2,
"start_line": 494
} |
Prims.Ghost | val buffer_read (#t:base_typ) (b:buffer t) (i:int) (h:vale_heap) : Ghost (base_typ_as_vale_type t)
(requires True)
(ensures (fun v ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
v == Seq.index (buffer_as_seq h b) i
)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i | val buffer_read (#t:base_typ) (b:buffer t) (i:int) (h:vale_heap) : Ghost (base_typ_as_vale_type t)
(requires True)
(ensures (fun v ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
v == Seq.index (buffer_as_seq h b) i
))
let buffer_read #t b i h = | false | null | false | if i < 0 || i >= buffer_length b then default_of_typ t else Seq.index (buffer_as_seq h b) i | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_BarBar",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Vale.PPC64LE.Memory.buffer_length",
"Vale.PPC64LE.Memory.default_of_typ",
"Prims.bool",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.buffer_as_seq"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0 | false | false | Vale.PPC64LE.Memory.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": 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 buffer_read (#t:base_typ) (b:buffer t) (i:int) (h:vale_heap) : Ghost (base_typ_as_vale_type t)
(requires True)
(ensures (fun v ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
v == Seq.index (buffer_as_seq h b) i
)) | [] | Vale.PPC64LE.Memory.buffer_read | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.PPC64LE.Memory.buffer t -> i: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost (Vale.PPC64LE.Memory.base_typ_as_vale_type t) | {
"end_col": 33,
"end_line": 264,
"start_col": 2,
"start_line": 263
} |
FStar.Pervasives.Lemma | val modifies_trans (s12:loc) (h1 h2:vale_heap) (s23:loc) (h3:vale_heap) : Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs | val modifies_trans (s12:loc) (h1 h2:vale_heap) (s23:loc) (h3:vale_heap) : Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3))
let modifies_trans s12 h1 h2 s23 h3 = | false | null | true | M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"LowStar.Monotonic.Buffer.modifies_trans",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs | false | false | Vale.PPC64LE.Memory.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": 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 modifies_trans (s12:loc) (h1 h2:vale_heap) (s23:loc) (h3:vale_heap) : Lemma
(requires (modifies s12 h1 h2 /\ modifies s23 h2 h3))
(ensures (modifies (loc_union s12 s23) h1 h3)) | [] | Vale.PPC64LE.Memory.modifies_trans | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s12: Vale.PPC64LE.Memory.loc ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap ->
s23: Vale.PPC64LE.Memory.loc ->
h3: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires Vale.PPC64LE.Memory.modifies s12 h1 h2 /\ Vale.PPC64LE.Memory.modifies s23 h2 h3)
(ensures Vale.PPC64LE.Memory.modifies (Vale.PPC64LE.Memory.loc_union s12 s23) h1 h3) | {
"end_col": 98,
"end_line": 244,
"start_col": 38,
"start_line": 244
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h | let writeable_mem (t: base_typ) addr (h: vale_heap) = | false | null | false | writeable_mem_aux t addr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.writeable_mem_aux",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val writeable_mem : t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | [] | Vale.PPC64LE.Memory.writeable_mem | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | {
"end_col": 91,
"end_line": 409,
"start_col": 52,
"start_line": 409
} |
|
Prims.Ghost | val valid_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t). {:pattern (List.memP x ps)\/(valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h | val valid_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t). {:pattern (List.memP x ps)\/(valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
let rec valid_mem_aux (t: base_typ) addr (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t). {:pattern (List.memP x ps)\/(valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h)) = | false | null | false | match ps with
| [] -> false
| a :: q -> valid_buffer t addr a h || valid_mem_aux t addr q h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_BarBar",
"Vale.PPC64LE.Memory.valid_buffer",
"Vale.PPC64LE.Memory.valid_mem_aux",
"Prims.bool",
"Vale.PPC64LE.Memory.sub_list",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.l_iff",
"Prims.b2t",
"Prims.l_Exists",
"Vale.PPC64LE.Memory.buffer",
"Prims.l_and",
"FStar.List.Tot.Base.memP"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h)) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t). {:pattern (List.memP x ps)\/(valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h)) | [
"recursion"
] | Vale.PPC64LE.Memory.valid_mem_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost Prims.bool | {
"end_col": 63,
"end_line": 358,
"start_col": 2,
"start_line": 356
} |
FStar.Pervasives.Lemma | val same_memTaint64
(b:buffer64)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1) | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1 | val same_memTaint64
(b:buffer64)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 = | false | null | true | same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.buffer64",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Vale.PPC64LE.Memory.same_memTaint",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_memTaint64
(b:buffer64)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1) | [] | Vale.PPC64LE.Memory.same_memTaint64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer64 ->
mem0: Vale.Arch.HeapImpl.vale_heap ->
mem1: Vale.Arch.HeapImpl.vale_heap ->
memtaint0: Vale.PPC64LE.Memory.memtaint ->
memtaint1: Vale.PPC64LE.Memory.memtaint
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.modifies (Vale.PPC64LE.Memory.loc_buffer b) mem0 mem1 /\
(forall (p: Prims.int). {:pattern FStar.Map.sel memtaint0 p\/FStar.Map.sel memtaint1 p}
FStar.Map.sel memtaint0 p == FStar.Map.sel memtaint1 p))
(ensures memtaint0 == memtaint1) | {
"end_col": 57,
"end_line": 607,
"start_col": 2,
"start_line": 607
} |
FStar.Pervasives.Lemma | val seq_upd (#b: _) (h: HS.mem) (vb: UV.buffer b {UV.live h vb}) (i: nat{i < UV.length vb}) (x: b)
: Lemma (Seq.equal (Seq.upd (UV.as_seq h vb) i x) (UV.as_seq (UV.upd h vb i x) vb)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0 | val seq_upd (#b: _) (h: HS.mem) (vb: UV.buffer b {UV.live h vb}) (i: nat{i < UV.length vb}) (x: b)
: Lemma (Seq.equal (Seq.upd (UV.as_seq h vb) i x) (UV.as_seq (UV.upd h vb i x) vb))
let seq_upd (#b: _) (h: HS.mem) (vb: UV.buffer b {UV.live h vb}) (i: nat{i < UV.length vb}) (x: b)
: Lemma (Seq.equal (Seq.upd (UV.as_seq h vb) i x) (UV.as_seq (UV.upd h vb i x) vb)) = | false | null | true | let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k: nat)
: Lemma
(requires
(k <= Seq.length upd_s /\
(forall (j: nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j: nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s
then ()
else
(UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k + 1))
in
aux 0 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"FStar.Monotonic.HyperStack.mem",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.live",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Up.length",
"Prims.unit",
"Prims.op_Subtraction",
"FStar.Seq.Base.length",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"FStar.Seq.Base.index",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.op_Equality",
"Prims.bool",
"Prims.op_Addition",
"LowStar.BufferView.Up.as_seq_sel",
"LowStar.BufferView.Up.upd",
"LowStar.BufferView.Up.sel_upd",
"FStar.Seq.Base.seq",
"FStar.Seq.Base.upd",
"FStar.Seq.Properties.lseq",
"LowStar.BufferView.Up.as_seq",
"Prims.l_True",
"FStar.Seq.Base.equal"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x) | false | false | Vale.PPC64LE.Memory.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": 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 seq_upd (#b: _) (h: HS.mem) (vb: UV.buffer b {UV.live h vb}) (i: nat{i < UV.length vb}) (x: b)
: Lemma (Seq.equal (Seq.upd (UV.as_seq h vb) i x) (UV.as_seq (UV.upd h vb i x) vb)) | [] | Vale.PPC64LE.Memory.seq_upd | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h: FStar.Monotonic.HyperStack.mem ->
vb: LowStar.BufferView.Up.buffer b {LowStar.BufferView.Up.live h vb} ->
i: Prims.nat{i < LowStar.BufferView.Up.length vb} ->
x: b
-> FStar.Pervasives.Lemma
(ensures
FStar.Seq.Base.equal (FStar.Seq.Base.upd (LowStar.BufferView.Up.as_seq h vb) i x)
(LowStar.BufferView.Up.as_seq (LowStar.BufferView.Up.upd h vb i x) vb)) | {
"end_col": 10,
"end_line": 291,
"start_col": 3,
"start_line": 276
} |
FStar.Pervasives.Lemma | val same_memTaint128
(b:buffer128)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1) | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1 | val same_memTaint128
(b:buffer128)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1)
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 = | false | null | true | same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.buffer128",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Vale.PPC64LE.Memory.same_memTaint",
"Vale.Arch.HeapTypes_s.TUInt128",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1 | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_memTaint128
(b:buffer128)
(mem0:vale_heap)
(mem1:vale_heap)
(memtaint0:memtaint)
(memtaint1:memtaint)
: Lemma
(requires (modifies (loc_buffer b) mem0 mem1 /\
(forall p.{:pattern Map.sel memtaint0 p \/ Map.sel memtaint1 p} Map.sel memtaint0 p == Map.sel memtaint1 p)))
(ensures memtaint0 == memtaint1) | [] | Vale.PPC64LE.Memory.same_memTaint128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer128 ->
mem0: Vale.Arch.HeapImpl.vale_heap ->
mem1: Vale.Arch.HeapImpl.vale_heap ->
memtaint0: Vale.PPC64LE.Memory.memtaint ->
memtaint1: Vale.PPC64LE.Memory.memtaint
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.modifies (Vale.PPC64LE.Memory.loc_buffer b) mem0 mem1 /\
(forall (p: Prims.int). {:pattern FStar.Map.sel memtaint0 p\/FStar.Map.sel memtaint1 p}
FStar.Map.sel memtaint0 p == FStar.Map.sel memtaint1 p))
(ensures memtaint0 == memtaint1) | {
"end_col": 58,
"end_line": 610,
"start_col": 2,
"start_line": 610
} |
FStar.Pervasives.Lemma | val length_t_eq (t: base_typ) (b: buffer t)
: Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t) | val length_t_eq (t: base_typ) (b: buffer t)
: Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t))
let length_t_eq (t: base_typ) (b: buffer t)
: Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) = | false | null | true | let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"FStar.Math.Lib.lemma_div_def",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.view_n",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Vale.PPC64LE.Memory.buffer_length",
"Prims.op_Division",
"LowStar.BufferView.Up.length_eq",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"Vale.PPC64LE.Memory.uint_view",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Prims.l_True",
"Prims.squash",
"FStar.Mul.op_Star",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length_t_eq (t: base_typ) (b: buffer t)
: Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) | [] | Vale.PPC64LE.Memory.length_t_eq | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> b: Vale.PPC64LE.Memory.buffer t
-> FStar.Pervasives.Lemma
(ensures
LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview (Buffer?.bsrc b)) ==
Vale.PPC64LE.Memory.buffer_length b * Vale.Interop.Types.view_n t) | {
"end_col": 56,
"end_line": 444,
"start_col": 75,
"start_line": 439
} |
FStar.Pervasives.Lemma | val modifies_goal_directed_trans (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies s13 h1 h3)] | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
() | val modifies_goal_directed_trans (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies s13 h1 h3)]
let modifies_goal_directed_trans s12 h1 h2 s13 h3 = | false | null | true | modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
() | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.unit",
"Vale.PPC64LE.Memory.modifies_loc_includes",
"Vale.PPC64LE.Memory.loc_union",
"Vale.PPC64LE.Memory.modifies_trans"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs | false | false | Vale.PPC64LE.Memory.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": 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 modifies_goal_directed_trans (s12:loc) (h1 h2:vale_heap) (s13:loc) (h3:vale_heap) : Lemma
(requires
modifies s12 h1 h2 /\
modifies_goal_directed s13 h2 h3 /\
loc_includes s13 s12
)
(ensures (modifies s13 h1 h3))
[SMTPat (modifies s12 h1 h2); SMTPat (modifies s13 h1 h3)] | [] | Vale.PPC64LE.Memory.modifies_goal_directed_trans | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
s12: Vale.PPC64LE.Memory.loc ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap ->
s13: Vale.PPC64LE.Memory.loc ->
h3: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.modifies s12 h1 h2 /\
Vale.PPC64LE.Memory.modifies_goal_directed s13 h2 h3 /\
Vale.PPC64LE.Memory.loc_includes s13 s12)
(ensures Vale.PPC64LE.Memory.modifies s13 h1 h3)
[
SMTPat (Vale.PPC64LE.Memory.modifies s12 h1 h2);
SMTPat (Vale.PPC64LE.Memory.modifies s13 h1 h3)
] | {
"end_col": 4,
"end_line": 249,
"start_col": 2,
"start_line": 247
} |
FStar.Pervasives.Lemma | val same_underlying_seq (#t: base_typ) (h1 h2: vale_heap) (b: buffer t)
: Lemma
(requires
Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc))
(DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0 | val same_underlying_seq (#t: base_typ) (h1 h2: vale_heap) (b: buffer t)
: Lemma
(requires
Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc))
(DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
let same_underlying_seq (#t: base_typ) (h1 h2: vale_heap) (b: buffer t)
: Lemma
(requires
Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc))
(DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b)) = | false | null | true | let db = get_downview b.bsrc in
let rec aux (i: nat{i <= buffer_length b})
: Lemma
(requires
(forall (j: nat{j < i}).
Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures
(forall (j: nat{j < buffer_length b}).
Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b
then ()
else
(let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i + 1))
in
aux 0 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.buffer",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Vale.PPC64LE.Memory.buffer_length",
"Prims.unit",
"Prims.op_Subtraction",
"Prims.l_and",
"Prims.l_Forall",
"Prims.op_LessThan",
"Prims.eq2",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Memory.buffer_as_seq",
"FStar.Seq.Base.equal",
"FStar.UInt8.t",
"LowStar.BufferView.Down.as_seq",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.op_Equality",
"Prims.bool",
"Prims.op_Addition",
"LowStar.BufferView.Up.as_seq_sel",
"Vale.Interop.Types.base_typ_as_type",
"LowStar.BufferView.Up.get_sel",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"Vale.PPC64LE.Memory.uint_view",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc))) | false | false | Vale.PPC64LE.Memory.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": 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 same_underlying_seq (#t: base_typ) (h1 h2: vale_heap) (b: buffer t)
: Lemma
(requires
Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc))
(DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b)) | [] | Vale.PPC64LE.Memory.same_underlying_seq | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap ->
b: Vale.PPC64LE.Memory.buffer t
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.equal (LowStar.BufferView.Down.as_seq (InteropHeap?.hs (Vale.Arch.HeapImpl._ih
h1))
(Vale.Interop.Types.get_downview (Buffer?.bsrc b)))
(LowStar.BufferView.Down.as_seq (InteropHeap?.hs (Vale.Arch.HeapImpl._ih h2))
(Vale.Interop.Types.get_downview (Buffer?.bsrc b))))
(ensures
FStar.Seq.Base.equal (Vale.PPC64LE.Memory.buffer_as_seq h1 b)
(Vale.PPC64LE.Memory.buffer_as_seq h2 b)) | {
"end_col": 10,
"end_line": 222,
"start_col": 3,
"start_line": 206
} |
Prims.GTot | val valid_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h | val valid_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool
let valid_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool = | false | null | false | DV.length (get_downview b.bsrc) % (view_n t) = 0 && addr_in_ptr #t addr b h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"Prims.op_Modulus",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"Vale.Interop.Types.view_n",
"Vale.PPC64LE.Memory.addr_in_ptr",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1) | false | false | Vale.PPC64LE.Memory.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": 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 valid_buffer (t: base_typ) (addr: int) (b: b8) (h: vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.valid_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
b: Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot Prims.bool | {
"end_col": 25,
"end_line": 342,
"start_col": 2,
"start_line": 341
} |
Prims.Tot | val is_initial_heap (layout:vale_heap_layout) (h:vale_heap) : prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized | val is_initial_heap (layout:vale_heap_layout) (h:vale_heap) : prop0
let is_initial_heap layout h = | false | null | false | h == layout.vl_inner.vl_old_heap /\ not layout.vl_inner.vl_heaplets_initialized | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.l_and",
"Prims.eq2",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_old_heap",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_inner",
"Prims.b2t",
"Prims.op_Negation",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplets_initialized",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_initial_heap (layout:vale_heap_layout) (h:vale_heap) : prop0 | [] | Vale.PPC64LE.Memory.is_initial_heap | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | layout: Vale.Arch.HeapImpl.vale_heap_layout -> h: Vale.Arch.HeapImpl.vale_heap
-> Vale.Def.Prop_s.prop0 | {
"end_col": 45,
"end_line": 740,
"start_col": 2,
"start_line": 739
} |
Prims.GTot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h | let find_valid_buffer (t: base_typ) (addr: int) (h: vale_heap) = | false | null | false | find_valid_buffer_aux t addr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.find_valid_buffer_aux",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.buffer"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_valid_buffer : t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | [] | Vale.PPC64LE.Memory.find_valid_buffer | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> addr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.GTot (FStar.Pervasives.Native.option (Vale.PPC64LE.Memory.buffer t)) | {
"end_col": 105,
"end_line": 373,
"start_col": 62,
"start_line": 373
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b) | let valid_taint_bufs (mem: vale_heap) (memTaint: memtaint) (ps: list b8) (ts: (b8 -> GTot taint)) = | false | null | false | forall b. {:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapTypes_s.taint",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Vale.PPC64LE.Memory.valid_taint_b8",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
() | false | false | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_taint_bufs : mem: Vale.Arch.HeapImpl.vale_heap ->
memTaint: Vale.PPC64LE.Memory.memtaint ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
ts: (_: Vale.PPC64LE.Memory.b8 -> Prims.GTot Vale.Arch.HeapTypes_s.taint)
-> Prims.logical | [] | Vale.PPC64LE.Memory.valid_taint_bufs | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Arch.HeapImpl.vale_heap ->
memTaint: Vale.PPC64LE.Memory.memtaint ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
ts: (_: Vale.PPC64LE.Memory.b8 -> Prims.GTot Vale.Arch.HeapTypes_s.taint)
-> Prims.logical | {
"end_col": 92,
"end_line": 635,
"start_col": 2,
"start_line": 635
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i | let inv_heaplet_ids (hs: vale_heaplets) = | false | null | false | forall (i: heaplet_id). {:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heaplets",
"Prims.l_Forall",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"Vale.Lib.Map16.sel",
"Vale.Arch.HeapImpl.vale_heap",
"FStar.Pervasives.Native.Some",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_heaplet_ids : hs: Vale.Arch.HeapImpl.vale_heaplets -> Prims.logical | [] | Vale.PPC64LE.Memory.inv_heaplet_ids | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | hs: Vale.Arch.HeapImpl.vale_heaplets -> Prims.logical | {
"end_col": 86,
"end_line": 696,
"start_col": 2,
"start_line": 696
} |
|
Prims.Tot | val layout_modifies_loc (layout:vale_heap_layout_inner) : loc | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let layout_modifies_loc layout = layout.vl_mod_loc | val layout_modifies_loc (layout:vale_heap_layout_inner) : loc
let layout_modifies_loc layout = | false | null | false | layout.vl_mod_loc | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_mod_loc",
"Vale.PPC64LE.Memory.loc"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized
let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
)
let layout_heaplets_initialized layout = layout.vl_heaplets_initialized | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val layout_modifies_loc (layout:vale_heap_layout_inner) : loc | [] | Vale.PPC64LE.Memory.layout_modifies_loc | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | layout: Vale.Arch.HeapImpl.vale_heap_layout_inner -> Vale.PPC64LE.Memory.loc | {
"end_col": 50,
"end_line": 755,
"start_col": 33,
"start_line": 755
} |
Prims.Tot | val layout_buffers (layout:vale_heap_layout_inner) : Seq.seq buffer_info | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let layout_buffers layout = layout.vl_buffers | val layout_buffers (layout:vale_heap_layout_inner) : Seq.seq buffer_info
let layout_buffers layout = | false | null | false | layout.vl_buffers | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_buffers",
"FStar.Seq.Base.seq",
"Vale.Arch.HeapImpl.buffer_info"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True
let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True
let is_initial_heap layout h =
h == layout.vl_inner.vl_old_heap /\
not layout.vl_inner.vl_heaplets_initialized
let mem_inv h =
h.vf_heap.heapletId == None /\
inv_heaplet_ids h.vf_heaplets /\
(if h.vf_layout.vl_inner.vl_heaplets_initialized
then
inv_heaplets h.vf_layout.vl_inner h.vf_heap
h.vf_heaplets h.vf_layout.vl_taint
else
h.vf_heaplets == empty_vale_heaplets h.vf_layout.vl_inner.vl_old_heap
)
let layout_heaplets_initialized layout = layout.vl_heaplets_initialized
let layout_old_heap layout = layout.vl_old_heap | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val layout_buffers (layout:vale_heap_layout_inner) : Seq.seq buffer_info | [] | Vale.PPC64LE.Memory.layout_buffers | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | layout: Vale.Arch.HeapImpl.vale_heap_layout_inner
-> FStar.Seq.Base.seq Vale.Arch.HeapImpl.buffer_info | {
"end_col": 45,
"end_line": 756,
"start_col": 28,
"start_line": 756
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True | let inv_buffer_info
(bi: buffer_info)
(owners: (heaplet_id -> Set.set int))
(h: vale_heap)
(hs: vale_heaplets)
(mt: memTaint_t)
(modloc: loc)
= | false | null | false | let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\ buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i: int). {:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns
) /\ True | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.buffer_info",
"Vale.Arch.HeapImpl.heaplet_id",
"FStar.Set.set",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.vale_heaplets",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.PPC64LE.Memory.loc",
"Prims.l_and",
"Prims.l_imp",
"Prims.eq2",
"Vale.Arch.HeapImpl.mutability",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_mutable",
"Vale.Arch.HeapImpl.Mutable",
"Vale.PPC64LE.Memory.loc_includes",
"Vale.PPC64LE.Memory.loc_buffer",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_typ",
"Vale.PPC64LE.Memory.buffer_readable",
"FStar.Seq.Base.seq",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.buffer_as_seq",
"Prims.l_iff",
"Vale.PPC64LE.Memory.valid_taint_buf",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_taint",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Vale.PPC64LE.Memory.buffer_addr",
"Prims.op_LessThan",
"Prims.op_Addition",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"FStar.Set.mem",
"Prims.l_True",
"Vale.Arch.HeapImpl.buffer",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_buffer",
"Vale.Lib.Map16.get",
"Vale.Arch.HeapImpl.__proj__Mkbuffer_info__item__bi_heaplet",
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_buffer_info : bi: Vale.Arch.HeapImpl.buffer_info ->
owners: (_: Vale.Arch.HeapImpl.heaplet_id -> FStar.Set.set Prims.int) ->
h: Vale.Arch.HeapImpl.vale_heap ->
hs: Vale.Arch.HeapImpl.vale_heaplets ->
mt: Vale.Arch.HeapTypes_s.memTaint_t ->
modloc: Vale.PPC64LE.Memory.loc
-> Prims.logical | [] | Vale.PPC64LE.Memory.inv_buffer_info | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
bi: Vale.Arch.HeapImpl.buffer_info ->
owners: (_: Vale.Arch.HeapImpl.heaplet_id -> FStar.Set.set Prims.int) ->
h: Vale.Arch.HeapImpl.vale_heap ->
hs: Vale.Arch.HeapImpl.vale_heaplets ->
mt: Vale.Arch.HeapTypes_s.memTaint_t ->
modloc: Vale.PPC64LE.Memory.loc
-> Prims.logical | {
"end_col": 6,
"end_line": 722,
"start_col": 135,
"start_line": 710
} |
|
Prims.Ghost | val get_addr_ptr (t: base_typ) (ptr: int) (h: vale_heap)
: Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h) | val get_addr_ptr (t: base_typ) (ptr: int) (h: vale_heap)
: Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
let get_addr_ptr (t: base_typ) (ptr: int) (h: vale_heap)
: Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h) = | false | null | false | Some?.v (find_valid_buffer t ptr h) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"FStar.Pervasives.Native.__proj__Some__item__v",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.find_valid_buffer",
"Prims.b2t",
"Vale.PPC64LE.Memory.valid_mem",
"Prims.l_and",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Vale.PPC64LE.Memory.valid_buffer"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_addr_ptr (t: base_typ) (ptr: int) (h: vale_heap)
: Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h) | [] | Vale.PPC64LE.Memory.get_addr_ptr | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Vale.Arch.HeapTypes_s.base_typ -> ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost (Vale.PPC64LE.Memory.buffer t) | {
"end_col": 37,
"end_line": 450,
"start_col": 2,
"start_line": 450
} |
Prims.Ghost | val buffer_write (#t:base_typ) (b:buffer t) (i:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires buffer_readable h b /\ buffer_writeable b)
(ensures (fun h' ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
modifies (loc_buffer b) h h' /\
get_heaplet_id h' == get_heaplet_id h /\
buffer_readable h' b /\
buffer_as_seq h' b == Seq.upd (buffer_as_seq h b) i v
)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end | val buffer_write (#t:base_typ) (b:buffer t) (i:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires buffer_readable h b /\ buffer_writeable b)
(ensures (fun h' ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
modifies (loc_buffer b) h h' /\
get_heaplet_id h' == get_heaplet_id h /\
buffer_readable h' b /\
buffer_as_seq h' b == Seq.upd (buffer_as_seq h b) i v
))
let buffer_write #t b i v h = | false | null | false | if i < 0 || i >= buffer_length b
then h
else
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h' | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Prims.int",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_BarBar",
"Prims.op_LessThan",
"Prims.op_GreaterThanOrEqual",
"Vale.PPC64LE.Memory.buffer_length",
"Prims.bool",
"Prims.unit",
"Prims._assert",
"FStar.Seq.Base.equal",
"Vale.PPC64LE.Memory.buffer_as_seq",
"FStar.Seq.Base.upd",
"Vale.PPC64LE.Memory.seq_upd",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__hs",
"Vale.Arch.HeapImpl._ih",
"Vale.PPC64LE.Memory.v_of_typ",
"Vale.Arch.HeapImpl.ValeHeap",
"FStar.Ghost.hide",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__heapletId",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.Interop.Heap_s.correct_down",
"Vale.Interop.down_mem",
"Vale.Interop.Heap_s.InteropHeap",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"FStar.Monotonic.HyperStack.mem",
"LowStar.BufferView.Up.upd",
"LowStar.BufferView.Up.upd_equal_domains",
"LowStar.BufferView.Up.upd_modifies",
"LowStar.BufferView.Up.buffer",
"LowStar.BufferView.Up.mk_buffer",
"FStar.UInt8.t",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.__proj__Buffer__item__bsrc",
"LowStar.BufferView.Up.view",
"Prims.eq2",
"Prims.pos",
"LowStar.BufferView.Up.__proj__View__item__n",
"Vale.Interop.Types.view_n",
"Vale.PPC64LE.Memory.uint_view"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0 | false | false | Vale.PPC64LE.Memory.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": 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 buffer_write (#t:base_typ) (b:buffer t) (i:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires buffer_readable h b /\ buffer_writeable b)
(ensures (fun h' ->
0 <= i /\ i < buffer_length b /\ buffer_readable h b ==>
modifies (loc_buffer b) h h' /\
get_heaplet_id h' == get_heaplet_id h /\
buffer_readable h' b /\
buffer_as_seq h' b == Seq.upd (buffer_as_seq h b) i v
)) | [] | Vale.PPC64LE.Memory.buffer_write | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer t ->
i: Prims.int ->
v: Vale.PPC64LE.Memory.base_typ_as_vale_type t ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost Vale.Arch.HeapImpl.vale_heap | {
"end_col": 5,
"end_line": 308,
"start_col": 2,
"start_line": 294
} |
Prims.GTot | val writeable_mem128 (ptr:int) (h:vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h | val writeable_mem128 (ptr:int) (h:vale_heap) : GTot bool
let writeable_mem128 ptr h = | false | null | false | writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.writeable_mem_aux",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
() | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val writeable_mem128 (ptr:int) (h:vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.writeable_mem128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.bool | {
"end_col": 76,
"end_line": 492,
"start_col": 29,
"start_line": 492
} |
Prims.Ghost | val writeable_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t).
{:pattern (List.memP x ps)\/(valid_buffer t addr x h)\/buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x)) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h | val writeable_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t).
{:pattern (List.memP x ps)\/(valid_buffer t addr x h)\/buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
let rec writeable_mem_aux (t: base_typ) addr (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t).
{:pattern (List.memP x ps)\/(valid_buffer t addr x h)\/buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x)) = | false | null | false | match ps with
| [] -> false
| a :: q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.op_BarBar",
"Vale.PPC64LE.Memory.writeable_buffer",
"Vale.PPC64LE.Memory.writeable_mem_aux",
"Prims.bool",
"Vale.PPC64LE.Memory.sub_list",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.l_iff",
"Prims.b2t",
"Prims.l_Exists",
"Vale.PPC64LE.Memory.buffer",
"Prims.l_and",
"FStar.List.Tot.Base.memP",
"Vale.PPC64LE.Memory.valid_buffer",
"Vale.PPC64LE.Memory.buffer_writeable"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x)) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val writeable_mem_aux (t: base_typ) (addr: _) (ps: list b8) (h: vale_heap)
: Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures
fun b ->
b <==>
(exists (x: buffer t).
{:pattern (List.memP x ps)\/(valid_buffer t addr x h)\/buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x)) | [
"recursion"
] | Vale.PPC64LE.Memory.writeable_mem_aux | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost Prims.bool | {
"end_col": 71,
"end_line": 408,
"start_col": 2,
"start_line": 406
} |
FStar.Pervasives.Lemma | val lemma_store_mem64 (b:buffer64) (i:nat) (v:nat64) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem64 (buffer_addr b h + scale8 i) v h == buffer_write b i v h
) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h | val lemma_store_mem64 (b:buffer64) (i:nat) (v:nat64) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem64 (buffer_addr b h + scale8 i) v h == buffer_write b i v h
)
let lemma_store_mem64 b i v h = | false | null | true | lemma_store_mem TUInt64 b i v h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.PPC64LE.Memory.buffer64",
"Prims.nat",
"Vale.Def.Types_s.nat64",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.lemma_store_mem",
"Vale.Arch.HeapTypes_s.TUInt64",
"Prims.unit"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_store_mem64 (b:buffer64) (i:nat) (v:nat64) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem64 (buffer_addr b h + scale8 i) v h == buffer_write b i v h
) | [] | Vale.PPC64LE.Memory.lemma_store_mem64 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer64 ->
i: Prims.nat ->
v: Vale.Def.Types_s.nat64 ->
h: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
i < FStar.Seq.Base.length (Vale.PPC64LE.Memory.buffer_as_seq h b) /\
Vale.PPC64LE.Memory.buffer_readable h b /\ Vale.PPC64LE.Memory.buffer_writeable b)
(ensures
Vale.PPC64LE.Memory.store_mem64 (Vale.PPC64LE.Memory.buffer_addr b h +
Vale.PPC64LE.Memory.scale8 i)
v
h ==
Vale.PPC64LE.Memory.buffer_write b i v h) | {
"end_col": 63,
"end_line": 540,
"start_col": 32,
"start_line": 540
} |
Prims.Ghost | val store_mem (t: base_typ) (addr: int) (v: base_typ_as_vale_type t) (h: vale_heap)
: Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h | val store_mem (t: base_typ) (addr: int) (v: base_typ_as_vale_type t) (h: vale_heap)
: Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
let store_mem (t: base_typ) (addr: int) (v: base_typ_as_vale_type t) (h: vale_heap)
: Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs) = | false | null | false | match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.find_writeable_buffer",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.buffer_write",
"Vale.PPC64LE.Memory.get_addr_in_ptr",
"Vale.PPC64LE.Memory.buffer_length",
"Vale.PPC64LE.Memory.buffer_addr",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Vale.Interop.Types.addr_map",
"Prims.l_or",
"Vale.Interop.Heap_s.mk_addr_map",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Prims.list",
"Vale.Interop.Types.b8",
"Vale.Interop.Heap_s.list_disjoint_or_eq"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val store_mem (t: base_typ) (addr: int) (v: base_typ_as_vale_type t) (h: vale_heap)
: Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs) | [] | Vale.PPC64LE.Memory.store_mem | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
v: Vale.PPC64LE.Memory.base_typ_as_vale_type t ->
h: Vale.Arch.HeapImpl.vale_heap
-> Prims.Ghost Vale.Arch.HeapImpl.vale_heap | {
"end_col": 72,
"end_line": 471,
"start_col": 2,
"start_line": 467
} |
FStar.Pervasives.Lemma | val same_memTaint (t: base_typ) (b: buffer t) (mem0 mem1: vale_heap) (memT0 memT1: memtaint)
: Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\ (forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1) | val same_memTaint (t: base_typ) (b: buffer t) (mem0 mem1: vale_heap) (memT0 memT1: memtaint)
: Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\ (forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1)
let same_memTaint (t: base_typ) (b: buffer t) (mem0 mem1: vale_heap) (memT0 memT1: memtaint)
: Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\ (forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) = | false | null | true | assert (Map.equal memT0 memT1) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Prims._assert",
"FStar.Map.equal",
"Prims.int",
"Vale.Arch.HeapTypes_s.taint",
"Prims.unit",
"Prims.l_and",
"Vale.PPC64LE.Memory.modifies",
"Vale.PPC64LE.Memory.loc_buffer",
"Prims.l_Forall",
"Prims.eq2",
"FStar.Map.sel",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p)) | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val same_memTaint (t: base_typ) (b: buffer t) (mem0 mem1: vale_heap) (memT0 memT1: memtaint)
: Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\ (forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) | [] | Vale.PPC64LE.Memory.same_memTaint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
b: Vale.PPC64LE.Memory.buffer t ->
mem0: Vale.Arch.HeapImpl.vale_heap ->
mem1: Vale.Arch.HeapImpl.vale_heap ->
memT0: Vale.PPC64LE.Memory.memtaint ->
memT1: Vale.PPC64LE.Memory.memtaint
-> FStar.Pervasives.Lemma
(requires
Vale.PPC64LE.Memory.modifies (Vale.PPC64LE.Memory.loc_buffer b) mem0 mem1 /\
(forall (p: Prims.int). FStar.Map.sel memT0 p == FStar.Map.sel memT1 p))
(ensures memT0 == memT1) | {
"end_col": 32,
"end_line": 604,
"start_col": 2,
"start_line": 604
} |
Prims.GTot | val valid_mem128 (ptr:int) (h:vale_heap) : GTot bool | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h | val valid_mem128 (ptr:int) (h:vale_heap) : GTot bool
let valid_mem128 ptr h = | false | null | false | valid_mem_aux (TUInt128) ptr (_ih h).ptrs h | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"sometrivial"
] | [
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.valid_mem_aux",
"Vale.Arch.HeapTypes_s.TUInt128",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Prims.bool"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
() | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_mem128 (ptr:int) (h:vale_heap) : GTot bool | [] | Vale.PPC64LE.Memory.valid_mem128 | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | ptr: Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> Prims.GTot Prims.bool | {
"end_col": 68,
"end_line": 491,
"start_col": 25,
"start_line": 491
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True | let inv_heaplet (owns: Set.set int) (h hi: vale_heap) = | false | null | false | h.ih.IB.ptrs == hi.ih.IB.ptrs /\ Map.domain h.mh == Map.domain hi.mh /\
(forall (i: int).
{:pattern Set.mem i owns\/Set.mem i (Map.domain h.mh)\/Map.sel h.mh i\/Map.sel hi.mh i}
Set.mem i owns ==> Set.mem i (Map.domain h.mh) /\ Map.sel h.mh i == Map.sel hi.mh i /\ True) /\
True | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"FStar.Set.set",
"Prims.int",
"Vale.Arch.HeapImpl.vale_heap",
"Prims.l_and",
"Prims.eq2",
"Prims.list",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"FStar.Ghost.reveal",
"Vale.Interop.Heap_s.interop_heap",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__ih",
"FStar.Map.domain",
"Vale.Def.Types_s.nat8",
"Vale.Arch.HeapImpl.__proj__ValeHeap__item__mh",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"FStar.Set.mem",
"FStar.Map.sel",
"Prims.l_True",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_heaplet : owns: FStar.Set.set Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> hi: Vale.Arch.HeapImpl.vale_heap
-> Prims.logical | [] | Vale.PPC64LE.Memory.inv_heaplet | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | owns: FStar.Set.set Prims.int -> h: Vale.Arch.HeapImpl.vale_heap -> hi: Vale.Arch.HeapImpl.vale_heap
-> Prims.logical | {
"end_col": 6,
"end_line": 707,
"start_col": 2,
"start_line": 699
} |
|
Prims.Tot | val valid_layout_buffer_id (t:base_typ) (b:buffer t) (layout:vale_heap_layout) (h_id:option heaplet_id) (write:bool) : prop0 | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write | val valid_layout_buffer_id (t:base_typ) (b:buffer t) (layout:vale_heap_layout) (h_id:option heaplet_id) (write:bool) : prop0
let valid_layout_buffer_id t b layout h_id write = | false | null | false | match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\ valid_layout_data_buffer t b layout.vl_inner hid write | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.Arch.HeapImpl.vale_heap_layout",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.bool",
"Prims.l_True",
"Prims.l_and",
"Prims.b2t",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplets_initialized",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout__item__vl_inner",
"Vale.PPC64LE.Memory.valid_layout_data_buffer",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"] | false | false | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_layout_buffer_id (t:base_typ) (b:buffer t) (layout:vale_heap_layout) (h_id:option heaplet_id) (write:bool) : prop0 | [] | Vale.PPC64LE.Memory.valid_layout_buffer_id | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
b: Vale.PPC64LE.Memory.buffer t ->
layout: Vale.Arch.HeapImpl.vale_heap_layout ->
h_id: FStar.Pervasives.Native.option Vale.Arch.HeapImpl.heaplet_id ->
write: Prims.bool
-> Vale.Def.Prop_s.prop0 | {
"end_col": 58,
"end_line": 693,
"start_col": 2,
"start_line": 689
} |
FStar.Pervasives.Lemma | val valid_memtaint (mem: vale_heap) (ps: list b8) (ts: (b8 -> GTot taint))
: Lemma (requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts) | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b) | val valid_memtaint (mem: vale_heap) (ps: list b8) (ts: (b8 -> GTot taint))
: Lemma (requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
let rec valid_memtaint (mem: vale_heap) (ps: list b8) (ts: (b8 -> GTot taint))
: Lemma (requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts) = | false | null | true | FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq)
list_disjoint_or_eq
list_disjoint_or_eq_def
(IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq)
list_disjoint_or_eq
list_disjoint_or_eq_def
(forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapImpl.vale_heap",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapTypes_s.taint",
"Vale.Def.Opaque_s.opaque_assert",
"Vale.Interop.Types.b8",
"Prims.logical",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.list_disjoint_or_eq_def",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.List.Tot.Base.memP",
"Vale.Interop.Heap_s.disjoint_or_eq_b8",
"Prims.unit",
"Vale.PPC64LE.Memory.write_taint_lemma",
"Vale.Arch.HeapImpl._ih",
"Vale.Interop.Base.create_memtaint",
"Prims._assert",
"Prims.eq2",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Vale.Interop.Base.write_taint",
"Vale.PPC64LE.Memory.valid_memtaint",
"FStar.Pervasives.reveal_opaque",
"Vale.Def.Words_s.nat64",
"Vale.Interop.Types.addr_map_pred",
"Prims.squash",
"Vale.PPC64LE.Memory.valid_taint_bufs",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts) | false | false | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val valid_memtaint (mem: vale_heap) (ps: list b8) (ts: (b8 -> GTot taint))
: Lemma (requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts) | [
"recursion"
] | Vale.PPC64LE.Memory.valid_memtaint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
mem: Vale.Arch.HeapImpl.vale_heap ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
ts: (_: Vale.PPC64LE.Memory.b8 -> Prims.GTot Vale.Arch.HeapTypes_s.taint)
-> FStar.Pervasives.Lemma (requires Vale.Interop.Heap_s.list_disjoint_or_eq ps)
(ensures
Vale.PPC64LE.Memory.valid_taint_bufs mem
(Vale.Interop.Base.create_memtaint (Vale.Arch.HeapImpl._ih mem) ps ts)
ps
ts) | {
"end_col": 142,
"end_line": 677,
"start_col": 2,
"start_line": 666
} |
FStar.Pervasives.Lemma | val find_valid_buffer_aux_ps (t: base_typ) (addr: int) (ps: list b8) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2) | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2 | val find_valid_buffer_aux_ps (t: base_typ) (addr: int) (ps: list b8) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
let rec find_valid_buffer_aux_ps (t: base_typ) (addr: int) (ps: list b8) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2) = | false | null | true | match ps with
| [] -> ()
| a :: q -> find_valid_buffer_aux_ps t addr q h1 h2 | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Prims.int",
"Prims.list",
"Vale.PPC64LE.Memory.b8",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.find_valid_buffer_aux_ps",
"Prims.unit",
"Prims.l_and",
"Prims.eq2",
"Vale.Interop.Types.b8",
"Prims.l_or",
"Vale.Interop.Heap_s.list_disjoint_or_eq",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__ptrs",
"Vale.Arch.HeapImpl._ih",
"Vale.PPC64LE.Memory.sub_list",
"Prims.squash",
"FStar.Pervasives.Native.option",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.find_valid_buffer_aux",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2) | false | false | Vale.PPC64LE.Memory.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val find_valid_buffer_aux_ps (t: base_typ) (addr: int) (ps: list b8) (h1 h2: vale_heap)
: Lemma (requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2) | [
"recursion"
] | Vale.PPC64LE.Memory.find_valid_buffer_aux_ps | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
t: Vale.Arch.HeapTypes_s.base_typ ->
addr: Prims.int ->
ps: Prims.list Vale.PPC64LE.Memory.b8 ->
h1: Vale.Arch.HeapImpl.vale_heap ->
h2: Vale.Arch.HeapImpl.vale_heap
-> FStar.Pervasives.Lemma
(requires
InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h1) ==
InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h2) /\
Vale.PPC64LE.Memory.sub_list ps (InteropHeap?.ptrs (Vale.Arch.HeapImpl._ih h1)))
(ensures
Vale.PPC64LE.Memory.find_valid_buffer_aux t addr ps h1 ==
Vale.PPC64LE.Memory.find_valid_buffer_aux t addr ps h2) | {
"end_col": 51,
"end_line": 381,
"start_col": 2,
"start_line": 379
} |
FStar.Pervasives.Lemma | val modifies_valid_taint (#t:base_typ) (b:buffer t) (p:loc) (h h':vale_heap) (mt:memtaint) (tn:taint) : Lemma
(requires modifies p h h')
(ensures valid_taint_buf b h mt tn <==> valid_taint_buf b h' mt tn)
[SMTPat (modifies p h h'); SMTPat (valid_taint_buf b h' mt tn)] | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right()) | val modifies_valid_taint (#t:base_typ) (b:buffer t) (p:loc) (h h':vale_heap) (mt:memtaint) (tn:taint) : Lemma
(requires modifies p h h')
(ensures valid_taint_buf b h mt tn <==> valid_taint_buf b h' mt tn)
[SMTPat (modifies p h h'); SMTPat (valid_taint_buf b h' mt tn)]
let modifies_valid_taint #t b p h h' mt tn = | false | null | true | let dv = get_downview b.bsrc in
let imp_left () : Lemma (requires valid_taint_buf b h mt tn) (ensures valid_taint_buf b h' mt tn) =
let aux (i: nat{i < DV.length dv}) : Lemma (mt.[ (_ih h').addrs b + i ] = tn) =
apply_taint_buf b h mt tn i
in
Classical.forall_intro aux
in
let imp_right () : Lemma (requires valid_taint_buf b h' mt tn) (ensures valid_taint_buf b h mt tn) =
let aux (i: nat{i < DV.length dv}) : Lemma (mt.[ (_ih h).addrs b + i ] = tn) =
apply_taint_buf b h' mt tn i
in
Classical.forall_intro aux
in
(Classical.move_requires imp_left ());
(Classical.move_requires imp_right ()) | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"lemma"
] | [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.buffer",
"Vale.PPC64LE.Memory.loc",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.PPC64LE.Memory.memtaint",
"Vale.Arch.HeapTypes_s.taint",
"FStar.Classical.move_requires",
"Prims.unit",
"Vale.PPC64LE.Memory.valid_taint_buf",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Classical.forall_intro",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"LowStar.BufferView.Down.length",
"FStar.UInt8.t",
"Prims.op_Equality",
"Vale.PPC64LE.Memory.op_String_Access",
"Prims.int",
"Prims.op_Addition",
"Vale.Interop.Heap_s.__proj__InteropHeap__item__addrs",
"Vale.Arch.HeapImpl._ih",
"Prims.l_True",
"FStar.Map.sel",
"Vale.PPC64LE.Memory.apply_taint_buf",
"LowStar.BufferView.Down.buffer",
"Vale.Interop.Types.get_downview",
"Vale.Interop.Types.__proj__Buffer__item__src",
"Vale.Interop.Types.b8_preorder",
"Vale.Interop.Types.__proj__Buffer__item__writeable",
"Vale.Interop.Types.base_typ_as_type",
"Vale.Interop.Types.__proj__Buffer__item__bsrc"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1 | false | false | Vale.PPC64LE.Memory.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": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val modifies_valid_taint (#t:base_typ) (b:buffer t) (p:loc) (h h':vale_heap) (mt:memtaint) (tn:taint) : Lemma
(requires modifies p h h')
(ensures valid_taint_buf b h mt tn <==> valid_taint_buf b h' mt tn)
[SMTPat (modifies p h h'); SMTPat (valid_taint_buf b h' mt tn)] | [] | Vale.PPC64LE.Memory.modifies_valid_taint | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
b: Vale.PPC64LE.Memory.buffer t ->
p: Vale.PPC64LE.Memory.loc ->
h: Vale.Arch.HeapImpl.vale_heap ->
h': Vale.Arch.HeapImpl.vale_heap ->
mt: Vale.PPC64LE.Memory.memtaint ->
tn: Vale.Arch.HeapTypes_s.taint
-> FStar.Pervasives.Lemma (requires Vale.PPC64LE.Memory.modifies p h h')
(ensures
Vale.PPC64LE.Memory.valid_taint_buf b h mt tn <==>
Vale.PPC64LE.Memory.valid_taint_buf b h' mt tn)
[
SMTPat (Vale.PPC64LE.Memory.modifies p h h');
SMTPat (Vale.PPC64LE.Memory.valid_taint_buf b h' mt tn)
] | {
"end_col": 39,
"end_line": 628,
"start_col": 44,
"start_line": 612
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_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": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Heap",
"short_module": "H"
},
{
"abbrev": false,
"full_module": "Vale.Lib.BufferViewHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": false,
"full_module": "LowStar.ModifiesPat",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.Modifies",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "LowStar.Monotonic.Buffer",
"short_module": "MB"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "Vale.Interop",
"short_module": "I"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Base",
"short_module": "IB"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Interop.Types",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapTypes_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_heaplets (layout:vale_heap_layout_inner) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) =
let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\ // modifies for entire heap
(forall (i:heaplet_id) (a:int).{:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)
) /\
(forall (i:heaplet_id).{:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i:nat).{:pattern (Seq.index bs i)} i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1 i2:nat).{:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==> buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\
True | let inv_heaplets
(layout: vale_heap_layout_inner)
(h: vale_heap)
(hs: vale_heaplets)
(mt: memTaint_t)
= | false | null | false | let bs = layout.vl_buffers in
modifies layout.vl_mod_loc layout.vl_old_heap h /\
(forall (i: heaplet_id) (a: int). {:pattern Set.mem a (layout.vl_heaplet_sets i)}
layout.vl_heaplet_map a == Some i <==> Set.mem a (layout.vl_heaplet_sets i)) /\
(forall (i: heaplet_id). {:pattern (Map16.sel hs i)}
inv_heaplet (layout.vl_heaplet_sets i) h (Map16.sel hs i)) /\
(forall (i: nat). {:pattern (Seq.index bs i)}
i < Seq.length bs ==>
inv_buffer_info (Seq.index bs i) layout.vl_heaplet_sets h hs mt layout.vl_mod_loc) /\
(forall (i1: nat) (i2: nat). {:pattern (Seq.index bs i1); (Seq.index bs i2)}
i1 < Seq.length bs /\ i2 < Seq.length bs ==>
buffer_info_disjoint (Seq.index bs i1) (Seq.index bs i2)) /\ True | {
"checked_file": "Vale.PPC64LE.Memory.fst.checked",
"dependencies": [
"Vale.X64.Machine_s.fst.checked",
"Vale.Lib.Seqs_s.fst.checked",
"Vale.Lib.BufferViewHelpers.fst.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Types.fst.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"LowStar.ModifiesPat.fst.checked",
"LowStar.Modifies.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Heap.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.PPC64LE.Memory.fst"
} | [
"total"
] | [
"Vale.Arch.HeapImpl.vale_heap_layout_inner",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.vale_heaplets",
"Vale.Arch.HeapTypes_s.memTaint_t",
"Prims.l_and",
"Vale.PPC64LE.Memory.modifies",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_mod_loc",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_old_heap",
"Prims.l_Forall",
"Vale.Arch.HeapImpl.heaplet_id",
"Prims.int",
"Prims.l_iff",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplet_map",
"FStar.Pervasives.Native.Some",
"Prims.b2t",
"FStar.Set.mem",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_heaplet_sets",
"Vale.PPC64LE.Memory.inv_heaplet",
"Vale.Lib.Map16.sel",
"Prims.nat",
"Prims.l_imp",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Arch.HeapImpl.buffer_info",
"Vale.PPC64LE.Memory.inv_buffer_info",
"FStar.Seq.Base.index",
"Vale.PPC64LE.Memory.buffer_info_disjoint",
"Prims.l_True",
"FStar.Seq.Base.seq",
"Vale.Arch.HeapImpl.__proj__Mkvale_heap_layout_inner__item__vl_buffers",
"Prims.logical"
] | [] | module Vale.PPC64LE.Memory
include Vale.Interop.Types
friend Vale.Arch.Heap
open Vale.Def.Opaque_s
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Interop.Base
module IB = Vale.Interop.Base
module I = Vale.Interop
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module MB = LowStar.Monotonic.Buffer
module M = LowStar.Modifies
open LowStar.ModifiesPat
module UV = LowStar.BufferView.Up
module DV = LowStar.BufferView.Down
open Vale.Lib.BufferViewHelpers
module H = FStar.Heap
module S = Vale.Arch.MachineHeap_s
#reset-options "--initial_fuel 2 --max_fuel 2 --initial_ifuel 1 --max_ifuel 1"
let b8 = IB.b8
unfold let (.[]) = Map.sel
unfold let (.[]<-) = Map.upd
let get_heaplet_id h =
h.heapletId
let tuint8 = UInt8.t
let tuint16 = UInt16.t
let tuint32 = UInt32.t
let tuint64 = UInt64.t
let v_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : base_typ_as_type t =
match t with
| TUInt8 -> UInt8.uint_to_t v
| TUInt16 -> UInt16.uint_to_t v
| TUInt32 -> UInt32.uint_to_t v
| TUInt64 -> UInt64.uint_to_t v
| TUInt128 -> v
let v_to_typ (t:base_typ) (v:base_typ_as_type t) : base_typ_as_vale_type t =
match t with
| TUInt8 -> UInt8.v v
| TUInt16 -> UInt16.v v
| TUInt32 -> UInt32.v v
| TUInt64 -> UInt64.v v
| TUInt128 -> v
let lemma_v_to_of_typ (t:base_typ) (v:base_typ_as_vale_type t) : Lemma
(ensures v_to_typ t (v_of_typ t v) == v)
[SMTPat (v_to_typ t (v_of_typ t v))]
=
()
let uint8_view = Vale.Interop.Views.up_view8
let uint16_view = Vale.Interop.Views.up_view16
let uint32_view = Vale.Interop.Views.up_view32
let uint64_view = Vale.Interop.Views.up_view64
let uint128_view = Vale.Interop.Views.up_view128
let uint_view (t:base_typ) : (v:UV.view UInt8.t (IB.base_typ_as_type t){UV.View?.n v == view_n t}) =
match t with
| TUInt8 -> uint8_view
| TUInt16 -> uint16_view
| TUInt32 -> uint32_view
| TUInt64 -> uint64_view
| TUInt128 -> uint128_view
let buffer_as_seq #t h b =
let s = UV.as_seq (IB.hs_of_mem (_ih h)) (UV.mk_buffer (get_downview b.bsrc) (uint_view t)) in
Vale.Lib.Seqs_s.seq_map (v_to_typ t) s
let buffer_readable #t h b = List.memP b (IB.ptrs_of_mem (_ih h))
let buffer_writeable #t b = b.writeable
let buffer_length #t b = UV.length (UV.mk_buffer (get_downview b.bsrc) (uint_view t))
let loc = M.loc
let loc_none = M.loc_none
let loc_union = M.loc_union
let loc_buffer #t b = M.loc_buffer b.bsrc
let loc_disjoint = M.loc_disjoint
let loc_includes = M.loc_includes
let modifies s h h' =
M.modifies s (_ih h).hs (_ih h').hs /\
h.heapletId == h'.heapletId /\
(_ih h).ptrs == (_ih h').ptrs /\
(_ih h).addrs == (_ih h').addrs /\
HST.equal_domains (_ih h).hs (_ih h').hs
let buffer_addr #t b h = IB.addrs_of_mem (_ih h) b
open FStar.Mul
#set-options "--z3rlimit 20"
let index64_heap_aux (s:Seq.lseq UInt8.t 8) (heap:S.machine_heap) (ptr:int) : Lemma
(requires forall (j:nat{j < 8}). UInt8.v (Seq.index s j) == heap.[ptr+j])
(ensures UInt64.v (Vale.Interop.Views.get64 s) == S.get_heap_val64 ptr heap) =
let open Vale.Def.Words.Seq_s in
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
Vale.Interop.Views.get64_reveal ();
S.get_heap_val64_reveal ();
Vale.Def.Types_s.le_bytes_to_nat64_reveal ()
let index_helper (x y:int) (heap:S.machine_heap) : Lemma
(requires x == y)
(ensures heap.[x] == heap.[y])
=
()
let index_mul_helper (addr i n j:int) : Lemma
(addr + (i * n + j) == addr + n * i + j) =
()
#set-options "--max_fuel 0 --max_ifuel 0"
let index64_get_heap_val64
(h:vale_heap)
(b:buffer64{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma (Seq.index (buffer_as_seq h b) i == S.get_heap_val64 (buffer_addr b h + scale8 i) heap)
=
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db uint64_view in
let ptr = buffer_addr b h + scale8 i in
let s = DV.as_seq (_ih h).hs db in
let t = TUInt64 in
let addr = buffer_addr b h in
UV.length_eq ub;
UV.as_seq_sel (_ih h).hs ub i;
UV.get_sel (_ih h).hs ub i;
let s' = Seq.slice s (i*8) (i*8 + 8) in
let aux (j:nat{j < 8}) : Lemma (UInt8.v (Seq.index s' j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*8 + j)) == heap.[addr + (i*8+j)]);
Seq.lemma_index_slice s (i*8) (i*8+8) j;
assert (UInt8.v (Seq.index s' j) == heap.[addr+(i*8+j)]);
index_mul_helper addr i 8 j;
()
in Classical.forall_intro aux;
index64_heap_aux s' heap ptr
#set-options "--z3rlimit 50"
open Vale.Def.Words_s
open Vale.Def.Types_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Four_s
open Vale.Lib.Seqs_s
let index128_get_heap_val128_aux (s:Seq.lseq UInt8.t 16) (ptr:int) (heap:S.machine_heap) : Lemma
(requires (forall (j:nat) . j < 16 ==> UInt8.v (Seq.index s j) == heap.[ptr+j]))
(ensures Vale.Interop.Views.get128 s == Mkfour
(S.get_heap_val32 ptr heap)
(S.get_heap_val32 (ptr+4) heap)
(S.get_heap_val32 (ptr+8) heap)
(S.get_heap_val32 (ptr+12) heap)) =
reveal_opaque (`%seq_to_seq_four_LE) (seq_to_seq_four_LE #nat8);
S.get_heap_val32_reveal ();
Vale.Interop.Views.get128_reveal ();
Vale.Def.Types_s.le_bytes_to_quad32_reveal ()
let index128_get_heap_val128
(h:vale_heap)
(b:buffer128{List.memP b (_ih h).ptrs})
(heap:S.machine_heap{IB.correct_down (_ih h) heap})
(i:nat{i < buffer_length b})
: Lemma
(ensures (
let addr = buffer_addr b h in
Seq.index (buffer_as_seq h b) i ==
Mkfour
(S.get_heap_val32 (addr + scale16 i) heap)
(S.get_heap_val32 (addr + scale16 i+4) heap)
(S.get_heap_val32 (addr + scale16 i+8) heap)
(S.get_heap_val32 (addr + scale16 i +12) heap)
))
=
let db = get_downview b.bsrc in
let vb = UV.mk_buffer db uint128_view in
let ptr = buffer_addr b h + scale16 i in
let s = DV.as_seq (_ih h).hs db in
let addr = buffer_addr b h in
UV.length_eq vb;
UV.as_seq_sel (_ih h).hs vb i;
UV.get_sel (_ih h).hs vb i;
let sl = Seq.slice s (i*16) (i*16+16) in
let aux (j:nat{j < 16}) : Lemma (UInt8.v (Seq.index sl j) == heap.[ptr+j]) =
assert (UInt8.v (Seq.index s (i*16 + j)) == heap.[addr + (i*16+j)]);
Seq.lemma_index_slice s (i*16) (i*16+16) j;
assert (UInt8.v (Seq.index sl j) == heap.[addr+(i*16+j)]);
index_mul_helper addr i 16 j
in Classical.forall_intro aux;
index128_get_heap_val128_aux sl ptr heap
let modifies_goal_directed s h1 h2 = modifies s h1 h2
let lemma_modifies_goal_directed s h1 h2 = ()
let buffer_length_buffer_as_seq #t h b = ()
let same_underlying_seq (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) : Lemma
(requires Seq.equal (DV.as_seq (_ih h1).hs (get_downview b.bsrc)) (DV.as_seq (_ih h2).hs (get_downview b.bsrc)))
(ensures Seq.equal (buffer_as_seq h1 b) (buffer_as_seq h2 b))
=
let db = get_downview b.bsrc in
let rec aux (i:nat{i <= buffer_length b}) : Lemma
(requires (forall (j:nat{j < i}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j) /\
(Seq.equal (DV.as_seq (_ih h1).hs db) (DV.as_seq (_ih h2).hs db)))
(ensures (forall (j:nat{j < buffer_length b}). Seq.index (buffer_as_seq h1 b) j == Seq.index (buffer_as_seq h2 b) j))
(decreases %[(buffer_length b) - i]) =
if i = buffer_length b then ()
else (
let bv = UV.mk_buffer db (uint_view t) in
UV.get_sel (_ih h1).hs bv i;
UV.get_sel (_ih h2).hs bv i;
UV.as_seq_sel (_ih h1).hs bv i;
UV.as_seq_sel (_ih h2).hs bv i;
aux (i+1)
)
in aux 0
let modifies_buffer_elim #t1 b p h h' =
let db = get_downview b.bsrc in
lemma_dv_equal (down_view b.src) b.bsrc (_ih h).hs (_ih h').hs;
same_underlying_seq h h' b;
assert (Seq.equal (buffer_as_seq h b) (buffer_as_seq h' b))
let modifies_buffer_addr #t b p h h' = ()
let modifies_buffer_readable #t b p h h' = ()
let loc_disjoint_none_r s = M.loc_disjoint_none_r s
let loc_disjoint_union_r s s1 s2 = M.loc_disjoint_union_r s s1 s2
let loc_includes_refl s = M.loc_includes_refl s
let loc_includes_trans s1 s2 s3 = M.loc_includes_trans s1 s2 s3
let loc_includes_union_r s s1 s2 = M.loc_includes_union_r s s1 s2
let loc_includes_union_l s1 s2 s = M.loc_includes_union_l s1 s2 s
let loc_includes_union_l_buffer #t s1 s2 b = M.loc_includes_union_l s1 s2 (loc_buffer b)
let loc_includes_none s = M.loc_includes_none s
let modifies_refl s h = M.modifies_refl s (_ih h).hs
let modifies_goal_directed_refl s h = M.modifies_refl s (_ih h).hs
let modifies_loc_includes s1 h h' s2 = M.modifies_loc_includes s1 (_ih h).hs (_ih h').hs s2
let modifies_trans s12 h1 h2 s23 h3 = M.modifies_trans s12 (_ih h1).hs (_ih h2).hs s23 (_ih h3).hs
let modifies_goal_directed_trans s12 h1 h2 s13 h3 =
modifies_trans s12 h1 h2 s13 h3;
modifies_loc_includes s13 h1 h3 (loc_union s12 s13);
()
let modifies_goal_directed_trans2 s12 h1 h2 s13 h3 = modifies_goal_directed_trans s12 h1 h2 s13 h3
let default_of_typ (t:base_typ) : base_typ_as_vale_type t =
allow_inversion base_typ;
match t with
| TUInt8 -> 0
| TUInt16 -> 0
| TUInt32 -> 0
| TUInt64 -> 0
| TUInt128 -> Vale.Def.Words_s.Mkfour #nat32 0 0 0 0
let buffer_read #t b i h =
if i < 0 || i >= buffer_length b then default_of_typ t else
Seq.index (buffer_as_seq h b) i
let seq_upd
(#b:_)
(h:HS.mem)
(vb:UV.buffer b{UV.live h vb})
(i:nat{i < UV.length vb})
(x:b)
: Lemma
(Seq.equal
(Seq.upd (UV.as_seq h vb) i x)
(UV.as_seq (UV.upd h vb i x) vb))
=
let old_s = UV.as_seq h vb in
let new_s = UV.as_seq (UV.upd h vb i x) vb in
let upd_s = Seq.upd old_s i x in
let rec aux (k:nat) : Lemma
(requires (k <= Seq.length upd_s /\ (forall (j:nat). j < k ==> Seq.index upd_s j == Seq.index new_s j)))
(ensures (forall (j:nat). j < Seq.length upd_s ==> Seq.index upd_s j == Seq.index new_s j))
(decreases %[(Seq.length upd_s) - k]) =
if k = Seq.length upd_s then ()
else begin
UV.sel_upd vb i k x h;
UV.as_seq_sel h vb k;
UV.as_seq_sel (UV.upd h vb i x) vb k;
aux (k+1)
end
in aux 0
let buffer_write #t b i v h =
if i < 0 || i >= buffer_length b then h else
begin
let view = uint_view t in
let db = get_downview b.bsrc in
let bv = UV.mk_buffer db view in
UV.upd_modifies (_ih h).hs bv i (v_of_typ t v);
UV.upd_equal_domains (_ih h).hs bv i (v_of_typ t v);
let hs' = UV.upd (_ih h).hs bv i (v_of_typ t v) in
let ih' = InteropHeap (_ih h).ptrs (_ih h).addrs hs' in
let mh' = Vale.Interop.down_mem ih' in
let h':vale_heap = ValeHeap mh' (Ghost.hide ih') h.heapletId in
seq_upd (_ih h).hs bv i (v_of_typ t v);
assert (Seq.equal (buffer_as_seq h' b) (Seq.upd (buffer_as_seq h b) i v));
h'
end
unfold let scale_t (t:base_typ) (index:int) : int = scale_by (view_n t) index
// Checks if address addr corresponds to one of the elements of buffer ptr
let addr_in_ptr (#t:base_typ) (addr:int) (ptr:buffer t) (h:vale_heap) : Ghost bool
(requires True)
(ensures fun b -> not b <==>
(forall (i:int).{:pattern (scale_t t i)} 0 <= i /\ i < buffer_length ptr ==>
addr <> (buffer_addr ptr h) + scale_t t i))
=
let n = buffer_length ptr in
let base = buffer_addr ptr h in
let rec aux (i:nat) : Tot (b:bool{not b <==> (forall j. i <= j /\ j < n ==>
addr <> base + scale_t t j)})
(decreases %[n-i]) =
if i >= n then false
else if addr = base + scale_t t i then true
else aux (i+1)
in aux 0
let valid_offset (t:base_typ) (n base:nat) (addr:int) (i:nat) =
exists j.{:pattern (scale_t t j)} i <= j /\ j < n /\ base + scale_t t j == addr
let rec get_addr_in_ptr (t:base_typ) (n base addr:nat) (i:nat) : Ghost nat
(requires valid_offset t n base addr i)
(ensures fun j -> base + scale_t t j == addr)
(decreases %[n - i])
=
if base + scale_t t i = addr then i
else get_addr_in_ptr t n base addr (i + 1)
let valid_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
DV.length (get_downview b.bsrc) % (view_n t) = 0 &&
addr_in_ptr #t addr b h
let writeable_buffer (t:base_typ) (addr:int) (b:b8) (h:vale_heap) : GTot bool =
valid_buffer t addr b h && b.writeable
#set-options "--max_fuel 1 --max_ifuel 1"
let sub_list (p1 p2:list 'a) = forall x. {:pattern List.memP x p2} List.memP x p1 ==> List.memP x p2
let rec valid_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b ->
b <==> (exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h)}
List.memP x ps /\ valid_buffer t addr x h))
=
match ps with
| [] -> false
| a::q -> valid_buffer t addr a h || valid_mem_aux t addr q h
let valid_mem (t:base_typ) addr (h:vale_heap) = valid_mem_aux t addr (_ih h).ptrs h
let valid_mem64 ptr h = valid_mem (TUInt64) ptr h
let rec find_valid_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o ->
match o with
| None -> not (valid_mem_aux t addr ps h)
| Some a -> valid_buffer t addr a h /\ List.memP a ps)
=
match ps with
| [] -> None
| a::q -> if valid_buffer t addr a h then Some a else find_valid_buffer_aux t addr q h
let find_valid_buffer (t:base_typ) (addr:int) (h:vale_heap) = find_valid_buffer_aux t addr (_ih h).ptrs h
let rec find_valid_buffer_aux_ps (t:base_typ) (addr:int) (ps:list b8) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs /\ sub_list ps (_ih h1).ptrs)
(ensures find_valid_buffer_aux t addr ps h1 == find_valid_buffer_aux t addr ps h2)
=
match ps with
| [] -> ()
| a::q -> find_valid_buffer_aux_ps t addr q h1 h2
let find_valid_buffer_ps (t:base_typ) (addr:int) (h1:vale_heap) (h2:vale_heap) : Lemma
(requires (_ih h1).ptrs == (_ih h2).ptrs)
(ensures find_valid_buffer t addr h1 == find_valid_buffer t addr h2)
=
find_valid_buffer_aux_ps t addr (_ih h1).ptrs h1 h2
let find_valid_buffer_valid_offset (t:base_typ) (addr:int) (h:vale_heap) : Lemma
(ensures (
match find_valid_buffer t addr h with
| None -> True
| Some a ->
let base = buffer_addr a h in
valid_offset t (buffer_length a) base addr 0
))
=
()
let rec writeable_mem_aux (t:base_typ) addr (ps:list b8) (h:vale_heap) : Ghost bool
(requires sub_list ps (_ih h).ptrs)
(ensures fun b -> b <==>
(exists (x:buffer t). {:pattern (List.memP x ps) \/ (valid_buffer t addr x h) \/ buffer_writeable x}
List.memP x ps /\ valid_buffer t addr x h /\ buffer_writeable x))
=
match ps with
| [] -> false
| a::q -> writeable_buffer t addr a h || writeable_mem_aux t addr q h
let writeable_mem (t:base_typ) addr (h:vale_heap) = writeable_mem_aux t addr (_ih h).ptrs h
let writeable_mem64 ptr h = writeable_mem (TUInt64) ptr h
let rec find_writeable_buffer_aux (t:base_typ) (addr:int) (ps:list b8) (h:vale_heap) : Ghost (option (buffer t))
(requires sub_list ps (_ih h).ptrs)
(ensures fun o -> (
match o with
| None -> not (writeable_mem_aux t addr ps h)
| Some a -> writeable_buffer t addr a h /\ List.memP a ps
))
=
match ps with
| [] -> None
| a::q -> if writeable_buffer t addr a h then Some a else find_writeable_buffer_aux t addr q h
let find_writeable_buffer (t:base_typ) (addr:int) (h:vale_heap) =
find_writeable_buffer_aux t addr (_ih h).ptrs h
let load_mem (t:base_typ) (addr:int) (h:vale_heap) : GTot (base_typ_as_vale_type t) =
match find_valid_buffer t addr h with
| None -> default_of_typ t
| Some a ->
let base = buffer_addr a h in
buffer_read a (get_addr_in_ptr t (buffer_length a) base addr 0) h
let load_mem64 ptr h =
if not (valid_mem64 ptr h) then 0
else load_mem (TUInt64) ptr h
let length_t_eq (t:base_typ) (b:buffer t) :
Lemma (DV.length (get_downview b.bsrc) == buffer_length b * (view_n t)) =
let db = get_downview b.bsrc in
let ub = UV.mk_buffer db (uint_view t) in
UV.length_eq ub;
assert (buffer_length b == DV.length db / (view_n t));
FStar.Math.Lib.lemma_div_def (DV.length db) (view_n t)
let get_addr_ptr (t:base_typ) (ptr:int) (h:vale_heap) : Ghost (buffer t)
(requires valid_mem t ptr h)
(ensures fun b -> List.memP b (_ih h).ptrs /\ valid_buffer t ptr b h)
=
Some?.v (find_valid_buffer t ptr h)
#reset-options "--max_fuel 0 --max_ifuel 0 --initial_fuel 0 --initial_ifuel 0 --z3rlimit 20"
let load_buffer_read (t:base_typ) (ptr:int) (h:vale_heap) : Lemma
(requires valid_mem t ptr h)
(ensures (
let b = get_addr_ptr t ptr h in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
load_mem t ptr h == buffer_read #t b i h
))
=
()
let store_mem (t:base_typ) (addr:int) (v:base_typ_as_vale_type t) (h:vale_heap) : Ghost vale_heap
(requires True)
(ensures fun h1 -> (_ih h).addrs == (_ih h1).addrs /\ (_ih h).ptrs == (_ih h1).ptrs)
=
match find_writeable_buffer t addr h with
| None -> h
| Some a ->
let base = buffer_addr a h in
buffer_write a (get_addr_in_ptr t (buffer_length a) base addr 0) v h
let store_mem64 i v h =
if not (valid_mem64 i h) then h
else store_mem (TUInt64) i v h
let store_buffer_write
(t:base_typ)
(ptr:int)
(v:base_typ_as_vale_type t)
(h:vale_heap{writeable_mem t ptr h})
: Lemma
(ensures (
let b = Some?.v (find_writeable_buffer t ptr h) in
let i = get_addr_in_ptr t (buffer_length b) (buffer_addr b h) ptr 0 in
store_mem t ptr v h == buffer_write b i v h
))
=
()
let valid_mem128 ptr h = valid_mem_aux (TUInt128) ptr (_ih h).ptrs h
let writeable_mem128 ptr h = writeable_mem_aux (TUInt128) ptr (_ih h).ptrs h
let load_mem128 ptr h =
if not (valid_mem128 ptr h) then (default_of_typ (TUInt128))
else load_mem (TUInt128) ptr h
let store_mem128 ptr v h =
if not (valid_mem128 ptr h) then h
else store_mem (TUInt128) ptr v h
let lemma_valid_mem64 b i h = ()
let lemma_writeable_mem64 b i h = ()
let lemma_store_mem (t:base_typ) (b:buffer t) (i:nat) (v:base_typ_as_vale_type t) (h:vale_heap) : Lemma
(requires
i < Seq.length (buffer_as_seq h b) /\
buffer_readable h b /\
buffer_writeable b
)
(ensures
store_mem t (buffer_addr b h + scale_t t i) v h == buffer_write b i v h
)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let view = uint_view t in
let addr = buffer_addr b h + scale_t t i in
match find_writeable_buffer t addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_load_mem64 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale8 i in
let view = uint64_view in
match find_valid_buffer TUInt64 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem64 b i v h = lemma_store_mem TUInt64 b i v h
let lemma_valid_mem128 b i h = ()
let lemma_writeable_mem128 b i h = ()
let lemma_load_mem128 b i h =
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
let addr = buffer_addr b h + scale16 i in
let view = uint128_view in
match find_valid_buffer TUInt128 addr h with
| None -> ()
| Some a ->
let da = get_downview a.bsrc in
let db = get_downview b.bsrc in
UV.length_eq (UV.mk_buffer da view);
UV.length_eq (UV.mk_buffer db view);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.disjoint_or_eq_b8 a b);
assert (a == b)
let lemma_store_mem128 b i v h = lemma_store_mem TUInt128 b i v h
open Vale.X64.Machine_s
let valid_taint_b8 (b:b8) (h:vale_heap) (mt:memtaint) (tn:taint) : GTot prop0 =
let addr = (_ih h).addrs b in
(forall (i:int).{:pattern (mt.[i])}
addr <= i /\ i < addr + DV.length (get_downview b.bsrc) ==> mt.[i] == tn)
let valid_taint_buf #t b h mt tn =
valid_taint_b8 b h mt tn
let apply_taint_buf (#t:base_typ) (b:buffer t) (mem:vale_heap) (memTaint:memtaint) (tn:taint) (i:nat) : Lemma
(requires i < DV.length (get_downview b.bsrc) /\ valid_taint_buf b mem memTaint tn)
(ensures memTaint.[(_ih mem).addrs b + i] == tn)
=
()
let lemma_valid_taint64 b memTaint mem i t =
length_t_eq (TUInt64) b;
let ptr = buffer_addr b mem + scale8 i in
let aux (i':nat) : Lemma
(requires i' >= ptr /\ i' < ptr + 8)
(ensures memTaint.[i'] == t) =
let extra = scale8 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let lemma_valid_taint128 b memTaint mem i t =
length_t_eq (TUInt128) b;
let ptr = buffer_addr b mem + scale16 i in
let aux i' : Lemma
(requires i' >= ptr /\ i' < ptr + 16)
(ensures memTaint.[i'] == t) =
let extra = scale16 i + i' - ptr in
assert (i' == (_ih mem).addrs b + extra);
apply_taint_buf b mem memTaint t extra
in
Classical.forall_intro (Classical.move_requires aux)
let same_memTaint (t:base_typ) (b:buffer t) (mem0 mem1:vale_heap) (memT0 memT1:memtaint) : Lemma
(requires modifies (loc_buffer b) mem0 mem1 /\
(forall p. Map.sel memT0 p == Map.sel memT1 p))
(ensures memT0 == memT1) =
assert (Map.equal memT0 memT1)
let same_memTaint64 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt64) b mem0 mem1 memtaint0 memtaint1
let same_memTaint128 b mem0 mem1 memtaint0 memtaint1 =
same_memTaint (TUInt128) b mem0 mem1 memtaint0 memtaint1
let modifies_valid_taint #t b p h h' mt tn =
let dv = get_downview b.bsrc in
let imp_left () : Lemma
(requires valid_taint_buf b h mt tn)
(ensures valid_taint_buf b h' mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h').addrs b + i] = tn) =
apply_taint_buf b h mt tn i
in Classical.forall_intro aux
in let imp_right () : Lemma
(requires valid_taint_buf b h' mt tn)
(ensures valid_taint_buf b h mt tn) =
let aux (i:nat{i < DV.length dv}) : Lemma (mt.[(_ih h).addrs b + i] = tn) =
apply_taint_buf b h' mt tn i
in Classical.forall_intro aux
in
(Classical.move_requires imp_left());
(Classical.move_requires imp_right())
#set-options "--initial_fuel 1 --max_fuel 1 --initial_ifuel 1 --max_ifuel 1"
let modifies_same_heaplet_id l h1 h2 =
()
let valid_taint_bufs (mem:vale_heap) (memTaint:memtaint) (ps:list b8) (ts:b8 -> GTot taint) =
forall b.{:pattern List.memP b ps} List.memP b ps ==> valid_taint_b8 b mem memTaint (ts b)
let rec write_taint_lemma (i:nat) (mem:IB.interop_heap) (ts:b8 -> GTot taint) (b:b8) (accu:memtaint) : Lemma
(requires
i <= DV.length (get_downview b.bsrc) /\
(forall (j:int).{:pattern accu.[j]} mem.addrs b <= j /\ j < mem.addrs b + i ==> accu.[j] = ts b)
)
(ensures (
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
(forall j.{:pattern m.[j]} addr <= j /\ j < addr + DV.length (get_downview b.bsrc) ==>
m.[j] = ts b) /\
(forall j. {:pattern m.[j]} j < addr \/ j >= addr + DV.length (get_downview b.bsrc) ==>
m.[j] == accu.[j])))
(decreases %[DV.length (get_downview b.bsrc) - i])
=
let m = IB.write_taint i mem ts b accu in
let addr = mem.addrs b in
if i >= DV.length (get_downview b.bsrc) then ()
else
let new_accu = accu.[addr+i] <- ts b in
assert (IB.write_taint i mem ts b accu == IB.write_taint (i + 1) mem ts b new_accu);
assert (Set.equal (Map.domain new_accu) (Set.complement Set.empty));
assert (forall j.{:pattern m.[j]} addr <= j /\ j < addr + i + 1 ==> new_accu.[j] == ts b);
write_taint_lemma (i + 1) mem ts b new_accu
#restart-solver
let rec valid_memtaint (mem:vale_heap) (ps:list b8) (ts:b8 -> GTot taint) : Lemma
(requires IB.list_disjoint_or_eq ps)
(ensures valid_taint_bufs mem (IB.create_memtaint (_ih mem) ps ts) ps ts)
=
FStar.Pervasives.reveal_opaque (`%addr_map_pred) addr_map_pred;
match ps with
| [] -> ()
| b :: q ->
assert (List.memP b ps);
assert (forall i. {:pattern List.memP i q} List.memP i q ==> List.memP i ps);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (IB.list_disjoint_or_eq q);
valid_memtaint mem q ts;
assert (IB.create_memtaint (_ih mem) ps ts ==
IB.write_taint 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts));
write_taint_lemma 0 (_ih mem) ts b (IB.create_memtaint (_ih mem) q ts);
opaque_assert (`%list_disjoint_or_eq) list_disjoint_or_eq list_disjoint_or_eq_def (forall p. List.memP p q ==> IB.disjoint_or_eq_b8 p b)
let valid_layout_data_buffer (t:base_typ) (b:buffer t) (layout:vale_heap_layout_inner) (hid:heaplet_id) (write:bool) =
exists (n:nat).{:pattern (Seq.index layout.vl_buffers n)} n < Seq.length layout.vl_buffers /\ (
let bi = Seq.index layout.vl_buffers n in
t == bi.bi_typ /\
b == bi.bi_buffer /\
(write ==> bi.bi_mutable == Mutable) /\
hid == bi.bi_heaplet)
[@"opaque_to_smt"]
let valid_layout_buffer_id t b layout h_id write =
match h_id with
| None -> True
| Some hid ->
layout.vl_inner.vl_heaplets_initialized /\
valid_layout_data_buffer t b layout.vl_inner hid write
let inv_heaplet_ids (hs:vale_heaplets) =
forall (i:heaplet_id).{:pattern Map16.sel hs i} (Map16.sel hs i).heapletId == Some i
let inv_heaplet (owns:Set.set int) (h hi:vale_heap) =
h.ih.IB.ptrs == hi.ih.IB.ptrs /\
Map.domain h.mh == Map.domain hi.mh /\
(forall (i:int).{:pattern Set.mem i owns \/ Set.mem i (Map.domain h.mh) \/ Map.sel h.mh i \/ Map.sel hi.mh i}
Set.mem i owns ==>
Set.mem i (Map.domain h.mh) /\
Map.sel h.mh i == Map.sel hi.mh i /\
True
) /\
True
// heaplet state matches heap state
let inv_buffer_info (bi:buffer_info) (owners:heaplet_id -> Set.set int) (h:vale_heap) (hs:vale_heaplets) (mt:memTaint_t) (modloc:loc) =
let t = bi.bi_typ in
let hid = bi.bi_heaplet in
let hi = Map16.get hs hid in
let b = bi.bi_buffer in
let owns = owners hid in
(bi.bi_mutable == Mutable ==> loc_includes modloc (loc_buffer b)) /\
buffer_readable h b /\
buffer_as_seq hi b == buffer_as_seq h b /\
(valid_taint_buf b hi mt bi.bi_taint <==> valid_taint_buf b h mt bi.bi_taint) /\
(forall (i:int).{:pattern Set.mem i owns}
buffer_addr b h <= i /\ i < buffer_addr b h + DV.length (get_downview b.bsrc) ==> Set.mem i owns) /\
True | false | true | Vale.PPC64LE.Memory.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_heaplets : layout: Vale.Arch.HeapImpl.vale_heap_layout_inner ->
h: Vale.Arch.HeapImpl.vale_heap ->
hs: Vale.Arch.HeapImpl.vale_heaplets ->
mt: Vale.Arch.HeapTypes_s.memTaint_t
-> Prims.logical | [] | Vale.PPC64LE.Memory.inv_heaplets | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
layout: Vale.Arch.HeapImpl.vale_heap_layout_inner ->
h: Vale.Arch.HeapImpl.vale_heap ->
hs: Vale.Arch.HeapImpl.vale_heaplets ->
mt: Vale.Arch.HeapTypes_s.memTaint_t
-> Prims.logical | {
"end_col": 6,
"end_line": 736,
"start_col": 99,
"start_line": 724
} |
Subsets and Splits