.
.
.
.
Proof.
.
Proof.
.
Proof.
).
Proof.
).
Proof.
.
Proof.
.
Proof.
Transparent Mem.load.
intros NIF ab κ
ofs AL.
assert (
match block_of_ablock ge (
fst m)
ab with
|
None =>
mem_as_fun ge m (
cell_from ab (
ofs, κ)) =
Vundef
|
Some b =>
mem_as_fun ge m (
cell_from ab (
ofs, κ)) =
extend (
Mem.load (
proj1_sig κ) (
snd m)
b)
ofs
end)
as K.
{
clear.
destruct ab as [
f x |
b ];
simpl.
case get_stk;
simpl;
auto.
intros (
tmp,
e).
case (
e !
x);
simpl;
auto.
intros (
b,
sz).
reflexivity.
case Genv.invert_symbol;
simpl;
auto.
}
destruct (
block_of_ablock _ _ _)
as [
b | ]
eqn:
Hab;
rewrite K.
-
simpl.
unfold Mem.load.
case Mem.valid_access_dec.
+
intros VALID.
eexists.
refine (
conj _ (
conj eq_refl _)).
{
specialize (
NIF _ _ Hab).
clear -
NIF.
assert (
let sz :=
size_chunk_nat (
proj1_sig κ)
in sz = 1 ∨
sz = 2 ∨
sz = 4 ∨
sz = 8)%
nat as C.
destruct κ
as [() ()];
eauto.
simpl in C.
assert (∀
b c:
bool,
b →
c →
b &&
c)
as K by (
intros () ();
auto).
repeat destruct C as [
C |
C ];
rewrite C;
clear κ
C;
simpl;
repeat (
apply K;
auto);
match goal with
|-
appcontext[
ZMap.get ?
o ] =>
generalize (
NIF o);
destruct (
ZMap.get o _)
as [ | | () ];
intros ();
auto
end. }
apply conj'.
apply Mem.getN_length.
intros Hlen i LT.
assert ((
i <
size_chunk_nat (
proj1_sig κ))%
nat)
as Hi
by (
rewrite <-
Hlen;
apply NPeano.ltb_lt,
LT).
rewrite (
get_nth Undef),
getN_map_seq_get.
rewrite map_nth'
with (
q :=
O). 2:
now rewrite seq_length.
rewrite seq_nth;
auto.
rewrite (
block_of_ablock_Some _ _ _ Hab).
simpl.
unfold Mem.load.
case Mem.valid_access_dec.
reflexivity.
intros X;
elim X;
clear X.
split.
simpl.
intros n Hn.
apply (
proj1 VALID n).
apply NPeano.ltb_lt in LT.
rewrite Mem.getN_length in LT.
unfold size_chunk_nat in LT.
clear -
Hn LT.
pose proof (
size_chunk_pos (
proj1_sig κ)).
zify.
rewrite Z2Nat.id in LT;
Psatz.lia.
eexists.
rewrite Z.mul_1_r.
reflexivity.
+
intros Hvalid.
assert (¬
Mem.range_perm (
snd m)
b ofs (
ofs +
size_chunk (
proj1_sig κ))
Cur Readable)
as Hperm.
{
now intros ?;
apply Hvalid;
split. }
clear Hvalid.
exists (
List.map (λ
i,
if Mem.valid_access_dec (
snd m)
Mint8unsigned b (
ofs +
Z.of_nat i)
Readable
then ZMap.get (
ofs +
Z.of_nat i) ((
Mem.mem_contents (
snd m)) !!
b)
else Undef
) (
List.seq O (
size_chunk_nat (
proj1_sig κ)))
).
repeat (
refine (
conj'
_ (λ
H,
_))).
{
specialize (
NIF _ _ Hab).
clear -
NIF.
assert (
let sz :=
size_chunk_nat (
proj1_sig κ)
in sz = 1 ∨
sz = 2 ∨
sz = 4 ∨
sz = 8)%
nat as C.
destruct κ
as [() ()];
eauto.
simpl in C.
assert (∀
b c:
bool,
b →
c →
b &&
c)
as K by (
intros () ();
auto).
repeat destruct C as [
C |
C ];
rewrite C;
clear κ
C;
simpl;
repeat (
apply K;
auto);
destruct Mem.valid_access_dec;
auto;
match goal with
|-
appcontext[
ZMap.get ?
o ] =>
generalize (
NIF o);
destruct (
ZMap.get o _)
as [ | | () ];
intros ();
auto
end. }
destruct κ
as [() ?];
simpl.
destruct (
Mem.valid_access_dec _ _ _ _)
as [ (
Hperm0 &
_) |
Hvalid0 ];
auto.
elim Hperm.
generalize Hperm0.
simpl.
now rewrite !
Z.add_0_r.
destruct (
Mem.valid_access_dec _ _ _ _)
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
now rewrite !
Z.add_0_r in Hperm0.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1). 2:
Psatz.lia.
intros [ -> | -> ] ; [
apply Hperm0 |
apply Hperm1 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mint16signed I)).
simpl.
intuition.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1). 2:
Psatz.lia.
intros [ -> | -> ] ; [
apply Hperm0 |
apply Hperm1 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mint16unsigned I)).
simpl.
intuition.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 2))
as [ (
Hperm2 &
_) |
Hvalid2].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 3))
as [ (
Hperm3 &
_) |
Hvalid3].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i);
specialize (
Hperm2 i);
specialize (
Hperm3 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1 ∨
i =
ofs + 2 ∨
i =
ofs + 3). 2:
Psatz.lia.
intros [ -> | [ -> | [ -> | -> ] ] ] ; [
apply Hperm0 |
apply Hperm1 |
apply Hperm2 |
apply Hperm3 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mint32 I)).
simpl.
intuition.
apply (
decode_val_undef_in (
exist _ Mint32 I)).
simpl.
intuition.
apply (
decode_val_undef_in (
exist _ Mint32 I)).
simpl.
intuition.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 2))
as [ (
Hperm2 &
_) |
Hvalid2].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 3))
as [ (
Hperm3 &
_) |
Hvalid3].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 4))
as [ (
Hperm4 &
_) |
Hvalid4].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 5))
as [ (
Hperm5 &
_) |
Hvalid5].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 6))
as [ (
Hperm6 &
_) |
Hvalid6].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 7))
as [ (
Hperm7 &
_) |
Hvalid7].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i);
specialize (
Hperm2 i);
specialize (
Hperm3 i);
specialize (
Hperm4 i);
specialize (
Hperm5 i);
specialize (
Hperm6 i);
specialize (
Hperm7 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1 ∨
i =
ofs + 2 ∨
i =
ofs + 3 ∨
i =
ofs + 4 ∨
i =
ofs + 5 ∨
i =
ofs + 6 ∨
i =
ofs + 7). 2:
Psatz.lia.
intros [ -> | [ -> | [ -> | [ -> | [ -> | [ -> | [ -> | -> ] ] ] ] ] ] ]; [
apply Hperm0 |
apply Hperm1 |
apply Hperm2 |
apply Hperm3 |
apply Hperm4 |
apply Hperm5 |
apply Hperm6 |
apply Hperm7 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mint64 I));
simpl;
intuition.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 2))
as [ (
Hperm2 &
_) |
Hvalid2].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 3))
as [ (
Hperm3 &
_) |
Hvalid3].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i);
specialize (
Hperm2 i);
specialize (
Hperm3 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1 ∨
i =
ofs + 2 ∨
i =
ofs + 3). 2:
Psatz.lia.
intros [ -> | [ -> | [ -> | -> ] ] ] ; [
apply Hperm0 |
apply Hperm1 |
apply Hperm2 |
apply Hperm3 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mfloat32 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat32 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat32 I));
simpl;
intuition.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 0))
as [ (
Hperm0 &
_) |
Hvalid0];
auto.
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 1))
as [ (
Hperm1 &
_) |
Hvalid1].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 2))
as [ (
Hperm2 &
_) |
Hvalid2].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 3))
as [ (
Hperm3 &
_) |
Hvalid3].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 4))
as [ (
Hperm4 &
_) |
Hvalid4].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 5))
as [ (
Hperm5 &
_) |
Hvalid5].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 6))
as [ (
Hperm6 &
_) |
Hvalid6].
destruct (
Mem.valid_access_dec _ _ _ (
ofs + 7))
as [ (
Hperm7 &
_) |
Hvalid7].
elim Hperm;
intros i Hi;
specialize (
Hperm0 i);
specialize (
Hperm1 i);
specialize (
Hperm2 i);
specialize (
Hperm3 i);
specialize (
Hperm4 i);
specialize (
Hperm5 i);
specialize (
Hperm6 i);
specialize (
Hperm7 i).
simpl in *.
cut (
i =
ofs ∨
i =
ofs + 1 ∨
i =
ofs + 2 ∨
i =
ofs + 3 ∨
i =
ofs + 4 ∨
i =
ofs + 5 ∨
i =
ofs + 6 ∨
i =
ofs + 7). 2:
Psatz.lia.
intros [ -> | [ -> | [ -> | [ -> | [ -> | [ -> | [ -> | -> ] ] ] ] ] ] ]; [
apply Hperm0 |
apply Hperm1 |
apply Hperm2 |
apply Hperm3 |
apply Hperm4 |
apply Hperm5 |
apply Hperm6 |
apply Hperm7 ];
Psatz.lia.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
apply (
decode_val_undef_in (
exist _ Mfloat64 I));
simpl;
intuition.
easy.
easy.
now rewrite map_length,
seq_length.
intros i Hi.
rewrite (
get_nth Undef).
apply NPeano.ltb_lt in Hi.
rewrite H1 in *.
rewrite (
block_of_ablock_Some _ _ _ Hab).
simpl.
unfold Mem.load.
rewrite map_nth'
with (
q :=
O),
seq_nth.
simpl.
destruct (
Mem.valid_access_dec _ _ _ _);
auto.
easy.
now rewrite seq_length.
-
exists (
List.map (λ
_,
Undef) (
seq 0 (
size_chunk_nat (
proj1_sig κ)))).
destruct κ
as [()
X];
try elim X;
(
split; [
vm_compute;
reflexivity | ];
split; [
vm_compute;
reflexivity | ];
split; [
vm_compute;
reflexivity | ]);
intros i LT;
repeat (
destruct i as [ |
i ];
try exact (
false_not_true LT _));
simpl in *;
rewrite (
block_of_ablock_None _ _ _ Hab);
reflexivity.
Opaque Mem.load.
Qed.
.
Proof.
.
Proof.
.
Proof.
* 256)).
Proof.
).
Proof.
₀.
Proof.
₁.
Proof.
₃ * 256) * 256) * 256.
Proof.
(8 * 1)).
Proof.
(8 * 1))).
Proof.
(8 * 1))).
Proof.
(8 * 2))).
Proof.
(8 * 3))).
Proof.
.
Proof.
.
Proof.
256)) < 65281.
Proof.
65536)) < 16711681.
Proof.
16777216)) < 4278190081.
Proof.