Kind name,action,proc type.
Import "ccs_core".
Import "ccs_ctx".
Import "ccs_bisim".
Import "ccs_context".
Define bisim_context_t : proc -> proc -> proc -> proc -> prop by
bisim_context_t P1 P3 Q1 Q3 :=
exists P2 Q2, bisim_t P1 P2 Q1 Q2 /\ context_t P2 P3 Q2 Q3.
Theorem bisim_context_t_reflexive : forall P, bisim_context_t P P P P.
intros !P. unfold. witness P. witness P. split.
- backchain bisim_t_reflexive.
- search.
Theorem bisim_context_reflexive : forall P, bisim_up_to bisim_context_t P P.
CH : coinduction. intros !P. unfold.
- intros !_ !Pnext.
witness Pnext. split.
+ search.
+ witness Pnext. witness Pnext. split.
* unfold. witness Pnext. witness Pnext. split.
-- unfold.
++ backchain bisim_reflexive_.
++ backchain bisim_reflexive_.
-- search.
* backchain *CH.
- intros !_ !Qnext.
witness Qnext. split.
+ search.
+ witness Qnext. witness Qnext. split.
* unfold. witness Qnext. witness Qnext. split.
-- unfold.
++ backchain bisim_reflexive_.
++ backchain bisim_reflexive_.
-- search.
* backchain *CH.
Theorem bisim_context_t_contexts : forall C P1 P2 Q1 Q2,
at C P2 P1 -> at C Q2 Q1 ->
bisim_context_t P1 P2 Q1 Q2.
intros !C !P1 !P2 !Q1 !Q2. unfold. witness P1. witness Q1. split.
- unfold.
+ backchain bisim_reflexive_.
+ backchain bisim_reflexive_.
- search.
Theorem bisim_substitutive_ : forall C P1 Q1 P2 Q2,
at C P1 Q1 -> at C P2 Q2 ->
bisim_up_to refl_t P1 P2 ->
bisim_up_to refl_t Q1 Q2.
Hsub : apply bisim_substitutive.
HsubSpec : case Hsub.
intros !C !P1 !Q1 !P2 !Q2.
backchain HsubSpec.
Theorem ctx_mirror : forall C P1 P2 Q1, at C P1 P2 -> exists Q2, at C Q1 Q2.
IH : induction on 1. intros !_ !_ !_ !Q1 HatCtx. case HatCtx.
- search.
- HatCtxSub => apply IH to *HatCtxSub with Q1 = Q1. search.
- HatCtxSub => apply IH to *HatCtxSub with Q1 = Q1. search.
- HatCtxSub => apply IH to *HatCtxSub with Q1 = Q1. search.
- HatCtxSub => apply IH to *HatCtxSub with Q1 = Q1. search.
- HatCtxSub => apply IH to *HatCtxSub with Q1 = Q1. search.
Theorem bisim_context_substitutive :
substitutive_rel (bisim_up_to bisim_context_t).
unfold. CH : coinduction.
intros !P1 !P2 !C !Q1 !Q2 HatCtxP1 HatCtxP2 HbisimCtx.
unfold.
% from P
- intros !_ !Pstep Hone.
Hfaith : apply ctx_faithful to *HatCtxP1 *Hone.
case Hfaith.
+ _ HfaithAll =>
!RR : apply *HfaithAll to *HatCtxP2.
witness RR. split.
* search.
* witness P1. witness P2. split.
-- backchain bisim_context_t_contexts.
-- backchain *CH.
+ HoneP1 HatCtx HctxAll =>
HbisimFwd HbisimBwd : case HbisimCtx.
!_ !Pmid !Qmid HoneP2 HbisimCtx2 : apply *HbisimFwd to *HoneP1.
HctxAll2 : apply *HctxAll to *HoneP2.
!RR _ HatCtxQ3 : apply *HctxAll2 to *HatCtxP2.
witness RR. split.
* search.
* !Psub !Qsub HbisimT HctxT : case HbisimCtx2.
HatCtxP4 HatCtxQ4 : case HctxT.
HbisimReflP HbisimReflQ : case HbisimT.
HatCtxPsub : apply ctx_mirror to HatCtx with Q1 = Psub.
HatCtxQsub : apply ctx_mirror to HatCtxQ3 with Q1 = Qsub.
apply bisim_substitutive_ to *HatCtx HatCtxPsub *HbisimReflP.
apply bisim_substitutive_ to *HatCtxQ3 HatCtxQsub *HbisimReflQ.
apply concat_ctx2 to *HatCtxP4 *HatCtxPsub *HatCtxQ4 *HatCtxQsub.
witness Pmid. witness Qmid. split.
-- search.
-- backchain *CH.
+ HoneAll =>
apply *HoneAll to *HatCtxP2.
witness Pstep. split.
* search.
* witness Pstep. witness Pstep. split.
-- backchain bisim_context_t_reflexive.
-- backchain *CH. backchain bisim_context_reflexive.
% from Q
- intros !_ !Qstep Hone.
Hfaith : apply ctx_faithful to *HatCtxP2 *Hone.
case Hfaith.
+ _ HfaithAll =>
!RR : apply *HfaithAll to *HatCtxP1.
witness RR. split.
* search.
* witness P1. witness P2. split.
-- backchain bisim_context_t_contexts.
-- backchain *CH.
+ HoneP2 HatCtx HctxAll =>
HbisimFwd HbisimBwd : case HbisimCtx.
!_ !Pmid !Qmid HoneP1 HbisimCtx2 : apply *HbisimBwd to *HoneP2.
HctxAll2 : apply *HctxAll to *HoneP1.
!RR _ HatCtxP3 : apply *HctxAll2 to *HatCtxP1.
witness RR. split.
* search.
* !Psub !Qsub HbisimT HctxT : case HbisimCtx2.
HatCtxP4 HatCtxQ4 : case HctxT.
HbisimReflP HbisimReflQ : case HbisimT.
HatCtxPsub : apply ctx_mirror to HatCtx with Q1 = Psub.
HatCtxQsub : apply ctx_mirror to HatCtxP3 with Q1 = Qsub.
apply bisim_substitutive_ to *HatCtx HatCtxQsub *HbisimReflQ.
apply bisim_substitutive_ to *HatCtxP3 HatCtxPsub *HbisimReflP.
apply concat_ctx2 to *HatCtxP4 *HatCtxPsub *HatCtxQ4 *HatCtxQsub.
witness Pmid. witness Qmid. split.
-- search.
-- backchain *CH.
+ HoneAll =>
apply *HoneAll to *HatCtxP1.
witness Qstep. split.
* search.
* witness Qstep. witness Qstep. split.
-- backchain bisim_context_t_reflexive.
-- backchain *CH. backchain bisim_context_reflexive.
Theorem bisim_context_sound_fst : is_sound_fst bisim_context_t.
unfold. CH : coinduction. intros !P !Q Hbis.
HbisimPR HbisimCtx HbisimSQ : case Hbis.
unfold.
% from P
- intros !_ !_ Hone.
HbisimPFwd HbisimPBwd : case HbisimPR.
clear HbisimPBwd.
!_ !Pnext HoneR Hrefl HbisimMid : apply HbisimPFwd to *Hone.
clear HbisimPFwd.
case Hrefl.
HbisimRFwd HbisimRBwd : case HbisimCtx.
clear HbisimRBwd.
HoneS HbisimCtx2 HbisimUp2 : apply HbisimRFwd to *HoneR.
clear HbisimRFwd.
HbisimSFwd HbisimSBwd : case HbisimSQ.
clear HbisimSBwd.
!_ !_ !Qnext _ HreflQ : apply HbisimSFwd to *HoneS.
clear HbisimSFwd.
case HreflQ.
witness Qnext. split.
+ search.
+ witness Pnext. witness Qnext. split.
* search.
* !Psub !Qsub HbisimT HctxT : case HbisimCtx2.
HbisimReflQ HbisimReflP : case HbisimT.
HbisimPLink : assert bisim_up_to refl_t Pnext Psub.
-- backchain bisim_transitive_.
-- HbisimCtxLink : assert bisim_up_to bisim_context_t Psub Qsub.
++ Lem : apply bisim_context_substitutive. Lem : case Lem.
case HctxT. backchain Lem.
++ HbisimQLink : assert bisim_up_to refl_t Qsub Qnext.
** apply bisim_symmetric_ to *HbisimReflP.
backchain bisim_transitive_.
** clear HbisimMid. backchain *CH.
% from Q
- intros !_ !_ Hone.
HbisimSFwd HbisimSBwd : case HbisimSQ.
!_ !_ !Qnext HoneS Hrefl : apply HbisimSBwd to *Hone.
HbisimRFwd HbisimRBwd : case HbisimCtx.
HoneR HbisimCtx2 HbisimUp2 : apply HbisimRBwd to *HoneS.
HbisimPFwd HbisimPBwd : case HbisimPR.
!_ !Pnext _ HreflP HbisimFin : apply HbisimPBwd to *HoneR.
clear HbisimSFwd HbisimSBwd HbisimRFwd HbisimRBwd HbisimPFwd HbisimPBwd.
case Hrefl.
case HreflP.
witness Pnext. split.
+ search.
+ witness Pnext. witness Qnext. split.
* search.
* !Psub !Qsub HbisimT HctxT : case HbisimCtx2.
HbisimReflQ HbisimReflP : case HbisimT.
HbisimPLink : assert bisim_up_to refl_t Pnext Psub.
-- backchain bisim_transitive_.
-- HbisimCtxLink : assert bisim_up_to bisim_context_t Psub Qsub.
++ Lem : apply bisim_context_substitutive. Lem : case Lem.
case HctxT. backchain Lem.
++ HbisimQLink : assert bisim_up_to refl_t Qsub Qnext.
** apply bisim_symmetric_ to *HbisimReflP.
backchain bisim_transitive_.
** clear HbisimFin. backchain *CH.
Theorem bisim_context_sound_snd : is_sound_snd bisim_context_t.
unfold. intros !P !Q HbisimCtx.
witness P. witness Q. split.
- backchain bisim_reflexive_.
- search.
- backchain bisim_reflexive_.
Theorem bisim_context_sound : is_sound bisim_context_t.
unfold. intros !P !Q HbisimCtx.
Snd : apply bisim_context_sound_snd. Snd : case Snd.
Fst : apply bisim_context_sound_fst. Fst : case Fst.
apply Snd to *HbisimCtx. backchain Fst.