Require Import Vbase Varith.
Require Import Relations Classical ClassicalDescription.
Require Import List Permutation Vlistbase Vlist extralib.
Require Import c11 fslassn fslmodel fslassnlemmas.
Require Import fslhmap stepback.
Set Implicit Arguments.
Lemma alloc_always_before:
∀ lab sb rf mo hmap V
(ACYCLIC: IrreflexiveHBuRF sb rf)
(CONS_RF: ConsistentRF_basic lab sb rf mo)
(HC: hist_closed sb rf V)
(VALID: hmap_valids lab sb rf hmap V)
edge (EV: edge_valid lab sb rf edge) (IN: In (hb_fst edge) V)
hf (MAP: hmap edge = Hdef hf) l (ALL: hf l ≠ HVnone)
lbl (LAB: HVlabeled (hf l) lbl),
∃ a, << ALLOC: lab a = Aalloc l >> ∧
((<< LBL: lbl = HLnormal >> ∧ << HB: clos_refl_trans _ (happens_before lab sb rf mo) a (hb_fst edge) >>) ∨
(<< LBL: lbl = HLtriangle >> ∧ ∃ b, << REL: is_release_fence (lab b) >> ∧
<< HB: happens_before lab sb rf mo a b >> ∧
<< SB: clos_refl_trans _ sb b (hb_fst edge) >>) ∨
(<< LBL: lbl = HLnabla >> ∧ << SB: ¬ is_rf edge >>
∧ ∃ b c, << REL: is_release_write (lab b) >> ∧
<< HB: happens_before lab sb rf mo a b >> ∧
<< RF: rf c = Some b >> ∧
<< SB: clos_refl_trans _ sb c (hb_fst edge) >>) ∨
(<< LBL: lbl = HLnabla >> ∧ << SB: ¬ is_rf edge >>
∧ ∃ b c d, << REL: is_release_fence (lab b) >> ∧
<< HB: happens_before lab sb rf mo a b >> ∧
<< SB1: clos_trans _ sb b c >> ∧
<< RF: rf d = Some c >> ∧
<< SB2: clos_refl_trans _ sb d (hb_fst edge) >>) ∨
(<< LBL: lbl = HLnabla >> ∧ << RF: ¬ is_sb edge >> ∧ << REL: is_release_write (lab (hb_fst edge)) >> ∧
<< HB: happens_before lab sb rf mo a (hb_fst edge) >>) ∨
(<< LBL: lbl = HLnabla >> ∧ << RF: ¬ is_sb edge >> ∧ ∃ b, << REL: is_release_fence (lab b) >> ∧
<< HB: happens_before lab sb rf mo a b >> ∧
<< SB: clos_trans _ sb b (hb_fst edge) >>)).
Proof.
intros until hf; revert hf; pattern edge; eapply edge_depth_ind; eauto.
clear edge EV IN; intros.
destruct lbl.
{
exploit step_back_from_normal; eauto.
ins; desf.
× eexists,; eauto.
left; split; vauto.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
eexists,; eauto.
left; split; eauto.
eapply rt_trans; eauto.
apply rt_step; destruct edge´; ins; desf; vauto.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf; try by destruct edge´.
+ eexists,; eauto.
left; split; eauto.
eapply rt_trans.
eby apply rt_step.
apply rt_step, t_step.
right; red.
right; left.
repeat split; eauto.
eexists,; repeat split.
3: by eassumption.
2: by vauto.
eapply rt_trans; eauto.
apply rt_step.
destruct edge´; ins; desf.
+ eexists,; eauto.
left; split; eauto.
eapply rt_trans.
eby apply rt_step.
apply rt_step, t_step.
right; red.
repeat right.
repeat split; eauto.
eexists,,; repeat split.
4: by eassumption.
3: by vauto.
by rewrite clos_refl_transE; eauto.
eapply rt_trans; eauto.
apply rt_step.
destruct edge´; ins; desf.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
+ eexists,; eauto.
left; split; eauto.
eapply rt_trans.
eby apply rt_step.
eapply rt_step, t_step.
right; red.
left; desf; repeat split; ins.
destruct edge´; ins; desf.
eexists,; try eassumption; vauto.
+ eexists,; eauto.
left; split; eauto.
eapply rt_trans.
eby apply rt_step.
eapply rt_step, t_step.
right; red.
do 2 right; left.
repeat split; eauto.
destruct edge´; ins; desf.
eexists,; repeat split; eauto.
by rewrite clos_refl_transE; eauto.
vauto.
}
{
exploit step_back_from_triangle; eauto.
ins; desf.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
eexists,; eauto.
right; left.
split; eauto.
eexists; repeat split; eauto.
eapply rt_trans; eauto.
apply rt_step.
destruct edge´; ins; desf.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
eexists,; eauto.
right; left.
split; eauto.
eexists; repeat split; eauto.
2: by vauto.
apply clos_refl_trans_hbE in HB; desf.
+ eapply t_trans; eauto.
apply t_step; left.
destruct edge´; ins; desf.
+ apply t_step; left.
destruct edge´; ins; desf.
}
{
exploit step_back_from_nabla; eauto.
ins; desf.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf; try by destruct edge´.
+ eexists,; eauto.
do 2 right; left.
repeat split; eauto.
eexists,; repeat split; eauto.
eapply rt_trans; eauto.
apply rt_step.
destruct edge´; ins; desf.
+ eexists,; eauto.
do 3 right; left.
repeat split; eauto.
eexists,,; repeat split; eauto.
eapply rt_trans; eauto.
apply rt_step.
destruct edge´; ins; desf.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
+ eexists,; eauto.
do 2 right; left.
repeat split; eauto.
destruct edge´; ins; desf.
eexists,; repeat split; eauto.
vauto.
+ eexists,; eauto.
do 3 right; left.
repeat split; eauto.
destruct edge´; ins; desf.
eexists,,; repeat split; eauto.
vauto.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
eexists,; eauto.
repeat right.
repeat split; eauto.
eexists; repeat split; eauto.
rewrite clos_refl_transE in SB; desf.
+ destruct edge´; ins; desf; vauto.
+ eapply t_trans; eauto.
destruct edge´; ins; desf; vauto.
× exploit (IH edge´); clear IH; eauto.
by apply t_step; destruct edge´; ins; desf; vauto.
ins; desf.
eexists,; eauto.
do 4 right; left.
repeat split; eauto.
apply clos_refl_trans_hbE in HB; desf.
+ eapply t_trans; eauto.
apply t_step; left.
destruct edge´; ins; desf.
+ apply t_step; left.
destruct edge´; ins; desf.
}
Qed.
Theorem valid_implies_mem_safe :
∀ lab sb rf mo hmap V
(ACYCLIC: IrreflexiveHBuRF sb rf)
(CONS_RF: ConsistentRF_basic lab sb rf mo)
(HC: hist_closed sb rf V)
(VALID: hmap_valids lab sb rf hmap V),
mem_safe V lab sb rf mo.
Proof.
red; ins.
exploit valid_accessD; eauto; ins; desf.
exploit alloc_always_before; eauto; ins; desf.
by eapply HC; eauto; vauto.
eexists,; eauto.
apply clos_refl_trans_hbE in HB; desf; vauto.
eapply t_trans; eauto; vauto.
Qed.
This page has been generated by coqdoc