Commit 94b59314 authored by Hai Dang's avatar Hai Dang

fix index for values

parent 46dc5239
......@@ -108,6 +108,14 @@ Proof.
by eapply fill_not_result, (result_head_stuck fns).
Qed.
Lemma result_tstep_rtc e σ e' σ' :
terminal e (e, σ) ~{fns}~>* (e', σ') e' = e σ' = σ.
Proof.
intros [v Eqe].
inversion 1 as [|x [] z STEP]; [done|].
apply result_tstep_stuck in STEP. by rewrite Eqe in STEP.
Qed.
Lemma tstep_reducible_fill_inv K e σ :
to_result e = None
reducible fns (fill K e) σ reducible fns e σ.
......
This diff is collapsed.
......@@ -38,8 +38,8 @@ Record sim_base (sim: SIM_CONFIG) (idx1: nat) (eσ1_src eσ1_tgt: expr * state)
(terminal eσ1_tgt.1 reducible fnt eσ1_tgt.1 eσ1_tgt.2) ;
(* (2) If [eσ1_tgt] is terminal, then [eσ1_src] terminates with some steps. *)
sim_terminal :
terminal eσ1_tgt.1 idx2 eσ2_src,
sflib.__guard__ (eσ1_src ~{fns}~>+ eσ2_src ((idx2 < idx1)%nat eσ1_src = eσ2_src))
terminal eσ1_tgt.1 eσ2_src,
eσ1_src ~{fns}~>* eσ2_src
terminal eσ2_src.1 sim_expr_terminal eσ2_src.1 eσ1_tgt.1 ;
(* (3) If [eσ1_tgt] steps to [eσ2_tgt] with 1 step,
then exists [eσ2_src] s.t. [eσ1_src] steps to [eσ2_src] with * step. *)
......
......@@ -85,12 +85,9 @@ Proof.
* unfold reducible in ST. des. eapply NS.
destruct x. eauto.
+ clear sim_stuck. exploit sim_terminal; eauto. i. des.
pfold. econs.
* instantiate (1 := eσ2_src). unguardH x0. des.
{ apply tc_rtc. eauto. }
{ subst. reflexivity. }
* unfold terminal in *. des.
econs 2. unfold term. erewrite x2; eauto.
pfold. econs; eauto.
unfold terminal in *. des.
econs 2. unfold term. erewrite x2; eauto.
+ pclearbot. exploit sim_step; eauto. i. revert sim_stuck.
rename s' into conf'_tgt.
have WFT': Wf conf'_tgt.2 by eapply tstep_wf; eauto.
......
......@@ -63,11 +63,9 @@ Record sim_local_body_base (r_f: A) (sim_local_body : SIM)
(* if tgt is terminal *)
vt (TERM: to_result et = Some vt),
(* then src can get terminal *)
vs' σs' r' idx',
sflib.__guard__ ((es, σs) ~{fs}~>+ (of_result vs', σs')
((idx' < idx)%nat (es, σs) = (of_result vs', σs')))
vs' σs' r', (es, σs) ~{fs}~>* (of_result vs', σs')
(* and re-establish wsat *)
wsat (r_f r') σs' σt Φ r' idx' vs' σs' vt σt ;
wsat (r_f r') σs' σt Φ r' idx vs' σs' vt σt ;
sim_local_body_step :
_sim_local_body_step r_f sim_local_body r idx es σs et σt Φ
}.
......@@ -100,7 +98,7 @@ Proof.
intros NT r_f WSAT. specialize (SIM NT r_f WSAT) as [NOTS TE SIM].
constructor; [done|..].
{ intros.
destruct (TE _ TERM) as (vs' & σs' & r' & idx' & STEP' & WSAT' & HΦ).
destruct (TE _ TERM) as (vs' & σs' & r' & STEP' & WSAT' & HΦ).
naive_solver. }
inversion SIM.
- left. intros.
......@@ -165,7 +163,7 @@ Proof.
specialize (SIM NT r_f WSAT2) as [NOTS TE SIM].
constructor; [done|..].
{ intros.
destruct (TE _ TERM) as (vs' & σs' & r' & idx' & STEP' & WSAT' & HΦ).
destruct (TE _ TERM) as (vs' & σs' & r' & STEP' & WSAT' & HΦ).
naive_solver. }
inversion SIM.
- left. intros.
......
......@@ -94,11 +94,10 @@ Proof.
destruct sim_local_body_stuck as [vt Eqvt].
rewrite -(of_to_result _ _ Eqvt).
destruct (sim_local_body_terminal _ Eqvt)
as (vs' & σs' & r' & idx' & SS' & WSAT' & (c & CALLIDS & ESAT') & VREL).
as (vs' & σs' & r' & SS' & WSAT' & (c & CALLIDS & ESAT') & VREL).
have STEPK: (fill (Λ:=bor_ectxi_lang fns) K_src0 e_src0, σ_src)
~{fns}~>* (fill (Λ:=bor_ectxi_lang fns) K_src0 vs', σs').
{ apply fill_tstep_rtc. destruct SS' as [|[? Eq]].
by apply tc_rtc. clear -Eq. simplify_eq. constructor. }
{ by apply fill_tstep_rtc. }
have NT3:= never_stuck_tstep_rtc _ _ _ _ _ STEPK NEVER_STUCK.
clear -STEPK NT3 FRAMES WSAT' VREL.
inversion FRAMES. { left. rewrite to_of_result. by eexists. }
......@@ -141,7 +140,7 @@ Proof.
σs2 = mkState σs.(shp) σs.(sst) cids1 σs.(snp) σs.(snc)
σt2 = mkState σt.(shp) σt.(sst) cids2 σt.(snp) σt.(snc)
r2 = r'.
have SIMEND : r' {idx',fns,fnt} (EndCall vs1, σs) (EndCall vt1, σt) : Φ.
have SIMEND : r' {idx,fns,fnt} (EndCall vs1, σs) (EndCall vt1, σt) : Φ.
{ apply sim_body_end_call; auto; [naive_solver|].
clear -VR. intros. rewrite /Φ. simpl. split; last naive_solver.
by eexists _, _. }
......@@ -154,8 +153,7 @@ Proof.
(EndCallCtx :: K_src frame0 ++ K_f_src) e_src0, σ_src)
~{fns}~>* (fill (Λ:= bor_ectxi_lang fns)
(EndCallCtx :: K_src frame0 ++ K_f_src) vs1, σs).
{ apply fill_tstep_rtc. destruct x as [|[? Eq]].
by apply tc_rtc. clear -Eq. simplify_eq. constructor. }
{ by apply fill_tstep_rtc. }
have NT3 := never_stuck_tstep_rtc _ _ _ _ _ STEPK NEVER_STUCK.
rewrite /= in NT3.
have NT4 := never_stuck_fill_inv _ _ _ _ NT3.
......@@ -172,8 +170,7 @@ Proof.
intros [idx3 SIMFR]. rename σ2_tgt into σt2.
do 2 eexists. split.
- left. apply fill_tstep_tc. eapply tc_rtc_l; [|apply STEPS].
apply (fill_tstep_rtc _ [EndCallCtx]).
clear -x. destruct x as [|[]]. by apply tc_rtc. simplify_eq. constructor.
by apply (fill_tstep_rtc _ [EndCallCtx]).
- right. apply CIH. econs; eauto.
+ rewrite fill_app. eauto.
......
......@@ -35,7 +35,7 @@ Proof.
have STEPS: (Alloc T, σs) ~{fs}~> (Place l t T, σs').
{ subst l σs' t. rewrite Eqlst -Eqnp.
eapply (head_step_fill_tstep _ []), alloc_head_step. }
eexists _, σs', (r r'), (S n). split; last split.
eexists _, σs', (r r'), n. split; last split.
{ left. by apply tc_once. }
{ have HLF : i, (i < tsize T)%nat (r_f r).(rlm) !! (l + i) = None.
{ intros i Lti.
......@@ -366,7 +366,7 @@ Proof.
have ND := proj2 (state_wf_stack_item _ WFT _ _ Eqstk).
admit.
}
exists (Val vs), σs', (r (core (r_f r))), (S n). split; last split.
exists (Val vs), σs', (r (core (r_f r))), n. split; last split.
{ left. by constructor 1. }
{ rewrite cmra_assoc -CORE.
split; last split; last split; last split; last split; last split.
......@@ -549,7 +549,7 @@ Proof.
rewrite EQL in EqD. rewrite -Eqnp in IN.
eapply (head_step_fill_tstep _ []), write_head_step'; eauto. }
exists (#[])%V, σs', (r' res_mapsto l 1 s (init_stack (Tagged tg))), (S n).
exists (#[])%V, σs', (r' res_mapsto l 1 s (init_stack (Tagged tg))), n.
split; last split.
{ left. by constructor 1. }
{ have HLlrf: (r_f r) .(rlm) !! l Some (to_locStateR (lsLocal v' (init_stack (Tagged tg)))).
......@@ -699,7 +699,7 @@ Proof.
have HL2: if k0 then (r_f.(rtm) r.(rtm)) !! tg = Some (to_tagKindR tkUnique, h0) else True.
{ destruct k0; [|done].
by apply (tmap_lookup_op_r _ _ _ _ (proj1 (proj1 VALID)) Eqtg). }
exists (#[])%V, σs', r', (S n). split; last split.
exists (#[])%V, σs', r', n. split; last split.
{ left. by constructor 1. }
{ have Eqrlm: (r_f r').(rlm) (r_f r).(rlm) by destruct k0.
destruct (for_each_lookup _ _ _ _ _ Eqα') as [EQ1 EQ2].
......@@ -1180,7 +1180,7 @@ Proof.
{ destruct WSAT as (?&?&?&?&?&SREL&?). destruct SREL as (? & ? & Eqcs' & ?).
eapply (head_step_fill_tstep _ []).
econstructor. by econstructor. econstructor. by rewrite Eqcs'. }
exists (Val vs), σs', r, (S n).
exists (Val vs), σs', r, n.
destruct WSAT as (WFS & WFT & VALID & PINV & CINV & SREL & LINV).
split; last split.
{ left. by constructor 1. }
......@@ -1216,8 +1216,8 @@ Lemma sim_body_end_call_elim' fs ft r n vs vt σs σt Φ :
r_f et' σt' (WSAT: wsat (r_f r) σs σt)
(NT: never_stuck fs (EndCall (Val vs)) σs)
(STEPT: (EndCall (Val vt), σt) ~{ft}~> (et', σt')),
r' idx' σs', (EndCall (Val vs), σs) ~{fs}~>+ (Val vs, σs') et' = Val vt
Φ r' idx' (ValR vs) σs' (ValR vt) σt'
r' n' σs', (EndCall (Val vs), σs) ~{fs}~>+ (Val vs, σs') et' = Val vt
Φ r' n' (ValR vs) σs' (ValR vt) σt'
wsat (r_f r') σs' σt'.
Proof.
intros SIM r_f et' σt' WSAT NT STEPT.
......@@ -1236,73 +1236,27 @@ Proof.
specialize (SIMV NT1 _ WSAT1) as [ST1 TE1 STEPS1].
apply tstep_end_call_inv in STEPT as (? & Eq1 &? & ? & ? & ? & ?);
[|by eexists]. simpl in Eq1. symmetry in Eq1. simplify_eq.
specialize (TE1 vt eq_refl) as (vs2 & σs2 & r2 & idx2 & STEP2 & WSAT2 & POST).
exists r2, idx2, σs2.
have ?: vs2 = vs.
specialize (TE1 vt eq_refl) as (vs2 & σs2 & r2 & STEP2 & WSAT2 & POST).
exists r2, n1, σs2.
assert (vs2 = vs (EndCall #vs, σs) ~{fs}~>+ ((#vs)%E, σs2)) as [].
{ clear -STEP1 STEP2.
destruct STEP1 as [STEP1|[Eq11 Eq12]]; [|simplify_eq].
- apply tstep_end_call_inv_tc in STEP1 as (? & Eq1 &? & ? & ? & ? & ?);
[|by eexists]. simpl in Eq1.
simplify_eq. destruct STEP2 as [?%result_tstep_tc_stuck|[]]; [done|].
simplify_eq.
have Eq := to_of_result vs2. rewrite -H1 /= in Eq. by simplify_eq.
- have Eq := to_of_result vs2.
destruct STEP2 as [STEP2|[? STEP2]].
+ apply tstep_end_call_inv_tc in STEP2 as (? & Eq' &? & ? & ? & ? & ?);
[|by eexists].
simpl in Eq'. simplify_eq.
rewrite H /= in Eq. by simplify_eq.
+ simplify_eq. by rewrite -H0 in Eq. }
subst vs2. split; [|done].
destruct STEP1 as [|[]], STEP2 as [|[]]; simplify_eq.
- eapply tc_rtc_l; eauto.
- done.
- done.
Qed.
Lemma sim_body_end_call_elim fs ft r n vs vt σs σt Φ :
r {n,fs,ft} (EndCall (Val vs), σs) (EndCall (Val vt), σt) : Φ
r_f σs' σt' (WSAT: wsat (r_f r) σs σt)
(NT: never_stuck fs (EndCall (Val vs)) σs)
(STEPS: (EndCall (Val vs), σs) ~{fs}~> (Val vs, σs'))
(STEPT: (EndCall (Val vt), σt) ~{ft}~> (Val vt, σt')),
r' idx', Φ r' idx' (ValR vs) σs' (ValR vt) σt' wsat (r_f r') σs' σt'.
Proof.
intros SIM r_f σs' σt' WSAT NT STEPS STEPT.
punfold SIM.
specialize (SIM NT _ WSAT) as [NOSK TERM STEPSS].
inversion STEPSS; last first.
{ exfalso. clear -CALLTGT. symmetry in CALLTGT.
apply fill_end_call_decompose in CALLTGT as [[]|[K' [? Eq]]]; [done|].
destruct (fill_result ft K' (Call #[ScFnPtr fid] (Val <$> vl_tgt))) as [[] ?];
[rewrite Eq; by eexists|done]. }
specialize (STEP _ _ STEPT) as (es1 & σs1 & r1 & n1 & STEP1 & WSAT1 & SIMV).
have STEPK: (EndCall #vs, σs) ~{fs}~>* (es1, σs1).
{ destruct STEP1 as [|[]]. by apply tc_rtc. by simplify_eq. }
have NT1 := never_stuck_tstep_rtc _ _ _ _ _ STEPK NT.
pclearbot. punfold SIMV.
specialize (SIMV NT1 _ WSAT1) as [ST1 TE1 STEPS1].
specialize (TE1 vt eq_refl) as (vs2 & σs2 & r2 & idx2 & STEP2 & WSAT2 & POST).
exists r2, idx2.
assert (σs2 = σs' vs2 = vs) as [].
{ clear -STEP1 STEP2 STEPS.
apply tstep_end_call_inv in STEPS as (? & ? &? & ? & ? & ? & ?);
[|by eexists].
destruct STEP1 as [STEP1|[Eq11 Eq12]]; [|simplify_eq].
- apply tstep_end_call_inv_tc in STEP1 as (? & ? &? & ? & ? & ? & ?);
[|by eexists].
simplify_eq. destruct STEP2 as [?%result_tstep_tc_stuck|[]]; [done|].
simplify_eq.
rewrite H1 in H5. simplify_eq. split; [done|].
have Eq := to_of_result vs2. rewrite -H2 in Eq. by simplify_eq.
- have Eq := to_of_result vs2.
destruct STEP2 as [STEP2|[? STEP2]].
+ apply tstep_end_call_inv_tc in STEP2 as (? & ? &? & ? & ? & ? & ?);
[|by eexists].
rewrite H1 in H3. simplify_eq. split; [done|].
rewrite H2 in Eq. by simplify_eq.
+ simplify_eq. by rewrite -H2 in Eq. }
subst σs2 vs2. done.
- have STEP1' := STEP1.
apply tstep_end_call_inv_tc in STEP1 as (v1 & Eq1 &? & ? & ? & ? & ?);
[|by eexists]. simplify_eq.
apply result_tstep_rtc in STEP2 as [Eq3 Eq4]; [|by eexists].
rewrite /to_result in Eq1. simplify_eq.
have Eq := to_of_result vs2. rewrite Eq3 /to_result in Eq. by simplify_eq.
- inversion STEP2 as [x1 x2 Eq2|x1 [] x3 STEP3 STEP4]; simplify_eq.
+ have Eq := to_of_result vs2. by rewrite -Eq2 in Eq.
+ have STEP3' := STEP3.
apply tstep_end_call_inv in STEP3 as (v1 & Eq1 &? & ? & ? & ? & ?);
[|by eexists]. simplify_eq.
apply result_tstep_rtc in STEP4 as [Eq3 Eq4]; [|by eexists].
rewrite /to_result in Eq1. simplify_eq.
have Eq := to_of_result vs2. rewrite Eq3 /to_result in Eq.
simplify_eq. split; [done|]. by apply tc_once. }
by subst vs2.
Qed.
(** PURE STEP ----------------------------------------------------------------*)
......
......@@ -90,14 +90,14 @@ Qed.
Lemma sim_simple_val fs ft r n (vs vt: value) css cst Φ :
Φ r n vs css vt cst
r ⊨ˢ{S n,fs,ft} (vs, css) (vt, cst) : Φ.
r ⊨ˢ{n,fs,ft} (vs, css) (vt, cst) : Φ.
Proof.
intros HH σs σt <-<-. eapply (sim_body_result _ _ _ _ vs vt). done.
Qed.
Lemma sim_simple_place fs ft r n ls lt ts tt tys tyt css cst Φ :
Φ r n (PlaceR ls ts tys) css (PlaceR lt tt tyt) cst
r ⊨ˢ{S n,fs,ft} (Place ls ts tys, css) (Place lt tt tyt, cst) : Φ.
r ⊨ˢ{n,fs,ft} (Place ls ts tys, css) (Place lt tt tyt, cst) : Φ.
Proof.
intros HH σs σt <-<-. eapply (sim_body_result _ _ _ _ (PlaceR _ _ _) (PlaceR _ _ _)). done.
Qed.
......
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