Theory Strong_Bisim_SC

(* 
   Title: The Calculus of Communicating Systems   
   Author/Maintainer: Jesper Bengtson (jebe@itu.dk), 2012
*)
theory Strong_Bisim_SC
  imports Strong_Sim_SC Strong_Bisim_Pres Struct_Cong
begin

lemma resNil:
  fixes x :: name

  shows "⦇νx𝟬  𝟬"
proof -
  have "(⦇νx𝟬, 𝟬)  {(⦇νx𝟬, 𝟬), (𝟬, ⦇νx𝟬)}" by simp
  thus ?thesis
    by(coinduct rule: bisimCoinduct)
      (auto intro: resNilLeft resNilRight)
qed

lemma scopeExt:
  fixes x :: name
  and   P :: ccs
  and   Q :: ccs

  assumes "x  P"

  shows "⦇νx(P  Q)  P  ⦇νxQ"
proof -
  let ?X = "{(⦇νx(P  Q), P  ⦇νxQ) | x P Q. x  P}  {(P  ⦇νxQ, ⦇νx(P  Q)) | x P Q. x  P}"
  from assms have "(⦇νx(P  Q), P  ⦇νxQ)  ?X" by auto
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (force intro: scopeExtLeft scopeExtRight)+
qed

lemma sumComm:
  fixes P :: ccs
  and   Q :: ccs

  shows "P  Q  Q  P"
proof -
  have "(P  Q, Q  P)  {(P  Q, Q  P), (Q  P, P  Q)}" by simp
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (auto intro: sumComm reflexive)
qed

lemma sumAssoc:
  fixes P :: ccs
  and   Q :: ccs
  and   R :: ccs

  shows "(P  Q)  R  P  (Q  R)"
proof -
  have "((P  Q)  R, P  (Q  R))  {((P  Q)  R, P  (Q  R)), (P  (Q  R), (P  Q)  R)}" by simp
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (auto intro: sumAssocLeft sumAssocRight reflexive)
qed

lemma sumId:
  fixes P :: ccs

  shows "P  𝟬  P"
proof -
  have "(P  𝟬, P)  {(P  𝟬, P), (P, P  𝟬)}" by simp
  thus ?thesis by(coinduct rule: bisimCoinduct) (auto intro: sumIdLeft sumIdRight reflexive) 
qed

lemma parComm:
  fixes P :: ccs
  and   Q :: ccs

  shows "P  Q  Q  P"
proof -
  have "(P  Q, Q  P)  {(P  Q, Q  P) | P Q. True}  {(Q  P, P  Q) | P Q. True}" by auto
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (auto intro: parComm)
qed

lemma parAssoc:
  fixes P :: ccs
  and   Q :: ccs
  and   R :: ccs

  shows "(P  Q)  R  P  (Q  R)"
proof -
  have "((P  Q)  R, P  (Q  R))  {((P  Q)  R, P  (Q  R)) | P Q R. True}   
                                     {(P  (Q  R), (P  Q)  R) | P Q R. True}" by auto
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (force intro: parAssocLeft parAssocRight)+
qed

lemma parId:
  fixes P :: ccs

  shows "P  𝟬  P"
proof -
  have "(P  𝟬, P)  {(P  𝟬, P) | P. True}  {(P, P  𝟬) | P. True}" by simp
  thus ?thesis by(coinduct rule: bisimCoinduct) (auto intro: parIdLeft parIdRight)
qed

lemma scopeFresh:
  fixes x :: name
  and   P :: ccs

  assumes "x  P"

  shows "⦇νxP  P"
proof -
  have "⦇νxP  ⦇νxP  𝟬" by(rule parId[THEN symmetric])
  moreover have "⦇νxP  𝟬  𝟬  ⦇νxP" by(rule parComm)
  moreover have "𝟬  ⦇νxP  ⦇νx(𝟬  P)" by(rule scopeExt[THEN symmetric]) auto
  moreover have "⦇νx(𝟬  P)  ⦇νx(P  𝟬)" by(rule resPres[OF parComm])
  moreover from x  P have "⦇νx(P  𝟬)  P  ⦇νx𝟬" by(rule scopeExt)
  moreover have  "P  ⦇νx𝟬  ⦇νx𝟬  P" by(rule parComm)
  moreover have "⦇νx𝟬  P  𝟬  P" by(rule parPres[OF resNil])
  moreover have "𝟬  P  P  𝟬" by(rule parComm)
  moreover have "P  𝟬  P" by(rule parId)
  ultimately show ?thesis by(metis transitive)
qed

lemma scopeExtSum:
  fixes x :: name
  and   P :: ccs
  and   Q :: ccs

  assumes "x  P"

  shows "⦇νx(P  Q)  P  ⦇νxQ"
proof -
  have "(⦇νx(P  Q), P  ⦇νxQ)  {(⦇νx(P  Q), P  ⦇νxQ), (P  ⦇νxQ, ⦇νx(P  Q))}"
    by simp
  thus ?thesis using x  P
    by(coinduct rule: bisimCoinduct) 
      (auto intro: scopeExtSumLeft scopeExtSumRight reflexive scopeFresh scopeFresh[THEN symmetric])
qed

lemma resAct:
  fixes x :: name
  and   α :: act
  and   P :: ccs

  assumes "x  α"

  shows "⦇νx(α.(P))  α.(⦇νxP)"
proof -
  have "(⦇νx(α.(P)), α.(⦇νxP))  {(⦇νx(α.(P)), α.(⦇νxP)), (α.(⦇νxP), ⦇νx(α.(P)))}"
    by simp
  thus ?thesis using x  α
    by(coinduct rule: bisimCoinduct) (auto intro: resActLeft resActRight reflexive)
qed

lemma resComm:
  fixes x :: name
  and   y :: name
  and   P :: ccs

  shows "⦇νx(⦇νyP)  ⦇νy(⦇νxP)"
proof -
  have "(⦇νx(⦇νyP), ⦇νy(⦇νxP))  {(⦇νx(⦇νyP), ⦇νy(⦇νxP)) | x y P. True}" by auto
  thus ?thesis
  by(coinduct rule: bisimCoinduct) (auto intro: resComm)
qed

lemma bangUnfold:
  fixes P

  shows "!P  P  !P"
proof -
  have "(!P, P  !P)  {(!P, P  !P), (P  !P, !P)}" by auto
  thus ?thesis
    by(coinduct rule: bisimCoinduct) (auto intro: bangUnfoldLeft bangUnfoldRight reflexive)
qed

lemma bisimStructCong:
  fixes P :: ccs
  and   Q :: ccs

  assumes "P s Q"

  shows "P  Q"
using assms
apply(nominal_induct rule: Struct_Cong.strong_induct)
by(auto intro: reflexive symmetric transitive parComm parAssoc parId sumComm
   sumAssoc sumId resNil scopeExt scopeExtSum resAct resComm bangUnfold)   

end