.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
).
.
.
Proof.
.
.
.
Proof.
.
Proof.
.
Proof.
'2.
Proof.
).
Proof.
assert (
sm_obj0 :
env ! (
OldVar ovObj) =
Some (
Ptr _ _ (
Some (
bl,
off)))).
rewrite <-
sm_obj.
eapply sm_other.
assumption.
intros;
congruence.
assert (
sm_vtt0 :
env ! (
OldVar ovVTT) =
Some (
VTTptr (
romty :=
romty A)
_ _ (
hyperreal, (
hr,
pr)))).
rewrite <-
sm_vtt.
eapply sm_other.
assumption.
intros;
congruence.
unfold compile_set_vptr.
functional inversion Hoff.
subst off.
generalize Hoz.
unfold relative_pointer_offset.
rewrite H0.
rewrite H1.
case_eq (
subobject_offset offsets hyperreal p');
try congruence.
intros until 1.
injection 1;
intro;
subst oz.
functional inversion H.
subst l p'.
inversion Hptr.
inversion Hinv.
assert (
Hdyn :
is_dynamic hierarchy real)
by eauto using is_dynamic_path,
path_concat.
generalize (
sm_vptr0 Hdyn).
clear sm_vptr0.
intro sm_vptr0.
case_eq (
compile_set_vptr_case h ismostderived).
intros.
assert ((
hr,
pr) = (
Class.Inheritance.Repeated,
hyperreal ::
nil) \/
h =
Class.Inheritance.Repeated).
functional inversion H10;
auto.
destruct H11.
subobject of the true most-derived object
injection H11;
intros;
subst hr pr.
generalize (
path_last H9).
injection 1;
intro;
subst real.
erewrite concat_trivial_left in Hhp'.
2 :
eassumption.
injection Hhp';
intros;
subst h p.
rewrite H.
unfold subobject_offset in H2.
rewrite H4 in H2.
rewrite (
virtual_base_offsets_self (
intro H4))
in H2.
simpl in H2.
injection H2;
intro;
subst z2.
assert (
valid_relative_pointer (
A:=
A)
hierarchy afrom zfrom ar hyperreal i
h' (
b ::
_x)
to
).
econstructor.
eassumption.
assumption.
assumption.
assumption.
assert (
offsets !
to <>
None)
by eauto using path_defined_to.
destruct (
dynamic_align Hhier intro H16 Hoz Hoa H17 Hto).
case_eq (
offsets !
to);
try congruence.
intros.
generalize (
own_fields_offset_dynamic_low_bound (
intro H20)
Hto).
simpl.
intro.
generalize (
non_virtual_data_size_own_fields_offset (
intro H20)).
intro.
destruct (
relative_pointer_data_incl intro H16 (
dynamic_nonempty (
c :=
COP)
Hto)
Hoz).
generalize (
H24 _ Hoa _ H20).
intro.
generalize (
data_size_high_bound (
intro Hoa)).
intro.
assert ((
zfrom - 1) *
size oa +
size oa =
zfrom *
size oa)
by ring.
simpl in H18,
H19.
refine (
_ (
Memory.store_some (
mv := (
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
Class.Inheritance.Repeated,
hyperreal ::
nil),
(
h',
b ::
_x)))
)
memprop H19 Hbl_valid _ _ (
memv :=
mva))).
2 :
omega.
2 :
simpl.
2 :
unfold valdata.
2 :
unfold type_of_value.
2 :
omega.
case_eq (
Memory.store memop
(
Memory.valsize (
valop (
A:=
A) (
romty A)
mblock vop')
(
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
Class.Inheritance.Repeated,
hyperreal ::
nil),
(
h',
b ::
_x))))
mbl mva (
bl,
z1 +
i *
size ofto +
z)
(
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
Class.Inheritance.Repeated,
hyperreal ::
nil),
(
h',
b ::
_x)))
).
2 :
congruence.
intros until 1.
intros _.
esplit.
esplit.
split.
eright.
econstructor.
eright.
econstructor.
eauto.
rewrite sm_vtt0.
econstructor.
rewrite Hprog.
simpl.
eapply map_all_pvtt_complete.
eassumption.
eauto using is_dynamic_path.
rewrite Hprog.
Opaque pvtables.
simpl.
eapply pvtables_complete.
eassumption.
2 :
eassumption.
assumption.
assumption.
rewrite Hprog.
reflexivity.
reflexivity.
eright.
econstructor.
eright.
econstructor.
rewrite PTree.gso.
eassumption.
congruence.
rewrite PTree.gss.
reflexivity.
reflexivity.
replace (
z1 +
i *
size ofto + 0 +
z
)
with (
z1 +
i *
size ofto +
z
)
by omega.
eassumption.
eleft.
reflexivity.
reflexivity.
reflexivity.
repeat rewrite E0_left;
eauto using evtr_sem.
split.
split.
rewrite PTree.gso.
subst hr.
subst pr.
subst real.
auto.
intro.
injection H29.
intro.
generalize (
Plt_succ nvcap).
rewrite H30 at 1.
apply Plt_irrefl.
intros.
rewrite PTree.gso.
eauto.
destruct v;
try congruence.
intro.
generalize (
H29 _ H30).
intro.
destruct (
Plt_irrefl _ (
Plt_trans _ _ _ (
Plt_succ _)
H31)).
split.
erewrite Memory.load_store_same.
reflexivity.
eassumption.
eassumption.
intros.
eapply Memory.load_store_other.
eassumption.
eassumption.
simpl.
unfold valdata.
unfold type_of_value.
tauto.
non-virtual subobject
subst h.
inversion Hp.
rewrite H11 in *.
subst from.
unfold subobject_offset at 1.
assert (
offsets !
real <>
None)
by eauto using path_defined_from.
case_eq (
offsets !
real);
try congruence.
intros.
rewrite (
virtual_base_offsets_self (
intro H15)).
generalize Hhp'.
intro.
simpl in Hhp'0.
rewrite (
path_last H9)
in Hhp'0.
destruct (
peq real real);
try congruence.
injection Hhp'0.
intros.
subst h'.
destruct (
LibLists.last_correct (
path_last H9)).
subst pr.
rewrite app_ass in H16.
simpl in H16.
rewrite H16 in H3.
generalize (
non_virtual_subobject_offset_app_recip H3).
destruct 1.
destruct H17.
rewrite (
non_virtual_subobject_offset_rewrite H18).
assert (
valid_relative_pointer (
A:=
A)
hierarchy afrom zfrom ar hyperreal i hr
(
b ::
_x)
to
).
econstructor.
eassumption.
assumption.
assumption.
eapply path_concat.
eassumption.
eassumption.
assumption.
assert (
offsets !
to <>
None)
by eauto using path_defined_to.
destruct (
dynamic_align Hhier intro H19 Hoz Hoa H20 Hto).
simpl in H21,
H22.
case_eq (
offsets !
to);
try congruence.
intros.
generalize (
own_fields_offset_dynamic_low_bound (
intro H23)
Hto).
simpl.
intro.
generalize (
non_virtual_data_size_own_fields_offset (
intro H23)).
intro.
destruct (
relative_pointer_data_incl intro H19 (
dynamic_nonempty (
c :=
COP)
Hto)
Hoz).
generalize (
H27 _ Hoa _ H23).
intro.
generalize (
data_size_high_bound (
intro Hoa)).
intro.
assert ((
zfrom - 1) *
size oa +
size oa =
zfrom *
size oa)
by ring.
refine (
_ (
Memory.store_some (
mv := (
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
hr,
x ++
real ::
nil),
(
Class.Inheritance.Repeated,
real ::
lf))))
memprop _ Hbl_valid _ _ (
memv :=
mva))).
2 :
eassumption.
2 :
omega.
2 :
simpl.
2 :
unfold valdata.
2 :
unfold type_of_value.
2 :
omega.
case_eq (
Memory.store memop
(
Memory.valsize (
valop (
A:=
A) (
romty A)
mblock vop')
(
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
hr,
x ++
real ::
nil),
(
Class.Inheritance.Repeated,
real ::
lf))))
mbl mva
(
bl,
z1 +
i *
size ofto +
z)
(
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
hr,
x ++
real ::
nil),
(
Class.Inheritance.Repeated,
real ::
lf)))
);
try congruence.
intros until 1.
intros _.
functional inversion H2.
assert (
b0 =
b).
destruct x;
simpl in *;
congruence.
subst b0.
replace o0 with ofto in *
by congruence.
replace o with ofto in *
by congruence.
replace of0 with of in *
by congruence.
replace x0 with z2 in *
by congruence.
esplit.
esplit.
split.
eright.
econstructor.
eright.
econstructor.
eauto.
rewrite sm_vtt0.
econstructor.
rewrite Hprog.
simpl.
eapply map_all_pvtt_complete.
eassumption.
eauto using is_dynamic_path.
rewrite Hprog.
simpl.
eapply pvtables_complete.
eassumption.
2 :
eassumption.
eassumption.
assumption.
rewrite Hprog.
simpl.
eapply LibLists.last_complete.
reflexivity.
eright.
econstructor.
eright.
econstructor.
rewrite PTree.gso.
eassumption.
congruence.
rewrite PTree.gss.
reflexivity.
reflexivity.
replace (
z1 +
i *
size ofto +
z2 + (
z + 0 -
z2)
)
with (
z1 +
i *
size ofto +
z
)
by omega.
eassumption.
eleft.
reflexivity.
reflexivity.
reflexivity.
repeat rewrite E0_left;
eauto using evtr_sem.
split.
split.
rewrite PTree.gso.
rewrite sm_vptr0.
rewrite e0.
reflexivity.
intro.
injection H37.
intro.
generalize (
Plt_succ nvcap).
rewrite H38 at 1.
apply Plt_irrefl.
intros.
rewrite PTree.gso.
eauto.
destruct v;
try congruence.
intro.
generalize (
H37 _ H38).
intro.
destruct (
Plt_irrefl _ (
Plt_trans _ _ _ (
Plt_succ _)
H39)).
split.
erewrite Memory.load_store_same.
reflexivity.
eassumption.
rewrite H32.
eassumption.
intros.
eapply Memory.load_store_other.
eassumption.
eassumption.
simpl.
unfold valdata.
unfold type_of_value.
tauto.
virtual subobject: read into the VTable
functional inversion 1.
destruct h;
try contradiction.
generalize Hhp'.
simpl.
injection 1;
intros.
rewrite <-
H16.
rewrite (
non_virtual_subobject_offset_rewrite H3).
assert (
path hierarchy real (
real ::
nil)
real Class.Inheritance.Repeated
).
eleft with (
lt:=
nil).
reflexivity.
reflexivity.
simpl.
case_eq (
hierarchy !
real);
auto.
generalize (
path_defined_to H9).
intros;
contradiction.
generalize (
concat_trivial_right H9).
intro.
symmetry in H19.
generalize (
path_path1 Hp).
rewrite <-
H16.
inversion 1;
subst.
inversion H22;
subst.
injection H11;
intros;
subst.
destruct (
vboffsets_l_complete Hhier
intro exis H9 H18 H19 H2 H21).
destruct H15.
destruct H16.
destruct H16.
replace x with o in *
by congruence.
replace o with ofto in *
by congruence.
replace x0 with of in *
by congruence.
case_eq (
Zsem sem (
of -
z2)).
intros.
assert (
offsets !
to <>
None)
by eauto using path_defined_to.
assert (
valid_relative_pointer hierarchy afrom zfrom ar hyperreal i Class.Inheritance.Shared (
base ::
lf)
to).
econstructor.
eassumption.
assumption.
assumption.
eapply path_concat.
eassumption.
eassumption.
reflexivity.
destruct (
dynamic_align Hhier intro H25 Hoz Hoa H24 Hto).
simpl in H26,
H27.
case_eq (
offsets !
to);
try congruence.
intros.
generalize (
own_fields_offset_dynamic_low_bound (
intro H28)
Hto).
simpl.
intro.
generalize (
non_virtual_data_size_own_fields_offset (
intro H28)).
intro.
destruct (
relative_pointer_data_incl intro H25 (
dynamic_nonempty (
c :=
COP)
Hto)
Hoz).
generalize (
H32 _ Hoa _ H28).
intro.
generalize (
data_size_high_bound (
intro Hoa)).
intro.
assert ((
zfrom - 1) *
size oa +
size oa =
zfrom *
size oa)
by ring.
refine (
_ (
Memory.store_some (
val :=
val A (
romty A)
mblock)
(
o :=
memop)
(
v :=
valop (
romty A)
mblock vop')
_
(
i :=
z1 +
i *
size ofto +
z2 + (
of -
z2) + (
z + 0 -
of))
(
mv := (
Vptr A (
romty:=
romty A)
mblock
(
hyperreal, (
hr,
pr), (
Class.Inheritance.Shared,
base ::
lf))))
_
(
memb :=
mbl)
(
b :=
bl)
_
_
_
(
memv :=
mva)
)).
simpl.
unfold valdata.
unfold type_of_value.
simpl.
intro.
match type of x2 with ?
x <>
None =>
case_eq x ;
try congruence end.
clear x2.
intros.
2 :
assumption.
2 :
replace (
z1 +
i *
size ofto +
z2 + (
of -
z2) + (
z + 0 -
of)
)
with (
z1 +
i *
size ofto +
z
)
by omega.
2 :
assumption.
2 :
assumption.
2 :
omega.
2 :
simpl.
2 :
unfold valdata,
type_of_value;
omega.
esplit.
esplit.
split.
eright.
econstructor.
eright.
econstructor.
eauto.
rewrite (
sm_vptr0).
econstructor.
rewrite Hprog.
simpl.
eapply map_all_pvtable_complete.
eassumption.
eleft with (
lt :=
nil).
reflexivity.
reflexivity.
simpl.
case_eq (
hierarchy !
real);
auto.
generalize (
path_defined_to H9).
intros;
contradiction.
rewrite reduce_path_trivial.
reflexivity.
eauto using is_dynamic_path.
rewrite Hprog.
Opaque vboffsets_l.
simpl.
rewrite reduce_path_trivial in H17.
eassumption.
eassumption.
rewrite Hprog.
simpl.
reflexivity.
rewrite Hprog.
simpl.
eapply Relations.Relation_Operators.rt_refl.
rewrite Hprog.
simpl.
unfold vtable_access_VBase.
destruct (
vborder_list_ex Hhier real).
destruct s.
destruct e.
destruct H37.
eauto using virtual_base_vborder_list,
path_is_virtual_base_of.
edestruct (
path_defined_to H9).
assumption.
reflexivity.
eright.
econstructor.
eright.
econstructor.
eright.
econstructor.
rewrite PTree.gso.
eassumption.
congruence.
rewrite PTree.gss.
reflexivity.
eapply Zsem_semZ.
eassumption.
replace (
z1 +
i *
size ofto +
z2 + (
of -
z2) * 1
)
with (
z1 +
i *
size ofto +
z2 + (
of -
z2)
)
by ring.
reflexivity.
eright.
econstructor.
eright.
econstructor.
eright.
econstructor.
rewrite PTree.gso.
rewrite PTree.gso.
eauto.
congruence.
congruence.
rewrite sm_vtt0.
econstructor.
rewrite Hprog.
simpl.
eapply map_all_pvtt_complete.
eassumption.
eauto using is_dynamic_path.
rewrite Hprog.
simpl.
eapply pvtables_complete.
eassumption.
2 :
eassumption.
assumption.
assumption.
rewrite Hprog.
simpl.
eauto using path_last.
reflexivity.
eright.
econstructor.
eright.
econstructor.
rewrite PTree.gso.
rewrite PTree.gss.
reflexivity.
intro.
injection H37.
intro.
generalize (
Plt_succ (
Psucc nvcap)).
rewrite H38.
apply Plt_irrefl.
rewrite PTree.gss.
reflexivity.
reflexivity.
eassumption.
eleft.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
reflexivity.
repeat rewrite E0_left;
eauto using evtr_sem.
split.
split.
rewrite PTree.gso.
rewrite PTree.gso.
rewrite PTree.gso.
auto.
intro.
injection H37.
intro.
destruct (
Plt_irrefl nvcap).
rewrite H38 at 2.
eapply Plt_trans.
eapply Plt_succ.
eapply Plt_succ.
intro.
injection H37.
intro.
destruct (
Plt_irrefl nvcap).
rewrite H38 at 2.
eapply Plt_trans.
eapply Plt_succ.
eapply Plt_succ.
intro.
injection H37.
intro.
destruct (
Plt_irrefl nvcap).
rewrite H38 at 2.
eapply Plt_succ.
intros.
rewrite PTree.gso.
rewrite PTree.gso.
rewrite PTree.gso.
eauto.
destruct v0;
try congruence.
intro.
generalize (
H37 _ H38).
intro.
destruct (
Plt_irrefl nvcap).
eapply Plt_trans.
eapply Plt_succ.
eapply Plt_trans.
eapply Plt_succ.
assumption.
destruct v0;
try congruence.
intro.
generalize (
H37 _ H38).
intro.
destruct (
Plt_irrefl nvcap).
eapply Plt_trans.
eapply Plt_succ.
eapply Plt_trans.
eapply Plt_succ.
assumption.
destruct v0;
try congruence.
intro.
generalize (
H37 _ H38).
intro.
destruct (
Plt_irrefl nvcap).
eapply Plt_trans.
eapply Plt_succ.
assumption.
split.
erewrite Memory.load_store_same.
reflexivity.
eassumption.
replace (
z1 +
i *
size ofto +
z
)
with (
z1 +
i *
size ofto +
z2 + (
of -
z2) + (
z + 0 -
of)
)
by omega.
eassumption.
intros.
eapply Memory.load_store_other.
eassumption.
eassumption.
replace (
z1 +
i *
size ofto +
z2 + (
of -
z2) + (
z + 0 -
of)
)
with (
z1 +
i *
size ofto +
z
)
by omega.
simpl.
tauto.
Qed.
.
Proof.
.
Proof.