Require Import Coqlib FMemory GMemory Footprint FMemLemmas DetLemma InteractionSemantics CminorLang.
Lemma embed_eq:
forall fm m,
embed (
strip fm) (
Mem.freelist fm)
m ->
m =
fm.
Proof.
destruct fm,
m;
intro;
inv H.
unfold strip in *;
simpl in *.
inv H1.
assert (
nextblockid =
nextblockid0).
{
generalize valid_wd valid_wd0.
clear.
intros.
destruct (
Nat.lt_total nextblockid nextblockid0).
eapply valid_wd0 in H;
eauto.
eapply valid_wd in H;
eauto.
omega.
destruct H.
auto.
eapply valid_wd in H;
eauto.
eapply valid_wd0 in H;
eauto.
omega.
}
subst.
f_equal;
apply Axioms.proof_irr.
Qed.
Section EVALDET.
Lemma eval_expr_det:
forall ge sp e m a v,
eval_expr ge sp e m a v ->
forall v',
eval_expr ge sp e m a v' ->
v =
v'.
Proof.
induction 1; intros v' EVAL; inv EVAL; try congruence.
apply IHeval_expr in H3. subst. congruence.
apply IHeval_expr1 in H5. apply IHeval_expr2 in H7. subst. congruence.
apply IHeval_expr in H3. subst. congruence.
Qed.
Lemma eval_expr_fp_det:
forall ge sp e m a v,
eval_expr_fp ge sp e m a v ->
forall v',
eval_expr_fp ge sp e m a v' ->
v =
v'.
Proof.
induction 1;
intros v'
EVAL;
inv EVAL;
try congruence.
apply IHeval_expr_fp in H5.
subst.
congruence.
apply IHeval_expr_fp1 in H10.
apply IHeval_expr_fp2 in H12.
subst.
eapply eval_expr_det in H1;
eauto.
subst.
eapply eval_expr_det in H;
eauto.
subst.
rewrite H4 in H15.
inv H15.
congruence.
apply IHeval_expr_fp in H7.
subst.
eapply eval_expr_det in H;
eauto.
subst.
rewrite H1 in H8;
inv H8.
congruence.
Qed.
Lemma eval_exprlist_det:
forall ge sp e m al vl,
eval_exprlist ge sp e m al vl ->
forall vl',
eval_exprlist ge sp e m al vl' ->
vl =
vl'.
Proof.
induction al;
intros vl1 EVAL1 vl2 EVAL2;
inv EVAL1;
inv EVAL2;
auto.
eapply IHal in H3;
eauto.
subst.
exploit eval_expr_det.
exact H1.
exact H2.
intro.
subst.
auto.
Qed.
Lemma eval_exprlist_fp_det:
forall ge sp e m al vl,
eval_exprlist_fp ge sp e m al vl ->
forall vl',
eval_exprlist_fp ge sp e m al vl' ->
vl =
vl'.
Proof.
induction al;
intros vl1 EVAL1 vl2 EVAL2;
inv EVAL1;
inv EVAL2;
auto.
eapply IHal in H4;
eauto.
subst.
exploit eval_expr_det.
exact H1.
exact H5.
intro.
subst.
auto.
f_equal.
eapply eval_expr_fp_det;
eauto.
Qed.
End EVALDET.
Local Ltac solv_eq:=
match goal with
| [
H1: ?
P ,
H2 : ?
P |-
_] =>
clear H1
| [
H1: ?
P =
_,
H2: ?
P =
_ |-
_] =>
rewrite H1 in H2;
inv H2
| [
H1: ?
P =
_ ,
H2:
_ = ?
P |-
_] =>
rewrite H1 in H2;
inv H2
end
.
Local Ltac eval_det:=
repeat match goal with
|
H1:
eval_expr ?
a ?
b ?
c ?
d ?
e _,
H2:
eval_expr ?
a ?
b ?
c ?
d ?
e _ |-
_ =>
eapply eval_expr_det in H1;
try apply H2;
subst
|
H1:
eval_expr_fp ?
a ?
b ?
c ?
d ?
e _,
H2:
eval_expr_fp ?
a ?
b ?
c ?
d ?
e _ |-
_ =>
eapply eval_expr_fp_det in H1;
try apply H2;
subst
|
H1:
eval_exprlist ?
a ?
b ?
c ?
d ?
e _,
H2:
eval_exprlist ?
a ?
b ?
c ?
d ?
e _ |-
_ =>
eapply eval_exprlist_det in H1;
try apply H2;
subst
|
H1:
eval_exprlist_fp ?
a ?
b ?
c ?
d ?
e _,
H2:
eval_exprlist_fp ?
a ?
b ?
c ?
d ?
e _ |-
_ =>
eapply eval_exprlist_fp_det in H1;
try apply H2;
subst
end.
Local Ltac inv_eq:=
repeat (
try match goal with
|
H:?
P ,
H1: ?
P |-
_ =>
clear H
|
H:
Cminor.funsig _ |-
_ =>
unfold Cminor.funsig in H
|
H:
context[
match ?
x with _ =>
_ end] |-
_ =>
destruct x eqn:?;
try (
inversion H;
fail)
|
H:
false =
true |-
_ =>
inv H
|
H:
true =
false |-
_ =>
inv H
|
H:
None =
Some _ |-
_=>
inv H
|
H:
Some _ =
Some _ |-
_ =>
inv H
|
H:
Some _ =
None |-
_=>
inv H
|
H:
Values.Val.bool_of_val _ _ |-
_ =>
inv H
|
H:
Switch.switch_argument _ _ _ |-
_ =>
inv H
|
H:?
P = ?
Q,
H1:
context [ ?
P ] |-
_ =>
rewrite H in H1
|
H:?
P = ?
Q |-
context [ ?
P ] =>
rewrite H
end;
try eval_det;
simpl in *;
subst;
try contradiction).
Section DET.
Lemma Cminor_det:
lang_det CminorLang.
Proof.
unfold lang_det,
step_det;
intros.
inversion H;
subst.
inversion H0;
subst.
inv H1.
apply embed_eq in H3.
subst.
inv H2;
inv H4;
try solv_eq;
try(
Esimpl;
eauto;
fail);
try(
match goal with H:
Cminor.is_call_cont _ |-
_ =>
inv H end);
try(
inv_eq;
Esimpl;
eauto;
fail).
Qed.
End DET.
Local Ltac emp_eff:=
try (
unfold FP.emp,
effects;
simpl;
repeat rewrite Locs.emp_union_locs;
repeat rewrite Locs.locs_union_emp;
apply Locs.eq_refl).
Lemma Cminor_eff:
corestep_local_eff (
InteractionSemantics.step CminorLang).
Proof.
Lemma eval_binop_fp_empeff:
forall b v1 v2 m fp,
eval_binop_fp b v1 v2 m =
Some fp ->
Locs.eq (
effects fp)
Locs.emp.
Proof.
Lemma eval_expr_fp_empeff:
forall ge sp e m a fp,
eval_expr_fp ge sp e m a fp ->
Locs.eq (
effects fp)
Locs.emp.
Proof.
Lemma MemPre_weak_valid_pointer_fp_eq:
forall m b i m'
fp,
FMemOpFP.weak_valid_pointer_fp m b i =
fp ->
MemPre (
strip m) (
strip m')
fp ->
FMemOpFP.weak_valid_pointer_fp m'
b i =
fp.
Proof.
Lemma MemPre_eval_binop_eq:
forall b v1 v2 m v fp m',
MemPre (
strip m)(
strip m')
fp ->
eval_binop b v1 v2 m =
Some v->
eval_binop_fp b v1 v2 m =
Some fp ->
eval_binop b v1 v2 m' =
Some v /\
eval_binop_fp b v1 v2 m' =
Some fp.
Proof.
Lemma MemPre_eval_expr_eq:
forall a ge sp e m v fp m',
MemPre (
strip m)(
strip m')
fp->
FreelistEq (
strip m)(
strip m')(
Mem.freelist m)->
eval_expr ge sp e m a v ->
eval_expr_fp ge sp e m a fp->
eval_expr ge sp e m'
a v /\
eval_expr_fp ge sp e m'
a fp .
Proof.
Lemma MemPre_eval_exprlist_eq:
forall a ge sp e m v fp m',
MemPre (
strip m)(
strip m')
fp->
FreelistEq (
strip m)(
strip m')(
Mem.freelist m)->
eval_exprlist ge sp e m a v ->
eval_exprlist_fp ge sp e m a fp->
eval_exprlist ge sp e m'
a v /\
eval_exprlist_fp ge sp e m'
a fp .
Proof.
induction a;
intros;
inv H1;
inv H2;
try solv_eq;
inv_eq.
split;
econstructor;
eauto.
apply MemPre_split in H as [].
eapply MemPre_eval_expr_eq in H4 as [];
try apply H6;
eauto.
eapply IHa in H0 as ?;
eauto.
Hsimpl.
split;
econstructor;
eauto.
Qed.
Lemma eval_exprlist_fp_empeff:
forall ge sp e m a fp,
eval_exprlist_fp ge sp e m a fp ->
Locs.eq (
effects fp)
Locs.emp.
Proof.
Lemma Cminor_loc1:
corestep_locality_1 (
InteractionSemantics.step CminorLang).
Proof.
Theorem Cminor_wd:
wd CminorLang.CminorLang.
Proof.