Commit 246061ef authored by Hai Dang's avatar Hai Dang

deref/ref take results

parent 2f224774
......@@ -474,16 +474,18 @@ Proof.
- by exists (Ki :: K').
Qed.
Lemma tstep_ref_inv l tg T e' σ σ'
(STEP: ((& (Place l tg T))%E, σ) ~{fns}~> (e', σ')) :
e' = #[ScPtr l tg]%E σ' = σ is_Some (σ.(shp) !! l).
Lemma tstep_ref_inv (pl: result) e' σ σ'
(STEP: ((& pl)%E, σ) ~{fns}~> (e', σ')) :
l tg T, pl = PlaceR l tg T e' = #[ScPtr l tg]%E σ' = σ is_Some (σ.(shp) !! l).
Proof.
inv_tstep. symmetry in Eq.
destruct (fill_ref_decompose _ _ _ Eq)
as [[]|[K' [? Eq']]]; subst.
- clear Eq. simpl in HS. by inv_head_step.
- clear Eq. simpl in HS. inv_head_step.
have Eq1 := to_of_result pl. rewrite -H /to_result in Eq1. simplify_eq.
naive_solver.
- apply result_head_stuck, (fill_not_result _ K') in HS.
by rewrite Eq' in HS.
by rewrite Eq' to_of_result in HS.
Qed.
(** Deref *)
......@@ -498,17 +500,19 @@ Proof.
- by exists (Ki :: K').
Qed.
Lemma tstep_deref_inv l tg T e' σ σ'
(STEP: ((Deref #[ScPtr l tg] T)%E, σ) ~{fns}~> (e', σ')) :
e' = Place l tg T σ' = σ
Lemma tstep_deref_inv (rf: result) T e' σ σ'
(STEP: ((Deref rf T)%E, σ) ~{fns}~> (e', σ')) :
l tg, rf = (ValR [ScPtr l tg])%R e' = Place l tg T σ' = σ
( (i: nat), (i < tsize T)%nat l + i dom (gset loc) σ.(shp)).
Proof.
inv_tstep. symmetry in Eq.
destruct (fill_deref_decompose _ _ _ _ Eq)
as [[]|[K' [? Eq']]]; subst.
- clear Eq. simpl in HS. by inv_head_step.
- clear Eq. simpl in HS. inv_head_step.
have Eq1 := to_of_result rf. rewrite -H0 /to_result in Eq1. simplify_eq.
naive_solver.
- apply result_head_stuck, (fill_not_result _ K') in HS.
by rewrite Eq' in HS.
by rewrite Eq' to_of_result in HS.
Qed.
(** Call *)
......@@ -728,17 +732,21 @@ Proof.
- subst K. by exists (Ki :: K0).
Qed.
Lemma tstep_copy_inv l tg T e' σ σ'
(STEP: (Copy (Place l tg T), σ) ~{fns}~> (e', σ')) :
v α', e' = Val v read_mem l (tsize T) σ.(shp) = Some v
Lemma tstep_copy_inv (pl: result) e' σ σ'
(STEP: (Copy pl, σ) ~{fns}~> (e', σ')) :
l tg T v α',
pl = PlaceR l tg T
e' = Val v read_mem l (tsize T) σ.(shp) = Some v
memory_read σ.(sst) σ.(scs) l tg (tsize T) = Some α'
σ' = mkState σ.(shp) α' σ.(scs) σ.(snp) σ.(snc).
Proof.
inv_tstep. symmetry in Eq.
destruct (fill_copy_decompose _ _ _ Eq) as [[]|[K' [? Eq']]]; subst.
- clear Eq. simpl in HS. inv_head_step. naive_solver.
- clear Eq. simpl in HS. inv_head_step.
have Eq1 := to_of_result pl. rewrite -H0 /to_result in Eq1. simplify_eq.
naive_solver.
- exfalso. apply val_head_stuck in HS. destruct (fill_val K' e1') as [? Eq1'].
+ rewrite /= Eq'. by eexists.
+ rewrite /= Eq' to_of_result. by eexists.
+ by rewrite Eq1' in HS.
Qed.
......@@ -776,9 +784,12 @@ Proof.
- subst K. right. by exists r1, (Ki :: K').
Qed.
Lemma tstep_write_inv l tg T v e' σ σ'
(STEP: ((Place l tg T <- #v)%E, σ) ~{fns}~> (e', σ')) :
α', e' = (#[]%V)
Lemma tstep_write_inv (pl r: result) e' σ σ'
(STEP: ((pl <- r)%E, σ) ~{fns}~> (e', σ')) :
l tg T v α',
pl = PlaceR l tg T
r = ValR v
e' = (#[]%V)
memory_written σ.(sst) σ.(scs) l tg (tsize T) = Some α'
( (i: nat), (i < length v)%nat l + i dom (gset loc) σ.(shp))
(v <<t σ.(snp)) (length v = tsize T)
......@@ -787,12 +798,15 @@ Proof.
inv_tstep. symmetry in Eq.
destruct (fill_write_decompose _ _ _ _ Eq)
as [[]|[[K' [? Eq']]|[? [K' [? [Eq' ?]]]]]]; subst.
- clear Eq. simpl in HS. inv_head_step. naive_solver.
- clear Eq. simpl in HS. inv_head_step.
have Eq1 := to_of_result pl. rewrite -H0 /to_result in Eq1.
have Eq2 := to_of_result r. rewrite -H1 /to_result in Eq2. simplify_eq.
naive_solver.
- exfalso. apply val_head_stuck in HS. destruct (fill_val K' e1') as [? Eq1'].
+ rewrite /= Eq'. by eexists.
+ rewrite /= Eq' to_of_result. by eexists.
+ by rewrite Eq1' in HS.
- exfalso. apply val_head_stuck in HS. destruct (fill_val K' e1') as [? Eq1'].
+ rewrite /= Eq'. by eexists.
+ rewrite /= Eq' to_of_result. by eexists.
+ by rewrite Eq1' in HS.
Qed.
......
......@@ -14,8 +14,10 @@ Lemma sim_body_copy_left_1
Proof.
intros COND. pfold. intros NT r_f WSAT.
edestruct NT as [[]|[es1 [σs1 STEP1]]]; [constructor 1|done|].
destruct (tstep_copy_inv _ _ _ _ _ _ _ STEP1) as (vs & α' & ? & Eqvs & READ & ?).
subst es1 σs1. rewrite /= read_mem_equation_1 /= in Eqvs.
destruct (tstep_copy_inv _ (PlaceR l (Tagged t) int) _ _ _ STEP1)
as (l' & t' & T' & vs & α' & EqH & ? & Eqvs & READ & ?).
symmetry in EqH. simplify_eq.
rewrite /= read_mem_equation_1 /= in Eqvs.
destruct (σs.(shp) !! l) as [s|] eqn:Eqs; [|done]. simpl in Eqvs. simplify_eq.
specialize (COND _ eq_refl).
......
......@@ -102,13 +102,14 @@ Proof.
move=>Hwf xs Hxswf /=. sim_bind (subst_map _ e) (subst_map _ e).
eapply sim_simple_post_mono, IHe; [|by auto..].
intros r' n' rs css' rt cst' (-> & -> & -> & Hrel). simpl.
Fail eapply sim_simple_deref.
admit.
have ?:= (rrel_eq _ _ _ Hrel). subst rt.
eapply sim_simple_deref. intros. by subst.
- (* Ref *)
move=>Hwf xs Hxswf /=. sim_bind (subst_map _ e) (subst_map _ e).
eapply sim_simple_post_mono, IHe; [|by auto..].
intros r' n' rs css' rt cst' (-> & -> & -> & Hrel). simpl.
Fail eapply sim_simple_ref.
have ?:= (rrel_eq _ _ _ Hrel). subst rt.
eapply sim_simple_ref. intros. subst.
admit.
- (* Copy *) admit.
- (* Write *) admit.
......
This diff is collapsed.
......@@ -186,54 +186,61 @@ Lemma sim_body_let_place fs ft r n x ls lt ts tt tys tyt es2 et2 σs σt Φ :
Proof. apply sim_body_let; eauto. Qed.
(** Ref *)
Lemma sim_body_ref fs ft r n l tgs tgt Ts Tt σs σt Φ :
Φ r n (ValR [ScPtr l tgs]) σs (ValR [ScPtr l tgt]) σt : Prop
r {n,fs,ft} ((& (Place l tgs Ts))%E, σs) ((& (Place l tgt Tt))%E, σt) : Φ.
Lemma sim_body_ref fs ft r n (pl: result) σs σt Φ :
( l t T, pl = PlaceR l t T
Φ r n (ValR [ScPtr l t]) σs (ValR [ScPtr l t]) σt : Prop)
r {n,fs,ft} ((& pl)%E, σs) ((& pl)%E, σt) : Φ.
Proof.
intros SIM. pfold.
intros POST. pfold.
intros NT r_f WSAT. split; [|done|].
{ right.
destruct (NT (& (Place l tgs Ts))%E σs) as [[]|[es' [σs' STEPS]]]; [done..|].
destruct (tstep_ref_inv _ _ _ _ _ _ _ STEPS) as [? [? IS]]. subst es' σs'.
destruct (NT (& pl)%E σs) as [[]|[es' [σs' STEPS]]]; [done..|].
destruct (tstep_ref_inv _ _ _ _ _ STEPS) as (l & tg & T & ? & ? & ? & IS).
simplify_eq.
have ?: is_Some (σt.(shp) !! l).
{ clear -WSAT IS. move : IS.
by rewrite -2!(elem_of_dom (D:=gset loc)) -wsat_heap_dom. }
exists #[ScPtr l tgt]%E, σt.
exists #[ScPtr l tg]%E, σt.
eapply (head_step_fill_tstep _ []). by econstructor; econstructor. }
constructor 1. intros.
destruct (tstep_ref_inv _ _ _ _ _ _ _ STEPT) as [? [? IS]]. subst et' σt'.
destruct (tstep_ref_inv _ _ _ _ _ STEPT) as (l & tg & T & ? & ? & ? & IS).
simplify_eq.
have ?: is_Some (σs.(shp) !! l).
{ clear -WSAT IS. move : IS.
by rewrite -2!(elem_of_dom (D:=gset loc)) wsat_heap_dom. }
exists #[ScPtr l tgs]%E, σs, r, n. split.
exists #[ScPtr l tg]%E, σs, r, n. split.
{ left. constructor 1. eapply (head_step_fill_tstep _ []).
by econstructor; econstructor. }
split; [done|]. left.
by apply (sim_body_result _ _ _ _ (ValR _) (ValR _)).
apply (sim_body_result _ _ _ _ (ValR _) (ValR _)).
intros. by eapply POST.
Qed.
(** Deref *)
Lemma sim_body_deref fs ft r n l tgs tgt Ts Tt σs σt Φ
(EQS: tsize Ts = tsize Tt) :
Φ r n (PlaceR l tgs Ts) σs (PlaceR l tgt Tt) σt : Prop
r {n,fs,ft} (Deref #[ScPtr l tgs] Ts, σs) (Deref #[ScPtr l tgt] Tt, σt) : Φ.
Lemma sim_body_deref fs ft r n (rf: result) T σs σt Φ :
( l t, rf = ValR [ScPtr l t]
Φ r n (PlaceR l t T) σs (PlaceR l t T) σt : Prop )
r {n,fs,ft} (Deref rf T, σs) (Deref rf T, σt) : Φ.
Proof.
intros SIM. pfold.
intros POST. pfold.
intros NT r_f WSAT. split; [|done|].
{ right.
destruct (NT (Deref #[ScPtr l tgs] Ts) σs) as [[]|[es' [σs' STEPS]]]; [done..|].
destruct (tstep_deref_inv _ _ _ _ _ _ _ STEPS) as [? [? IS]]. subst es' σs'.
have ?: ( (i: nat), (i < tsize Tt)%nat l + i dom (gset loc) σt.(shp)).
{ clear -WSAT IS EQS. rewrite -EQS. move => i /IS. by rewrite -wsat_heap_dom. }
exists (Place l tgt Tt), σt.
destruct (NT (Deref rf T) σs) as [[]|[es' [σs' STEPS]]]; [done..|].
destruct (tstep_deref_inv _ _ _ _ _ _ STEPS) as (l & t & ? & ? & ? & IS).
subst.
have ?: ( (i: nat), (i < tsize T)%nat l + i dom (gset loc) σt.(shp)).
{ clear -WSAT IS. by setoid_rewrite wsat_heap_dom. }
exists (Place l t T), σt.
eapply (head_step_fill_tstep _ []). by econstructor; econstructor. }
constructor 1. intros.
destruct (tstep_deref_inv _ _ _ _ _ _ _ STEPT) as [? [? IS]]. subst et' σt'.
have ?: ( (i: nat), (i < tsize Ts)%nat l + i dom (gset loc) σs.(shp)).
{ clear -WSAT IS EQS. rewrite EQS. move => i /IS. by rewrite wsat_heap_dom. }
exists (Place l tgs Ts), σs, r, n. split.
destruct (tstep_deref_inv _ _ _ _ _ _ STEPT) as (l & t & ? & ? & ? & IS).
subst.
have ?: ( (i: nat), (i < tsize T)%nat l + i dom (gset loc) σs.(shp)).
{ clear -WSAT IS. by setoid_rewrite <- wsat_heap_dom. }
exists (Place l t T), σs, r, n. split.
{ left. constructor 1. eapply (head_step_fill_tstep _ []).
by econstructor; econstructor. }
split; [done|].
left. by apply (sim_body_result _ _ _ _ (PlaceR _ _ _) (PlaceR _ _ _)).
left. apply (sim_body_result _ _ _ _ (PlaceR _ _ _) (PlaceR _ _ _)).
intros. by eapply POST.
Qed.
......@@ -210,16 +210,17 @@ Lemma sim_simple_let_place fs ft r n x ls lt ts tt tys tyt es2 et2 css cst Φ :
r ⊨ˢ{n,fs,ft} (let: x := Place ls ts tys in es2, css) ((let: x := Place lt tt tyt in et2), cst) : Φ.
Proof. intros HH σs σt <-<-. apply sim_body_let; eauto. Qed.
Lemma sim_simple_ref fs ft r n l tgs tgt Ts Tt css cst Φ :
Φ r n (ValR [ScPtr l tgs]) css (ValR [ScPtr l tgt]) cst
r ⊨ˢ{n,fs,ft} ((& (Place l tgs Ts))%E, css) ((& (Place l tgt Tt))%E, cst) : Φ.
Lemma sim_simple_ref fs ft r n (pl: result) css cst Φ :
( l t T, pl = PlaceR l t T
Φ r n (ValR [ScPtr l t]) css (ValR [ScPtr l t]) cst)
r ⊨ˢ{n,fs,ft} ((& pl)%E, css) ((& pl)%E, cst) : Φ.
Proof. intros HH σs σt <-<-. apply sim_body_ref; eauto. Qed.
Lemma sim_simple_deref fs ft r n l tgs tgt Ts Tt css cst Φ :
tsize Ts = tsize Tt
Φ r n (PlaceR l tgs Ts) css (PlaceR l tgt Tt) cst
r ⊨ˢ{n,fs,ft} (Deref #[ScPtr l tgs] Ts, css) (Deref #[ScPtr l tgt] Tt, cst) : Φ.
Proof. intros ? HH σs σt <-<-. apply sim_body_deref; eauto. Qed.
Lemma sim_simple_deref fs ft r n (rf: result) T css cst Φ :
( l t, rf = ValR [ScPtr l t]
Φ r n (PlaceR l t T) css (PlaceR l t T) cst)
r ⊨ˢ{n,fs,ft} (Deref rf T, css) (Deref rf T, cst) : Φ.
Proof. intros HH σs σt <-<-. apply sim_body_deref; eauto. Qed.
Lemma sim_simple_var fs ft r n css cst var Φ :
r ⊨ˢ{n,fs,ft} (Var var, css) (Var var, cst) : Φ.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment