@@ -38,6 +38,7 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
3838 | epsilon_guard : forall t u, epsilon_ (observe u) t -> epsilon_ (GuardF u) t.
3939
4040 Definition epsilon {E C X} (t t' : ctree E C X) := epsilon_ (observe t) (observe t').
41+ Hint Constructors epsilon_det productive epsilon_ : core.
4142
4243 Section epsilon_det_theory.
4344
@@ -111,11 +112,11 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
111112 Qed .
112113
113114 Lemma sbisim_epsilon_det {E C X}:
114- forall (t t' : ctree E C X), epsilon_det t t' -> t ~ t'.
115+ forall (t t' : ctree E C X), epsilon_det t t' -> t ≃ t'.
115116 Proof .
116117 intros. induction H.
117118 - now rewrite H.
118- - rewrite H0. rewrite sb_guard . apply IHepsilon_det.
119+ - rewrite H0. rewrite sbisim_guard . apply IHepsilon_det.
119120 Qed .
120121
121122 End epsilon_det_theory.
@@ -261,8 +262,8 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
261262 genobs t ot. genobs t' ot'. clear t Heqot t' Heqot'.
262263 induction H.
263264 - rewrite H. apply H0.
264- - apply IHepsilon_ in H0. eapply trans_br in H0. apply H0. rewrite <- ctree_eta. reflexivity.
265- - apply IHepsilon_ in H0; etrans.
265+ - apply IHepsilon_ in H0. rewrite <- ctree_eta in H0. eapply trans_br in H0. apply H0.
266+ - apply IHepsilon_ in H0; rewrite <- ctree_eta in H0; etrans.
266267 Qed .
267268
268269 Lemma epsilon_fwd : forall {E C X Y} (t : ctree E C X) k x (c : C Y),
@@ -289,35 +290,29 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
289290 - intros; subst; eapply epsilon_guard, IHepsilon_; reflexivity.
290291 Qed .
291292
292- Lemma trans_epsilon {E C X} l (t t'' : ctree E C X) : trans l t t'' -> exists t',
293+ Lemma trans_epsilon {E C X} l (t : ctree E C X) t'' : trans l t t'' -> exists t',
293294 epsilon t t' /\ productive t' /\ trans l t' t''.
294295 Proof .
295- intros. do 3 red in H.
296- setoid_rewrite (ctree_eta t). setoid_rewrite (ctree_eta t'').
297- genobs t ot. genobs t'' ot''. clear t Heqot t'' Heqot''.
298- induction H; intros.
299- - destruct IHtrans_ as (? & ? & ? & ?).
300- rewrite <- ctree_eta in H0. eapply epsilon_br in H0.
301- exists x0. etrans.
302- - destruct IHtrans_ as (? & ? & ? & ?).
303- rewrite <- ctree_eta in H0. eapply epsilon_guard in H0.
304- eexists; etrans.
305- - eexists. split; [| split ].
306- + constructor 1. reflexivity.
307- + eapply prod_step. reflexivity.
308- + rewrite <- H, <- ctree_eta. etrans.
309- - eexists. split; [| split ].
310- + constructor 1. reflexivity.
311- + eapply prod_vis. reflexivity.
312- + rewrite <- H, <- ctree_eta. etrans.
313- - eexists. split; [| split ].
314- + constructor 1. reflexivity.
315- + eapply prod_ret. reflexivity.
316- + etrans.
317- Qed .
318-
319- Lemma trans_val_epsilon {E C X} : forall x (t t' : ctree E C X),
320- trans (val x) t t' -> epsilon t (Ret x) /\ t' ≅ Stuck.
296+ intros H. cbv in H.
297+ dependent induction H.
298+ - edestruct4 IHtransR; eauto.
299+ setoid_rewrite H; rewrite H0 in H2.
300+ cbv; eauto.
301+ - edestruct4 IHtransR; eauto.
302+ setoid_rewrite H.
303+ cbv; eauto.
304+ - setoid_rewrite H.
305+ setoid_rewrite H0.
306+ exists (Step t'); split3; eauto.
307+ - setoid_rewrite H.
308+ eauto 5.
309+ - setoid_rewrite H.
310+ setoid_rewrite H0.
311+ exists (Ret r); split3; eauto.
312+ Qed .
313+
314+ Lemma trans_val_epsilon {E C X} : forall x (t : ctree E C X) t',
315+ trans (val x) t t' -> epsilon t (Ret x).
321316 Proof .
322317 intros. apply trans_epsilon in H as (? & ? & ? & ?).
323318 inv H0.
@@ -333,17 +328,24 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
333328 inv H0.
334329 - rewrite EQ in H1. inv_trans.
335330 - rewrite EQ in H1. inv_trans.
336- - rewrite EQ in H1. inv_trans.
337- eauto.
331+ - rewrite EQ in H1,H.
332+ clear x EQ.
333+ inv_trans.
334+ inv EQ.
335+ eauto.
338336 Qed .
339337
340- Lemma trans_obs_epsilon {E C X Y} : forall (t t' : ctree E C X) e (x : Y),
341- trans (obs e x ) t t' -> exists k, epsilon t (Vis e k) /\ t' ≅ k x .
338+ Lemma trans_ask_epsilon {E C X Y} : forall (t : ctree E C X) t' (e : E Y),
339+ trans (ask e ) t t' -> exists k, epsilon t (Vis e k) /\ Seq t' (β e k) .
342340 Proof .
343341 intros. apply trans_epsilon in H as (? & ? & ? & ?).
344342 inv H0.
345343 - rewrite EQ in H1. inv_trans.
346- - rewrite EQ in H1. inv_trans. subst. etrans.
344+ - rewrite EQ in H1. inv_trans.
345+ rewrite EQ in H.
346+ pose proof ask_invT EQl; subst.
347+ pose proof ask_inv EQl; subst.
348+ eauto.
347349 - rewrite EQ in H1. inv_trans.
348350 Qed .
349351
@@ -501,68 +503,55 @@ Helper inductive: [epsilon t t'] judges that [t'] is reachable from [t] by a pat
501503 step in H0. step. eapply ss_epsilon_r in H0; eauto.
502504 Qed .
503505
506+ Notation "l ⊢ x → y" := (hrel_of (trans l) x y) (at level 10, x at next level, y at next level, only printing).
507+ Notation "x" := (α x) (at level 9, only printing).
508+
504509 Lemma ssim_ret_epsilon {E F C D X Y L} :
505510 forall r (u : ctree F D Y),
506- Respects_val L ->
507511 (Ret r : ctree E C X) (≲L) u ->
508512 exists r', epsilon u (Ret r') /\ L (val r) (val r').
509513 Proof .
510- intros * RV SIM *.
511- step in SIM. specialize (SIM (val r) Stuck (trans_ret _)).
512- destruct SIM as (l' & u' & TR & _ & EQ).
513- apply RV in EQ as ?. destruct H as [? _]. specialize (H (Is_val _)). inv H.
514- apply trans_val_invT in TR as ?. subst.
515- apply trans_val_epsilon in TR as []. eauto.
514+ intros * SIM *.
515+ play in SIM.
516+ invL.
517+ apply trans_val_epsilon in TR.
518+ etrans.
516519 Qed .
517520
518521 Lemma ssim_vis_epsilon {E F C D X Y Z L} :
519522 forall e (k : Z -> ctree E C X) (u : ctree F D Y),
520- Respects_val L ->
521- Respects_τ L ->
522523 Vis e k (≲L) u ->
523- forall x, exists Z' (e' : F Z') k' y, epsilon u (Vis e' k') /\ k x (≲L) k' y /\ L (obs e x) (obs e' y).
524- Proof .
525- intros * RV RT SIM *.
526- step in SIM. cbn in SIM. specialize (SIM (obs e x) (k x) (trans_vis _ _ _)).
527- destruct SIM as (l' & u'' & TR & SIM & EQ).
524+ forall x, exists Z' (e' : F Z') k' y,
525+ epsilon u (Vis e' k') /\
526+ k x (≲L) k' y /\
527+ L (ask e) (ask e') /\
528+ L (rcv e x) (rcv e' y).
529+ Proof .
530+ intros * SIM *.
531+ apply ssim_vis_l_inv in SIM as (? & ? & ? & TR & ? & SIM).
528532 apply trans_epsilon in TR. destruct TR as (u' & EPS & PROD & TR).
529- destruct PROD.
530- 1: {
531- subs. inv_trans. subst.
532- apply RV in EQ. destruct EQ as [_ ?]. specialize (H (Is_val _)). inv H.
533- }
534- 2: {
535- subs. inv_trans. subst.
536- apply RT in EQ. destruct EQ as [_ ?]. specialize (H eq_refl). inv H.
537- }
538- subs. inv_trans. subst.
539- eexists _, _, _, _. etrans.
533+ destruct PROD; subs; inv_trans.
534+ dependent induction EQ.
535+ pose proof ask_invT EQl; subst.
536+ pose proof ask_inv EQl; subst.
537+ destruct (SIM x) as (? & ? & ?).
538+ rewrite EQ in H2.
539+ ex4; split4; eauto; etrans.
540540 Qed .
541541
542542 Lemma ssim_brS_epsilon {E F C D X Y Z L} :
543543 forall c (k : Z -> ctree E C X) (u : ctree F D Y),
544- Respects_τ L ->
545- L τ τ ->
546544 BrS c k (≲L) u ->
547545 forall x,
548546 (exists v, epsilon u (Step v) /\ k x (≲L) v).
549547 Proof .
550- intros * RT HL SIM *.
548+ intros * SIM *.
551549 step in SIM. cbn in SIM. specialize (SIM τ (k x) (trans_brS _ _ _)).
552550 destruct SIM as (l' & u'' & TR & SIM & EQ).
553551 apply trans_epsilon in TR. destruct TR as (u' & EPS & PROD & TR).
554- destruct PROD.
555- 1: {
556- subs. inv_trans. subst.
557- apply RT in EQ. destruct EQ as [? _]. specialize (H eq_refl). inv H.
558- }
559- 1: {
560- subs. inv_trans. subst.
561- apply RT in EQ. destruct EQ as [? _]. specialize (H eq_refl). inv H.
562- }
563- subs.
564- inv_trans. subst.
565- eexists _. etrans.
552+ destruct PROD; subs; inv_trans; etrans.
553+ invL.
554+ invL.
566555 Qed .
567556
568557 End epsilon_theory.
0 commit comments