@@ -274,21 +274,6 @@ Section sbisim_homogenous_theory.
274274
275275End sbisim_homogenous_theory.
276276
277- Lemma Leq_eq {E X}: build_rel (@Leq E X) == eq.
278- Proof .
279- split; [| intros <-; reflexivity].
280- intros []; auto.
281- dependent induction HR; auto.
282- dependent induction HR; auto.
283- cbn in H; subst; auto.
284- Qed .
285-
286- Lemma flipL_Leq {E X}: lequiv (flipL (@Leq E X)) Leq.
287- Proof .
288- cbv; intuition.
289- all: dependent induction H; constructor.
290- Qed .
291-
292277(*|
293278Heterogeneous theory
294279--------------------
@@ -1561,41 +1546,99 @@ Interaction with (complete) strong simulation
15611546| *)
15621547Section SBisim_vs_SSim.
15631548
1564- Context {E F C D : Type -> Type } {X Y : Type }
1565- {L : lrel E F X Y}.
1566-
1567- Notation ss := (@ss E F C D X Y).
1568- Notation ssim := (@ssim E F C D X Y).
1569-
1570- (*|
1571- A two-sided [ss] gives an [sb]; the converse fails in general (see
1572- [ssim_sbisim_nequiv] below).
1573- | *)
1574- Lemma ss_sb (R : rel _ _) (t : ctree E C X) (u : ctree F D Y) :
1575- ss L R t u ->
1576- ss (flipL L) (flip R) u t ->
1577- sb L R t u.
1578- Admitted .
1579-
1580- Lemma sbisim_clos_ss {c : Chain (ss L)} :
1581- forall x y, @sbisim_clos E F C D X Y Leq Leq `c x y -> `c x y.
1582- Admitted .
1583-
1584- #[global] Instance sbisim_eq_clos_ss_goal {R : Chain (ss L)} :
1585- Proper (sbisim Leq ==> sbisim Leq ==> flip impl) `R.
1586- Admitted .
1587-
1588- #[global] Instance sbisim_eq_clos_ss_ctx {R : Chain (ss L)} :
1589- Proper (sbisim Leq ==> sbisim Leq ==> impl) `R.
1590- Admitted .
1549+ Section withParam.
1550+
1551+ Context {E F C D : Type -> Type } {X Y : Type }
1552+ {L : lrel E F X Y}.
15911553
1592- #[global] Instance sbisim_eq_clos_ssim_goal :
1593- Proper (sbisim Leq ==> sbisim Leq ==> flip impl) (ssim L).
1594- Admitted .
1554+ Notation ss := (@ss E F C D X Y).
1555+ Notation ssim := (@ssim E F C D X Y).
15951556
1596- #[global] Instance sbisim_eq_clos_ssim_ctx :
1597- Proper (sbisim Leq ==> sbisim Leq ==> impl) (ssim L).
1598- Admitted .
1557+ #[global] Instance sbisim_ss_chain_goal {c : Chain (ss L)} :
1558+ Proper (sbisimeq ==> sbisimeq ==> flip impl) `c.
1559+ Proof .
1560+ apply tower.
1561+ - intros ? INC x y EQ x' y' EQ' ?? HP; red.
1562+ eapply INC; eauto.
1563+ eapply leq_infx in HP.
1564+ now apply HP.
1565+ - clear.
1566+ intros c IH x y EQ x' y' EQ' SS ?? TR.
1567+ playL in EQ.
1568+ apply SS in TR0; destruct TR0 as (? & ? & TR0 & Sbis' & HL).
1569+ playR in EQ'.
1570+ ex2; split3; eauto.
1571+ eapply IH; eauto.
1572+ rewrite flipL_Leq in H0.
1573+ apply Leq_eq in H,H0; subst; auto.
1574+ Qed .
1575+
1576+ #[global] Instance sbisim_ss_chain_ctx {c : Chain (ss L)} :
1577+ Proper (sbisimeq ==> sbisimeq ==> impl) `c.
1578+ Proof .
1579+ apply tower.
1580+ - intros ? INC x y EQ x' y' EQ' ?? HP; red.
1581+ eapply INC; eauto.
1582+ eapply leq_infx in HP.
1583+ now apply HP.
1584+ - clear.
1585+ intros c IH x y EQ x' y' EQ' SS ?? TR.
1586+ playR in EQ.
1587+ apply SS in TR0; destruct TR0 as (? & ? & TR0 & Sbis' & HL).
1588+ playL in EQ'.
1589+ ex2; split3; eauto.
1590+ eapply IH; eauto.
1591+ rewrite flipL_Leq in H.
1592+ apply Leq_eq in H,H0; subst; auto.
1593+ Qed .
1594+
1595+ #[global] Instance sbisim_ssim_goal :
1596+ Proper (sbisim Leq ==> sbisim Leq ==> flip impl) (ssim L).
1597+ Proof .
1598+ repeat intro; eapply sbisim_ss_chain_goal; eauto.
1599+ Qed .
1600+
1601+ #[global] Instance sbisim_ssim_ctx :
1602+ Proper (sbisim Leq ==> sbisim Leq ==> impl) (ssim L).
1603+ Proof .
1604+ repeat intro; eapply sbisim_ss_chain_ctx; eauto.
1605+ Qed .
1606+
1607+ (*|
1608+ "Co-similarity" does not entail bisimilarity as per [ssim_sbisim_nequiv],
1609+ but we can get something weaker:
1610+ | *)
1611+ Lemma ss_sb (R : rel _ _) (t : ctree E C X) (u : ctree F D Y) :
1612+ ss L R t u ->
1613+ SSim.ss (flipL L) (flip R) u t ->
1614+ sb L R t u.
1615+ Proof .
1616+ split; cbn; intros.
1617+ - apply H in H1 as (? & ? & ? & ? & ?); eauto.
1618+ - apply H0 in H1 as (? & ? & ? & ? & ?); eauto.
1619+ Qed .
1620+
1621+ End withParam.
1622+
1623+ (* Bisimilarity entails co-similarity. *)
1624+ Lemma ssim_sbisim {E C X} (t u : ctree E C X) :
1625+ t ≃ u ->
1626+ ssim Leq t u /\ ssim Leq u t.
1627+ Proof .
1628+ intros SB.
1629+ split.
1630+ - coinduction r cih.
1631+ intros ?? TR.
1632+ playL in SB.
1633+ answer.
1634+ now rewrite EQ.
1635+ - coinduction r cih.
1636+ intros ?? TR.
1637+ playR in SB.
1638+ answer.
1639+ now rewrite EQ.
1640+ now simpL.
1641+ Qed .
15991642
16001643End SBisim_vs_SSim.
16011644
@@ -1608,59 +1651,176 @@ Section Two_ss_is_not_sb.
16081651 ss Leq RR t t' ->
16091652 ss Leq (flip RR) t' t ->
16101653 sb Leq RR t t'.
1611- Admitted .
1654+ Proof .
1655+ intros * fwd bwd.
1656+ play.
1657+ apply fwd in TR as (? & ? & ? & ? & ?); answer.
1658+ apply bwd in TR as (? & ? & ? & ? & ?); answer.
1659+ now rewrite flipL_Leq.
1660+ Qed .
16121661
16131662 Lemma split_sbisim_eq {E B X} (t u : ctree E B X) :
16141663 t ≃ u <-> ss Leq (sbisim Leq) t u /\ ss Leq (sbisim Leq) u t.
1615- Admitted .
1664+ Proof .
1665+ split; intro.
1666+ - step in H. split; [apply H |].
1667+ symmetry in H. apply H.
1668+ - step. split; [apply H |].
1669+ destruct H as [_ ?].
1670+ (* todo: this should be nicer *)
1671+ eapply lequiv_ss; [apply flipL_Leq |].
1672+ cbn; intros.
1673+ apply H in H0 as (? & ? & ? & ? & ?); answer.
1674+ symmetry; auto.
1675+ Qed .
16161676
16171677 (*|
16181678 A concrete counter-example: [Step (Ret tt)] and [brS2 (Ret tt) Stuck]
16191679 are mutually [ssim]-related but not [sbisim]-related.
16201680 | *)
16211681 Lemma ssim_sbisim_nequiv :
16221682 exists (t1 t2 : ctree void1 B2 unit),
1623- ssim Leq t1 t2 /\ ssim Leq t2 t1 /\ ≃ sbisim Leq t1 t2.
1624- Admitted .
1683+ ssim Leq t1 t2 /\ ssim Leq t2 t1 /\ ~ sbisimeq t1 t2.
1684+ Proof .
1685+ exists (Step (Ret tt)), (brS2 (Ret tt) (Stuck)).
1686+ intuition.
1687+ - unfold brS2.
1688+ step.
1689+ intros ?? TR.
1690+ inv_trans; subst.
1691+ exists τ, (α (Ret tt)); split3.
1692+ apply trans_br with true; etrans.
1693+ now rewrite EQ.
1694+ eauto.
1695+ - step; intros ?? TR.
1696+ inv_trans.
1697+ exists τ, (α (Ret tt)); intuition; now rewrite EQ.
1698+ exists τ, (α (Ret tt)). intuition.
1699+ rewrite EQ; apply ssim_stuck.
1700+ - step in H. cbn in H. destruct H as [_ ?].
1701+ specialize (H τ Stuck). lapply H; [| etrans].
1702+ intros. destruct H0 as (? & ? & ? & ? & ?).
1703+ inv_trans. step in H1. cbn in H1. destruct H1 as [? _].
1704+ specialize (H0 (val tt) Stuck). lapply H0.
1705+ 2: subst; etrans.
1706+ intro; destruct H1 as (? & ? & ? & ? & ?).
1707+ inv_trans.
1708+ Qed .
16251709
16261710End Two_ss_is_not_sb.
16271711
16281712Section SBisim_vs_CSSim.
16291713
1630- Context {E F C D : Type -> Type } {X Y : Type }
1631- {L : lrel E F X Y}.
1632-
1633- Notation css := (@css E F C D X Y).
1634- Notation cssim := (@cssim E F C D X Y).
1635-
1636- Lemma sb_css (R : rel _ _) (t : ctree E C X) (u : ctree F D Y) :
1637- sb L R t u -> css L R t u.
1638- Admitted .
1639-
1640- Lemma css_sb (R : rel _ _) (t : ctree E C X) (u : ctree F D Y) :
1641- css L R t u ->
1642- css (flipL L) (flip R) u t ->
1643- sb L R t u.
1644- Admitted .
1645-
1646- Lemma sbisim_clos_css {c : Chain (css L)} :
1647- forall x y, @sbisim_clos E F C D X Y Leq Leq `c x y -> `c x y.
1648- Admitted .
1649-
1650- #[global] Instance sbisim_eq_clos_css_goal {R : Chain (css L)} :
1651- Proper (sbisim Leq ==> sbisim Leq ==> flip impl) `R.
1652- Admitted .
1653-
1654- #[global] Instance sbisim_eq_clos_css_ctx {R : Chain (css L)} :
1655- Proper (sbisim Leq ==> sbisim Leq ==> impl) `R.
1656- Admitted .
1714+ Section withParam.
1715+
1716+ Context {E F C D : Type -> Type } {X Y : Type }
1717+ {L : lrel E F X Y}.
16571718
1658- #[global] Instance sbisim_eq_clos_cssim_goal :
1659- Proper (sbisim Leq ==> sbisim Leq ==> flip impl) (cssim L).
1660- Admitted .
1719+ Notation css := (@css E F C D X Y).
1720+ Notation cssim := (@cssim E F C D X Y).
16611721
1662- #[global] Instance sbisim_eq_clos_cssim_ctx :
1663- Proper (sbisim Leq ==> sbisim Leq ==> impl) (cssim L).
1664- Admitted .
1722+ Tactic Notation "dec3" ident(h) "as "
1723+ simple_intropattern(a) simple_intropattern(b) simple_intropattern(c)
1724+ := destruct h as (a & b & c).
1725+
1726+ #[global] Instance sbisim_css_chain_goal {c : Chain (css L)} :
1727+ Proper (sbisimeq ==> sbisimeq ==> flip impl) `c.
1728+ Proof .
1729+ apply tower.
1730+ - intros ? INC x y EQ x' y' EQ' ?? HP; red.
1731+ eapply INC; eauto.
1732+ eapply leq_infx in HP.
1733+ now apply HP.
1734+ - clear.
1735+ intros c IH x y EQ x' y' EQ'; split.
1736+ + intros ?? TR.
1737+ playL in EQ.
1738+ play in H.
1739+ playR in EQ'.
1740+ answer.
1741+ eapply IH; eauto.
1742+ now simpL.
1743+ + intros (? & ? & TR).
1744+ playL in EQ'.
1745+ destruct H as [_ LIV].
1746+ dec3 LIV as ? ? TR'; eauto.
1747+ playR in EQ.
1748+ eauto.
1749+ Qed .
1750+
1751+ #[global] Instance sbisim_css_chain_ctx {c : Chain (css L)} :
1752+ Proper (sbisimeq ==> sbisimeq ==> impl) `c.
1753+ Proof .
1754+ apply tower.
1755+ - intros ? INC x y EQ x' y' EQ' ?? HP; red.
1756+ eapply INC; eauto.
1757+ eapply leq_infx in HP.
1758+ now apply HP.
1759+ - clear.
1760+ intros c IH x y EQ x' y' EQ'; split.
1761+ + intros ?? TR.
1762+ playR in EQ.
1763+ play in H.
1764+ playL in EQ'.
1765+ answer.
1766+ eapply IH; eauto.
1767+ now simpL.
1768+ + intros (? & ? & TR).
1769+ playR in EQ'.
1770+ destruct H as [_ LIV].
1771+ dec3 LIV as ? ? TR'; eauto.
1772+ playL in EQ.
1773+ eauto.
1774+ Qed .
1775+
1776+ #[global] Instance sbisim_cssim_goal :
1777+ Proper (sbisim Leq ==> sbisim Leq ==> flip impl) (cssim L).
1778+ Proof .
1779+ repeat intro; eapply sbisim_css_chain_goal; eauto.
1780+ Qed .
1781+
1782+ #[global] Instance sbisim_cssim_ctx :
1783+ Proper (sbisim Leq ==> sbisim Leq ==> impl) (cssim L).
1784+ Proof .
1785+ repeat intro; eapply sbisim_css_chain_ctx; eauto.
1786+ Qed .
1787+
1788+ Lemma css_sb (R : rel _ _) (t : ctree E C X) (u : ctree F D Y) :
1789+ css L R t u ->
1790+ CSSim.css (flipL L) (flip R) u t ->
1791+ sb L R t u.
1792+ Proof .
1793+ split; cbn; intros.
1794+ - apply H in H1 as (? & ? & ? & ? & ?); eauto.
1795+ - apply H0 in H1 as (? & ? & ? & ? & ?); eauto.
1796+ Qed .
1797+
1798+ End withParam.
1799+
1800+ (* Bisimilarity entails co-similarity. *)
1801+ Lemma sbisim_cssim {E C X} (t u : ctree E C X) :
1802+ t ≃ u ->
1803+ cssim Leq t u /\ cssim Leq u t.
1804+ Proof .
1805+ intros SB.
1806+ split.
1807+ - coinduction r cih.
1808+ split.
1809+ + intros ?? TR.
1810+ playL in SB.
1811+ answer.
1812+ now rewrite EQ.
1813+ + intros (? & ? & TR).
1814+ playR in SB; eauto.
1815+ - coinduction r cih.
1816+ split.
1817+ + intros ?? TR.
1818+ playR in SB.
1819+ simpL.
1820+ answer.
1821+ now rewrite EQ.
1822+ + intros (? & ? & TR).
1823+ playL in SB; eauto.
1824+ Qed .
16651825
16661826End SBisim_vs_CSSim.
0 commit comments