.
.
.
.
).
The following property is needed by Unusedglobproof, to prove
injection between the initial memory states.
.
The transformed program is obtained from the original program
by keeping only the global definitions that belong to a given
set u of names.
.
Proof.
).
Proof.
Monotonic evolution of the workset.
.
Proof.
.
Proof.
.
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
).
Proof.
Correctness of the dependency graph traversal.
.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
Properties of the elimination of unused global definitions.
.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
).
Proof.
)).
Proof.
.
Proof.
.
.
.
)}.
.
.
.
.
.
.
.
'.
Proof.
).
Proof.
.
Proof.
'.
Proof.
'.
Proof.
Injections that preserve used globals.
', 0).
Proof.
'.
Proof.
.
Proof.
.
Proof.
).
Proof.
.
Proof.
').
Proof.
').
Proof.
'.
Proof.
).
Proof.
).
Proof.
.
Proof.
.
Proof.
'.
Proof.
).
Proof.
'.
Proof.
'.
Proof.
'.
Proof.
'.
Proof.
.
Proof.
'.
Proof.
.
Proof.
.
.
).
Proof.
.
Proof.
.
Proof.
apply Mem.zero_delta_inject.
-
intros b1 b2 delta H.
apply init_meminj_invert in H.
destruct H;
auto.
-
intros b1 b2 H.
apply init_meminj_invert in H.
destruct H as (
_ &
id &
Hsymb &
Htsymb).
split;
eapply Genv.find_symbol_not_fresh;
eauto.
-
intros b1 []
H.
apply init_meminj_invert in H.
destruct H as (
_ &
id1 &
Hid1 &
Htid1).
intros b2 H.
apply init_meminj_invert in H.
destruct H as (
_ &
id2 &
Hid2 &
Htid2).
cut (
id1 =
id2); [
congruence | ].
eapply Senv.find_symbol_injective with (
t :=
Genv.to_senv tge);
eauto.
-
intros b1 b2 H o k p0 H0.
apply init_meminj_invert_strong in H.
destruct H as (
_ &
id &
Hid &
Htid &
Htdef).
destruct (
Genv.find_def ge b1)
as [
def | ]
eqn:
DEF.
*
specialize (
Htdef _ (
eq_refl _)).
destruct Htdef as (
Htdef &
_).
exploit (
Genv.init_mem_characterization_gen p);
eauto.
exploit (
Genv.init_mem_characterization_gen tp);
eauto.
destruct def as [
f|
v].
+
destruct 1
as (
Htperm &
Htperm_impl) .
destruct 1
as (
Hperm &
Hperm_impl).
apply Hperm_impl in H0.
destruct H0;
subst.
apply Mem.perm_cur;
auto.
+
destruct 1
as (
Htperm &
Htperm_impl &
_).
destruct 1
as (
Hperm &
Hperm_impl &
_).
apply Hperm_impl in H0.
destruct H0 as (
LE &
ORD).
eapply Htperm in LE.
apply Mem.perm_cur;
auto.
eapply Mem.perm_implies;
eauto.
*
exploit (
Genv.init_mem_characterization_gen_strong p);
eauto.
intros [
GINIT _].
edestruct GINIT;
eauto.
-
intros b1 b2 H o k p0 H0.
apply init_meminj_invert_strong in H.
destruct H as (
_ &
id &
Hid &
Htid &
Htdef).
destruct (
Genv.find_def ge b1)
as [
def | ]
eqn:
DEF.
*
specialize (
Htdef _ (
eq_refl _)).
destruct Htdef as (
Htdef &
_).
exploit (
Genv.init_mem_characterization_gen p);
eauto.
exploit (
Genv.init_mem_characterization_gen tp);
eauto.
destruct def as [
f|
v].
+
destruct 1
as (
Htperm &
Htperm_impl).
destruct 1
as (
Hperm &
Hperm_impl).
apply Htperm_impl in H0.
destruct H0;
subst.
left.
apply Mem.perm_cur;
auto.
+
destruct 1
as (
Htperm &
Htperm_impl &
_).
destruct 1
as (
Hperm &
Hperm_impl &
_).
apply Htperm_impl in H0.
destruct H0 as (
LE &
ORD).
eapply Hperm in LE.
left.
apply Mem.perm_cur;
auto.
eapply Mem.perm_implies;
eauto.
*
exploit (
Genv.init_mem_characterization_gen_strong p);
eauto.
intros [
GINIT _].
right;
eauto.
-
intros b1 b2 H o v1 H0.
apply init_meminj_invert_strong in H.
destruct H as (
_ &
id &
Hid &
Htid &
Htdef).
destruct (
Genv.find_def ge b1)
as [
def | ]
eqn:
DEF.
*
specialize (
Htdef _ (
eq_refl _)).
destruct Htdef as (
Htdef &
Hkept).
exploit (
Genv.init_mem_characterization_gen p);
eauto.
exploit (
Genv.init_mem_characterization_gen tp);
eauto.
destruct def as [
f|
v].
+
intros _.
destruct 1
as (
_ &
Hperm).
exfalso.
apply Mem.loadbytes_range_perm in H0.
assert (
o <=
o <
o + 1)
as Hrange by omega.
apply H0 in Hrange.
apply Hperm in Hrange.
destruct Hrange;
discriminate.
+
destruct 1
as (
_ &
_&
_ &
TREAD).
destruct 1
as (
_ &
Hperm &
_ &
READ).
generalize H0.
intro H0_.
apply Mem.loadbytes_range_perm in H0.
assert (
o <=
o <
o + 1)
as Hrange by omega.
apply H0 in Hrange.
apply Hperm in Hrange.
destruct Hrange as (
LE &
Hrange).
assert (
NO:
gvar_volatile v =
false).
{
unfold Genv.perm_globvar in Hrange.
destruct (
gvar_volatile v);
auto.
inv Hrange. }
specialize (
READ NO).
specialize (
TREAD NO).
apply bytes_of_init_inject in Hkept.
replace (
init_data_list_size (
gvar_init v))
with
(
o + (
init_data_list_size (
gvar_init v) -
o))
in READ,
TREAD
by omega.
apply Mem.loadbytes_split in READ;
try omega.
destruct READ as (
b1l &
b1r &
Hb1l &
Hb1r &
EQ1).
apply Mem.loadbytes_split in TREAD;
try omega.
destruct TREAD as (
b2l &
b2r &
Hb2l &
Hb2r &
EQ2).
apply Mem.loadbytes_length in Hb1l.
apply Mem.loadbytes_length in Hb2l.
fold ge in EQ1.
rewrite EQ1 in Hkept.
fold tge in EQ2.
rewrite EQ2 in Hkept.
apply list_forall2_same_prefix_length in Hkept;
try congruence.
destruct Hkept as (
_ &
Hkept).
rewrite Z.add_0_l in Hb1r,
Hb2r.
replace (
init_data_list_size (
gvar_init v) -
o)
with (1 + (
init_data_list_size (
gvar_init v) - 1 -
o))
in Hb1r,
Hb2r
by omega.
apply Mem.loadbytes_split in Hb1r;
try omega.
destruct Hb1r as (
h1 &
t1 &
LOAD1 &
_ & ?);
subst.
apply Mem.loadbytes_split in Hb2r;
try omega.
destruct Hb2r as (
h2 &
t2 &
LOAD2 &
_ & ?);
subst.
rewrite H0_ in LOAD1.
inversion LOAD1;
clear LOAD1;
subst.
generalize LOAD2.
intro LOAD2_.
apply Mem.loadbytes_length in LOAD2_.
destruct h2 as [ | ? [ | ] ] ;
try discriminate.
inversion Hkept;
subst.
eauto.
*
apply Mem.loadbytes_range_perm in H0.
exploit (
Genv.init_mem_characterization_gen_strong p);
eauto.
intros [
GINIT _].
edestruct GINIT;
eauto.
eapply H0.
instantiate (1 :=
o);
omega.
-
repeat rewrite_stack_blocks.
unfold flat_frameinj;
simpl.
apply stack_inject_nil.
destruct gd as [f|v].
+ intros (P2 & Q2) (P1 & Q1).
apply Q1 in H0. destruct H0; discriminate.
+ intros (P2 & Q2 & R2 & S2) (P1 & Q1 & R1 & S1).
apply Q1 in H0. destruct H0.
assert (NO: gvar_volatile v = false).
{ unfold Genv.perm_globvar in H1. destruct (gvar_volatile v); auto. inv H1. }
Local Transparent Mem.loadbytes.
generalize (S1 NO). unfold Mem.loadbytes. destruct Mem.range_perm_dec; intros E1; inv E1.
generalize (S2 NO). unfold Mem.loadbytes. destruct Mem.range_perm_dec; intros E2; inv E2.
rewrite Zplus_0_r.
apply Mem_getN_forall2 with (p := 0) (n := nat_of_Z (init_data_list_size (gvar_init v))).
rewrite H3, H4. apply bytes_of_init_inject. auto.
omega.
rewrite nat_of_Z_eq by (apply init_data_list_size_pos). omega.
Qed.
Lemma init_mem_inj_2:
Mem.inject init_meminj m tm.
Proof.
constructor; intros.
- apply init_mem_inj_1.
- destruct (init_meminj b) as [[b' delta]|] eqn:INJ; auto.
elim H. exploit init_meminj_invert; eauto. intros (A & id & B & C).
eapply Genv.find_symbol_not_fresh; eauto.
- exploit init_meminj_invert; eauto. intros (A & id & B & C).
eapply Genv.find_symbol_not_fresh; eauto.
- red; intros.
exploit init_meminj_invert. eexact H0. intros (A1 & id1 & B1 & C1).
exploit init_meminj_invert. eexact H1. intros (A2 & id2 & B2 & C2).
destruct (ident_eq id1 id2). congruence. left; eapply Genv.global_addresses_distinct; eauto.
- exploit init_meminj_invert; eauto. intros (A & id & B & C). subst delta.
split. omega. generalize (Ptrofs.unsigned_range_2 ofs). omega.
- exploit init_meminj_invert_strong; eauto. intros (A & id & gd & B & C & D & E & F).
exploit (Genv.init_mem_characterization_gen p); eauto.
exploit (Genv.init_mem_characterization_gen tp); eauto.
destruct gd as [f|v].
+ intros (P2 & Q2) (P1 & Q1).
apply Q2 in H0. destruct H0. subst. replace ofs with 0 by omega.
left; apply Mem.perm_cur; auto.
+ intros (P2 & Q2 & R2 & S2) (P1 & Q1 & R1 & S1).
apply Q2 in H0. destruct H0. subst.
left. apply Mem.perm_cur. eapply Mem.perm_implies; eauto.
apply P1. omega.
*)Qed.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
.
Proof.
).
Proof.
).
Proof.
.
.
Proof.
.
Proof.
).
Proof.
.
Proof.
.