%% Simulation in the finite pi-calculus is a "pre-congruence"
%%
%% (a "pre-congruence" is a congruence without the symmetric relation
%% requirement).
%%
%% It should be straightforward to extend this script to prove that
%% (open) bisimulation is a congruence.
%%
%% Eventually, the adjective "finite" should be removed by allowing
%% the bang operator in pi-calculus expressions.
Specification "finite-pic".
Import "finite-pic".
Theorem sim_cong_null :
sim null null.
unfold.
- intros !A !P1 Hstep. case Hstep.
- intros !X !M Hstep. case Hstep.
- intros !X !M Hstep. case Hstep.
Theorem sim_cong_taup :
forall P Q, sim P Q -> sim (taup P) (taup Q).
intros !P !Q Hsim. unfold.
- intros !A !P1 Hstep. case Hstep. search.
- intros !X !M Hstep. case Hstep.
- intros !X !M Hstep. case Hstep.
Theorem sim_cong_plus :
forall P Q R S, sim P Q -> sim R S -> sim (plus P R) (plus Q S).
intros !P !Q !R !S HsimPQ HsimRS. unfold.
% Case 1: free action; left/right plus subcases
- intros !A !P1 HstepPlus. Hstep : case HstepPlus.
+ HsimPQFree : case HsimPQ. apply HsimPQFree to Hstep. search.
+ HsimRSFree : case HsimRS. apply HsimRSFree to Hstep. search.
% Case 2: bound input action; left/right plus subcases
- intros !X !M HstepPlus. HstepDn : case HstepPlus.
+ _ HsimPQDn : case HsimPQ. apply HsimPQDn to HstepDn. search.
+ _ HsimRSDn : case HsimRS. apply HsimRSDn to HstepDn. search.
% Case 3: bound output action; left/right plus subcases
- intros !X !M HstepPlus. HstepUp : case HstepPlus.
+ _ _ HsimPQUp : case HsimPQ. apply HsimPQUp to HstepUp. search.
+ _ _ HsimRSUp : case HsimRS. apply HsimRSUp to HstepUp. search.
Theorem sim_cong_match :
forall P Q X Y, sim P Q -> sim (match X Y P) (match X Y Q).
intros !P !Q !X !Y HsimPQ. unfold.
- intros !A !P1 HmatchStep. Hstep : case HmatchStep.
HsimPQFree : case HsimPQ. apply HsimPQFree to Hstep. search.
- intros !X1 !M HmatchStep. HstepDn : case HmatchStep.
_ HsimPQDn : case HsimPQ. apply HsimPQDn to HstepDn. search.
- intros !X1 !M HmatchStep. HstepUp : case HmatchStep.
_ _ HsimPQUp : case HsimPQ. apply HsimPQUp to HstepUp. search.
Theorem sim_cong_out :
forall P Q X Y, sim P Q -> sim (out X Y P) (out X Y Q).
intros !P !Q !X !Y Hsim. unfold.
- intros !A !P1 Hstep. case Hstep. search.
- intros !X1 !M Hstep. case Hstep.
- intros !X1 !M Hstep. case Hstep.
Theorem sim_cong_in :
forall P Q X, (forall W, sim (P W) (Q W)) -> sim (in X P) (in X Q).
intros !P !Q !X Hsim. unfold.
- intros !A !P1 Hstep. case Hstep.
- intros !X1 !M HstepIn. case HstepIn. exists Q. split.
+ search.
+ intros !W. apply Hsim with W = W. search.
- intros !X1 !M Hstep. case Hstep.
% Now define an invariant inductively
Define inv : proc -> proc -> prop by
inv P Q := sim P Q ;
inv (par P1 P2) (par Q1 Q2) := inv P1 Q1 /\ inv P2 Q2 ;
inv (nu P) (nu Q) := nabla x, inv (P x) (Q x).
% We could inline this since it only appears once. That is, the
% simInv predicate is the result of applying the body of `sim' once
% to inv.
Define simInv : proc -> proc -> prop by
simInv P Q :=
(forall A P1, {one P A P1} -> exists Q1, {one Q A Q1} /\ inv P1 Q1) /\
(forall X M, {oneb P (dn X) M} -> exists N, {oneb Q (dn X) N} /\
forall W, inv (M W) (N W)) /\
(forall X M, {oneb P (up X) M} -> exists N, {oneb Q (up X) N} /\
nabla w, inv (M w) (N w)).
% We now show that 'inv' is a post-fixed point of simulation.
Theorem inv_simInv :
forall P Q, inv P Q -> simInv P Q.
IHinv : induction on 1. intros !P !Q HinvPQ. case HinvPQ.
% Subgoal 1: sim P Q
- HsimPQ =>
HsimFree HsimDn HsimUp : case HsimPQ. unfold.
+ intros !A !P1 HstepP. apply HsimFree to HstepP. search.
+ intros !X !M HonebP. !N HonebQ HsimMN : apply HsimDn to HonebP.
exists N. split.
* search.
* intros !W. apply HsimMN with W = W. search.
+ intros !X !M HonebP. apply HsimUp to HonebP. search.
% Subgoal 2: P = P1|P2, Q = Q1|Q2, inv P1 Q1, inv P2 Q2
- !Q2 !Q1 !P2 !P1 HinvP1Q1 HinvP2Q2 =>
HsimInvP1Q1 : apply IHinv to HinvP1Q1.
HsimInvP2Q2 : apply IHinv to HinvP2Q2.
HsimInvP1Q1Free HsimInvP1Q1Dn HsimInvP1Q1Up : case HsimInvP1Q1.
HsimInvP2Q2Free HsimInvP2Q2Dn HsimInvP2Q2Up : case HsimInvP2Q2. unfold.
+ intros !A !P1 HstepPlus. case HstepPlus.
* !P4 HstepP => apply HsimInvP1Q1Free to HstepP. search.
* !Q3 HstepP2 => apply HsimInvP2Q2Free to HstepP2. search.
* !N !X !M HstepDn HstepUp =>
!N1 HonebQ2Up HinvNn1N1n1 : apply HsimInvP2Q2Up to HstepUp.
!N2 HonebQ1Dn HinvMWN2W : apply HsimInvP1Q1Dn to HstepDn.
exists (nu x\ par (N2 x) (N1 x)). split.
-- search.
-- apply HinvMWN2W with W = n1. search.
* !N !X !M HstepUp HstepDn =>
!N1 HonebQ1Up HinvMn1N1n1 : apply HsimInvP1Q1Up to HstepUp.
!N2 HonebQ2Dn HinvNWN2W : apply HsimInvP2Q2Dn to HstepDn.
exists (nu x\ par (N1 x) (N2 x)). split.
-- search.
-- apply HinvNWN2W with W = n1. search.
* !T !Y !X !M HstepDn HstepUp =>
!N HonebQ1Dn HinvMWNW : apply HsimInvP1Q1Dn to HstepDn.
!Q3 HoneQ2Up HinvTQ3 : apply HsimInvP2Q2Free to HstepUp.
exists (par (N Y) Q3). split.
-- search.
-- apply HinvMWNW with W = Y. search.
* !R !Y !X !M HstepDn HstepUp =>
!Q3 HoneQ1Up HinvRQ3 : apply HsimInvP1Q1Free to HstepUp.
!N HonebQ2Dn HinvMWNW : apply HsimInvP2Q2Dn to HstepDn.
exists (par Q3 (N Y)). apply HinvMWNW with W = Y. search.
+ intros !X !M HstepPar. case HstepPar.
* HstepDn =>
!N HonebQ1Dn HsimM1N : apply HsimInvP1Q1Dn to HstepDn.
exists (x\ par (N x) Q2). split.
-- search.
-- intros !W. apply HsimM1N with W = W. search.
* HstepDn =>
!N1 HonebQ2Dn HsimNN1 : apply HsimInvP2Q2Dn to HstepDn.
exists (x\ par Q1 (N1 x)). split.
-- search.
-- intros !W. apply HsimNN1 with W = W. search.
+ intros !X !M HstepPar. case HstepPar.
* HstepUp => apply HsimInvP1Q1Up to HstepUp. search.
* HstepUp => apply HsimInvP2Q2Up to HstepUp. search.
% Subgoal 3: P = nu P1, Q = nu Q1, inv (P1 n1), inv (Q1 n1)
- !Q1 !P1 HinvNu =>
HsimInvNu : apply IHinv to HinvNu.
HsimInvNuFree HsimInvNuDn HsimInvNuUp : case HsimInvNu. unfold.
+ intros !A !P3 HstepNu. Hstep : case HstepNu.
apply HsimInvNuFree to Hstep. search.
+ intros !X !M HonebNu. HstepDn : case HonebNu.
!N HonebQ HinvQ2N : apply HsimInvNuDn to HstepDn.
exists (x\ nu (y\ N y x)). split.
* search.
* intros !W. apply HinvQ2N with W = W. search.
+ intros !X !M HonebNu. case HonebNu.
* HstepUp => apply HsimInvNuUp to HstepUp. search.
* HstepNu => apply HsimInvNuFree to HstepNu. search.
% We can now conclude that inv is a simulation.
Theorem inv_sim :
forall P Q, inv P Q -> sim P Q.
CH : coinduction. intros !P !Q HinvPQ.
HsimInvPQ : apply inv_simInv to HinvPQ.
HsimFree HsimDn HsimUp : case HsimInvPQ. unfold.
- intros !A !P1 HstepP. _ HinvP1Q1 : apply HsimFree to HstepP.
apply CH to HinvP1Q1. search.
- intros !X !M HonebP. !N HonebQ HinvMN : apply HsimDn to HonebP.
exists N. split.
+ search.
+ intros !W. HinvMWNW : apply HinvMN with W = W.
apply CH to HinvMWNW. search.
- intros !X !M HonebP. HonebQ HinvMn1Nn1 : apply HsimUp to HonebP.
apply CH to HinvMn1Nn1. search.
% The fact that inv is a post-fixed point is used to prove the final
% two theorems regarding the pre-congruence of sim.
Theorem sim_cong_par :
forall P Q R S, sim P Q -> sim R S -> sim (par P R) (par Q S).
intros !P !Q !R !S HsimPQ HsimRS.
HinvPar : assert inv (par P R) (par Q S).
apply inv_sim to HinvPar. search.
Theorem sim_cong_nu :
forall P Q, nabla w, sim (P w) (Q w) -> sim (nu P) (nu Q).
intros !P !Q HsimAll.
HinvNu : assert inv (nu P) (nu Q).
apply inv_sim to HinvNu. search.