.
'.
Proof.
.
'.
Proof.
.
Proof.
).
Proof.
).
Proof.
).
Proof.
.
Proof.
Here we need constraints on init_mem, which should be a property of Language...
that says, we need any memory, with nextblock = ge.next, and initial data properly initialized,
no matter what the content in blocks not correspond to any ident, should be a proper initial memory
).
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
'.
Proof.
intros mu12 mu23 mu13 m2 m1'
m3'
MUCOMP INV13 RC3 FINITE2.
exploit mu_finite_1;
eauto.
intros [
bound1 FINITE1].
FINITE -> INJECT -> FINITE
assert (exists bound2, forall b, SharedTgt mu12 b -> Plt b bound2) as (bound2 & FINITE2).
{ inv MUCOMP. inv mu_inject_13. inv inj_weak. destruct mu12; simpl in *.
assert (FINITE: forall b', SharedTgt b' -> exists b, inj b = Some b' /\ Plt b bound1).
{ intros. apply inj_range in H. destruct H. eexists. split. eauto. apply FINITE1.
rewrite <- mu_Shared1_equiv0. eapply inj_dom'. eauto. }
revert FINITE inj_injective. clear. revert inj bound1 SharedTgt. unfold block.
intros j B T. revert T. pattern B. eapply positive_Peano_ind; clear B; intros.
exists 1%positive. intros. exfalso. apply FINITE in H. destruct H as [b0 [H H']]. eapply Pos.nlt_1_r; eauto.
specialize (H (fun b' => T b' /\ (forall b, j b = Some b' -> Plt b x))); simpl in H.
exploit H. intros b' [RANGE BOUND]. apply FINITE in RANGE. destruct RANGE as [b [INJ _]]. exists b. split; auto. auto.
intros [B' BOUND].
destruct (j x) as [B''|] eqn:XIMG.
exists (Pos.max B' (Pos.succ B'')). intros. exploit FINITE. exact H0. intros [b0 [INJ BOUND']].
destruct (peq b0 x).
subst. rewrite XIMG in INJ. inv INJ. pose proof (Pos.le_max_r B' (Pos.succ b)).
unfold Plt in *. apply Pos.le_succ_l; eauto.
apply Plt_Ple_trans with B'. apply BOUND. split; auto. intros.
exploit inj_injective. exact H1. exact INJ. intro. subst. apply Plt_succ_inv in BOUND'. destruct BOUND'; congruence.
apply Pos.le_max_l.
exists B'. intros. exploit FINITE. exact H0. intros [b0 [INJ BOUND']].
destruct (peq b0 x). subst. congruence.
apply BOUND. split; auto. intros. exploit inj_injective. exact INJ. exact H1. intros; subst.
apply Plt_succ_inv in BOUND'. destruct BOUND'; congruence. } *)
exploit finite_bset_inject_revert.
exact FINITE2.
exploit mu_inject_23;
eauto.
erewrite <-
mu_Shared2_equiv;
eauto.
intros [
j32 [
INJECT32 CONSIST23]].
pose (
Mem.nextblock m2)
as bound2.
exists (
update_memory (
inj mu23)
j32 bound2 m2 m3').
split.
INV12
unfold LDefs.Inv,
Bset.inj_to_meminj,
update_memory.
constructor.
constructor.
perm
{
intros until 1.
destruct (
inj mu12 b1)
eqn:? ;
inv H.
pose proof Heqo as INJ12.
eapply Bset.inj_range'
in Heqo;
try (
eapply Bset.inj_weak;
eapply mu_inject_12;
eauto;
fail).
erewrite mu_Shared2_equiv in Heqo;
eauto.
eapply Bset.inj_dom in Heqo;
try (
eapply mu_inject_23;
eauto).
destruct Heqo as [
b3 INJ23].
pose proof (
mu_inj_comp _ _ _ MUCOMP b1)
as INJ13.
rewrite INJ12,
INJ23 in INJ13.
intro PERM1.
exploit Mem.mi_perm;
try exact PERM1.
inv INV13;
eauto.
unfold Bset.inj_to_meminj.
rewrite INJ13;
eauto.
rewrite Z.add_0_r.
intro PERM3.
unfold Mem.perm,
Mem.perm_order'
in *;
simpl in *;
intros.
destruct ((
Mem.mem_access m1') !!
b1 ofs k)
eqn:
PERM1';
try contradiction.
destruct ((
Mem.mem_access m3') !!
b3 ofs k)
eqn:
PERM3';
try contradiction.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H.
rewrite H0.
unfold update_access_func.
destruct plt.
rewrite INJ23.
rewrite PERM3'.
auto.
exfalso.
eapply n.
apply FINITE2.
eapply Bset.inj_range'
in INJ12;
eauto.
eapply Bset.inj_weak,
mu_inject_12;
eauto.
}
align
{
intros.
destruct (
inj mu12 b1);
inv H.
apply Z.divide_0_r. }
memval
{
simpl.
intros.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H1.
rewrite H2.
destruct (
inj mu12 b1)
eqn:?;
inv H.
rewrite Z.add_0_r.
exploit Bset.inj_range';
eauto.
eapply Bset.inj_weak,
mu_inject_12;
eauto.
intro SHARED2.
exploit (
FINITE2 b2).
auto.
intro BOUND.
unfold inject_content.
destruct plt; [|
contradiction].
exploit Bset.inj_dom.
eapply mu_inject_23;
eauto.
erewrite <-
mu_Shared2_equiv;
eauto.
intros [
b3 INJ23].
rewrite INJ23.
destruct (
proj2_sig (
inject_zmap_memval_c j32 (
Mem.mem_contents m3') !!
b3)).
rewrite H3.
unfold inject_zmap_memval.
exploit Mem.mi_memval.
inv INV13;
eauto.
unfold Bset.inj_to_meminj.
erewrite mu_inj_comp;
eauto.
rewrite Heqo,
INJ23;
eauto.
eauto.
rewrite Z.add_0_r.
intro MEMVAL.
inv MEMVAL;
simpl;
constructor.
inv H6;
simpl;
try constructor.
unfold Bset.inj_to_meminj in H7.
destruct (
inj mu13 b0)
eqn:
INJ13';
inv H7.
exploit mu_inj_comp;
eauto.
rewrite INJ13'.
intro.
destruct (
inj mu12 b0)
eqn:
INJ12';
try discriminate.
symmetry in H6.
apply CONSIST23 in H6.
rewrite H6.
econstructor.
rewrite INJ12'.
eauto.
auto. }
freeblocks
{
intros.
destruct (
inj mu12 b)
eqn:
INJ12;
auto.
exfalso.
exploit Mem.mi_freeblocks;
eauto.
unfold Bset.inj_to_meminj.
erewrite mu_inj_comp;
eauto.
rewrite INJ12.
destruct (
inj mu23 b0)
eqn:
INJ23.
discriminate.
eapply Bset.inj_range'
in INJ12.
eapply Bset.inj_dom in INJ12.
rewrite INJ23 in INJ12.
destruct INJ12.
discriminate.
eapply mu_inject_23;
eauto.
erewrite <-
mu_Shared2_equiv;
eauto.
eapply Bset.inj_weak,
mu_inject_12;
eauto. }
mapped blocks
{
intros.
unfold Mem.valid_block;
simpl.
destruct (
inj mu12 b)
eqn:
INJ12;
inv H.
apply Pos.max_lt_iff.
right.
apply FINITE2.
eapply Bset.inj_range';
eauto.
eapply mu_inject_12;
eauto. }
no overlap
{
unfold Mem.meminj_no_overlap.
intros.
destruct (
inj mu12 b1)
eqn:
INJ1;
inv H0.
destruct (
inj mu12 b2)
eqn:
INJ2;
inv H1.
left.
intro.
apply H.
subst.
eapply Bset.inj_injective;
eauto.
eapply mu_inject_12;
eauto. }
representable
{
intros.
destruct (
inj mu12 b)
eqn:
INJ12;
inv H.
split;[
xomega|].
pose proof (
Ptrofs.unsigned_range ofs).
unfold Ptrofs.max_unsigned.
omega. }
perm inv
{
unfold Mem.perm,
Mem.perm_order';
simpl.
intros.
destruct (
inj mu12 b1)
eqn:
INJ12;
inv H.
rewrite Z.add_0_r in H0.
exploit Bset.inj_range';
eauto.
eapply Bset.inj_weak,
mu_inject_12;
eauto.
intro SHARED2.
exploit (
FINITE2 b2).
auto.
intro BOUND.
exploit Bset.inj_dom.
eapply mu_inject_23;
eauto.
erewrite <-
mu_Shared2_equiv;
eauto.
intros [
b3 INJ23].
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H.
rewrite H1 in H0.
unfold update_access_func in H0.
destruct plt;
try contradiction.
rewrite INJ23 in H0.
eapply Mem.mi_perm_inv;
eauto.
unfold Bset.inj_to_meminj.
erewrite mu_inj_comp,
INJ12,
INJ23;
eauto.
rewrite Z.add_0_r.
auto. }
INV23
split.
unfold LDefs.Inv,
Bset.inj_to_meminj,
update_memory.
constructor.
constructor.
perm
{
intros b2 b3;
intros until 1.
destruct (
inj mu23 b2)
eqn:? ;
inv H.
pose proof Heqo as INJ23.
eapply Bset.inj_dom'
in Heqo;
try (
eapply Bset.inj_weak;
eapply mu_inject_23;
eauto;
fail).
exploit FINITE2.
erewrite mu_Shared2_equiv;
eauto.
intro BOUND2.
unfold Mem.perm,
Mem.perm_order';
simpl.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H.
rewrite H0.
unfold update_access_func.
destruct plt;
try contradiction.
rewrite INJ23,
Z.add_0_r.
auto. }
align
{
intros.
destruct (
inj mu23 b1);
inv H.
apply Z.divide_0_r. }
memval
{
simpl.
intros b2 ofs b3 delta INJ23 PERM.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H.
rewrite H0.
destruct (
inj mu23 b2)
eqn:?;
inv INJ23.
rewrite Z.add_0_r.
exploit Bset.inj_dom';
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
intro SHARED2.
exploit FINITE2.
erewrite mu_Shared2_equiv;
eauto.
intro BOUND2.
unfold inject_content.
destruct plt;
try contradiction.
rewrite Heqo.
destruct (
proj2_sig (
inject_zmap_memval_c j32 (
Mem.mem_contents m3') !!
b3)).
rewrite H2.
unfold inject_zmap_memval.
destruct (
ZMap.get ofs (
Mem.mem_contents m3') !!
b3);
simpl;
constructor.
destruct v;
simpl;
try econstructor.
destruct (
j32 b)
eqn:
J32; [|
constructor].
apply CONSIST23 in J32.
econstructor.
rewrite J32.
eauto.
auto using Ptrofs.add_zero. }
freeblocks
{
intros.
destruct (
inj mu23 b)
eqn:
INJ23;
auto.
exfalso.
apply H.
exploit FINITE2.
erewrite mu_Shared2_equiv;
eauto.
eapply Bset.inj_dom';
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
intro BOUND2.
unfold Mem.valid_block.
simpl.
apply Pos.max_lt_iff.
auto. }
mapped blocks
{
intros b2 b3 delta INJ23.
destruct (
inj mu23 b2)
eqn:
INJ23';
inv INJ23.
exploit Bset.inj_dom'.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
eauto.
erewrite <-
mu_Shared2_equiv;
eauto.
intro SHARED2.
exploit Bset.inj_range;
eauto.
eapply Bset.inj_weak,
mu_inject_12;
eauto.
eauto.
intros [
b1 INJ12].
eapply Mem.mi_mappedblocks;
eauto.
unfold Bset.inj_to_meminj.
erewrite mu_inj_comp;
eauto.
rewrite INJ12,
INJ23';
eauto. }
no overlap
{
unfold Mem.meminj_no_overlap.
intros.
destruct (
inj mu23 b1)
eqn:
INJ1;
inv H0.
destruct (
inj mu23 b2)
eqn:
INJ2;
inv H1.
left.
intro.
apply H.
subst.
eapply Bset.inj_injective;
eauto.
eapply mu_inject_23;
eauto. }
representable
{
intros.
destruct (
inj mu23 b)
eqn:
INJ23;
inv H.
split;[
xomega|].
pose proof (
Ptrofs.unsigned_range ofs).
unfold Ptrofs.max_unsigned.
omega. }
perm inv
{
unfold Mem.perm,
Mem.perm_order';
simpl.
intros.
destruct (
inj mu23 b1)
eqn:
INJ23;
inv H.
rewrite Z.add_0_r in H0.
exploit Bset.inj_dom';
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
intro SHARED2.
exploit (
FINITE2 b1).
erewrite mu_Shared2_equiv;
eauto.
auto.
intro BOUND.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H.
rewrite H1.
unfold update_access_func.
destruct plt;
try contradiction.
rewrite INJ23.
auto. }
RELY2
unfold update_memory.
constructor;
simpl.
nextblock
subst bound2.
apply Pos.max_id.
local unchg
constructor;
simpl.
{
subst bound2.
rewrite Pos.max_id.
auto with coqlib. }
{
unfold Mem.perm.
simpl.
intros.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H1.
rewrite H2.
unfold update_access_func.
destruct plt;
try contradiction.
destruct (
inj mu23 b)
eqn:
INJ23; [|
tauto].
exfalso.
apply H.
eapply Bset.inj_dom';
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto. }
{
intros.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H1.
rewrite H2.
unfold inject_content.
destruct plt;
auto.
destruct (
inj mu23 b)
eqn:
INJ23;
auto.
exfalso.
apply H.
eapply Bset.inj_dom';
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto. }
rc
constructor;
simpl.
reachable
{
intros.
inv H.
revert b H0.
induction L;
intros b REACH;
inv REACH.
auto.
apply IHL in H1.
clear IHL.
unfold Mem.perm in H2.
simpl in *.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H.
rewrite H0 in H2.
unfold update_access_func in H2.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H3.
rewrite H5 in H4.
unfold inject_content in H4.
exploit Bset.inj_dom;
try exact H1.
eapply mu_inject_23;
eauto.
intros [
b'3
INJ23].
rewrite INJ23 in H2,
H4.
destruct (
proj2_sig (
inject_zmap_memval_c j32 (
Mem.mem_contents m3') !!
b'3)).
destruct plt.
rewrite H7 in H4.
unfold inject_zmap_memval,
inject_memval in H4.
destruct (
ZMap.get z (
Mem.mem_contents m3') !!
b'3)
eqn:
CONTENT3;
inv H4.
destruct v;
inv H9.
destruct (
j32 b0)
eqn:
J32;
inv H8.
apply CONSIST23 in J32.
eapply Bset.inj_dom'.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
eauto.
exfalso.
apply n0.
apply FINITE2.
erewrite mu_Shared2_equiv;
eauto. }
no undef
{
intros until z.
unfold Mem.perm.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H as [
_ H].
rewrite H.
unfold update_access_func.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H0 as [
_ H0].
rewrite H0.
unfold inject_content.
intros SHARED2.
exploit Bset.inj_dom.
eapply mu_inject_23;
eauto.
eauto.
intros [
b3 INJ23].
exploit Bset.inj_range'.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
eauto.
intros SHARED3.
destruct plt.
rewrite INJ23.
destruct (
proj2_sig (
inject_zmap_memval_c j32 (
Mem.mem_contents m3') !!
b3))
as [
_ H1].
rewrite H1.
unfold inject_zmap_memval,
inject_memval.
intros PERM3 UNDEF.
destruct (
ZMap.get z (
Mem.mem_contents m3') !!
b3)
eqn:
CONTENT3;
try discriminate.
exploit no_undef.
exact RC3.
erewrite <-
mu_Shared3_equiv;
eauto.
eauto.
auto.
auto.
exfalso.
apply n,
FINITE2.
erewrite mu_Shared2_equiv;
eauto. }
no vundef
{
intros until n.
unfold Mem.perm.
pose proof (
proj2_sig (
update_access_c (
inj mu23)
bound2 (
Mem.mem_access m2) (
Mem.mem_access m3'))).
destruct H as [
_ H].
rewrite H.
unfold update_access_func.
pose proof (
proj2_sig (
inject_content_c (
inj mu23)
j32
bound2 (
Mem.mem_contents m2) (
Mem.mem_contents m3'))).
destruct H0 as [
_ H0].
rewrite H0.
unfold inject_content.
intros SHARED2.
exploit Bset.inj_dom.
eapply mu_inject_23;
eauto.
eauto.
intros [
b3 INJ23].
exploit Bset.inj_range'.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
eauto.
intros SHARED3.
destruct plt.
rewrite INJ23.
destruct (
proj2_sig (
inject_zmap_memval_c j32 (
Mem.mem_contents m3') !!
b3))
as [
_ H1].
rewrite H1.
unfold inject_zmap_memval,
inject_memval.
intros PERM3 UNDEF.
destruct (
ZMap.get z (
Mem.mem_contents m3') !!
b3)
eqn:
CONTENT3;
try discriminate.
inv UNDEF.
destruct v;
inv H3.
exploit no_vundef.
exact RC3.
erewrite <-
mu_Shared3_equiv;
eauto.
eauto.
eauto.
auto.
destruct (
j32 b0)
eqn:
SHARED0;
inv H4.
exploit reachable_closure.
exact RC3.
instantiate (1:=
b0).
econstructor.
instantiate (1:= (
b3,
i)::
nil).
econstructor.
constructor.
eapply Bset.inj_range';
eauto.
erewrite <-
mu_Shared3_equiv;
eauto.
eapply Bset.inj_weak,
mu_inject_23;
eauto.
eauto.
eauto.
intro SHARED0'.
eapply Bset.inj_range in SHARED0';
eauto.
destruct SHARED0'.
rewrite CONSIST23 in H2.
rewrite H2 in SHARED0.
discriminate.
erewrite <-
mu_Shared3_equiv;
eauto.
eapply mu_inject_23;
eauto.
exfalso.
apply n0,
FINITE2.
erewrite mu_Shared2_equiv;
eauto. }
Qed.
'.
Proof.
''.
Proof.
'))).
Proof.
.
Proof.
.
Proof.
.
Proof.