% flag to use fancy fonts / graphics
\newif\ifjnf\jnftrue

\documentclass[11pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{cmtt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{url}
\usepackage[margin=1in]{geometry}
\usepackage{mathpartir}

\usepackage{csnotes}
\newtheorem{proposition}{Proposition}

% local definitions for this lecture
%\newcommand{\lam}[2]{\ensuremath{\lambda #1.\,#2}}
%\newcommand{\definedas}{\ensuremath{\triangleq}}
\newcommand{\subst}[3]{\ensuremath{#1[#2/#3]}}
\newcommand{\bnf}{\ensuremath{\; \mid \;}}
\newcommand{\parcompcompact}[2]{\ensuremath{#1|#2}}
\newcommand{\parcomp}[2]{\ensuremath{#1 \mid #2}}
\newcommand{\comp}[2]{\ensuremath{#1;#2}}
\newcommand{\new}[2]{\ensuremath{\mathsf{new}~#1~#2}}
\newcommand{\step}[1]{\ensuremath{\overset{#1}{\rightarrow}}}
\newcommand{\estep}[1]{\ensuremath{\overset{#1}{\Rightarrow}}}
\newcommand{\hole}{\square}

\newcommand{\defeq}{\ensuremath{\overset{\Delta}{=}}}
\newcommand{\defiff}{\ensuremath{\overset{\Delta}{\iff}}}
\newcommand{\rel}[3]{\ensuremath{#1\mathcal{#2}#3}}

\begin{document}

\header{13 September 2011}{Raghu Rajkumar}

\section{Review of CCS}
\[ P ::= A \langle \overrightarrow{a} \rangle \bnf
        \sum_{i \in \mathcal{I}} \alpha_{i}.P_{i} \bnf \parcompcompact{P_1}{P_2} \bnf \new{a}{P}
\]

\section{Alegebraic Properties of Bisimilarity}
An example of of the kinds of properties exhibited by bisimilarity is $\parcompcompact{a}{b} \sim a.b + b.a$

\begin{proposition}
 $\forall P.~ P \sim \sum \{\alpha.P' \mid P \step{\alpha} P'\}$
\end{proposition}

\noindent
The summation is well-formed, since $P'$ can contain only a finite number of parallel compositions and sums over finite domains.

\begin{proposition}~
  
  $\begin{array}{lcl}
   \forall P_1\ldots P_n. \\
   \parcomp{\parcomp{P_1}{\ldots}}{P_n} 
      & \sim 
        & \sum \{\alpha.(\parcomp{\parcomp{\parcomp{\parcomp{P_1}{\ldots}}{P_i'}}{\ldots}}{P_n}) \mid P_i \step{\alpha} P_i' ~\wedge~ 1 \leq i \leq n \} \\
      & + 
        & \sum \{\tau . (\parcomp{\parcomp{\parcomp{\parcomp{\parcomp{\parcomp{P_1}{\ldots}}{P_i'}}{\ldots}}{P_j'}}{\ldots}}{P_n}) \\
      & & \qquad \qquad \mid P_i \step{\lambda} P_i' ~\wedge~ P_j \step{\bar{\lambda}} P_j' ~\wedge~ 1 \leq i < j \leq n \}
  \end{array}$
\end{proposition}


\begin{proposition}[Expansion Law]~

    $\begin{array}{lcl}
   \forall P_1\ldots P_n, \overrightarrow{a}. \\
   \new{\overrightarrow{a}}{\parcomp{\parcomp{P_1}{\ldots}}{P_n}}
      & \sim 
        & \sum \{\alpha.\new{\overrightarrow{a}}{(\parcomp{\parcomp{\parcomp{\parcomp{P_1}{\ldots}}{P_i'}}{\ldots}}{P_n})} \\
        & & \qquad \qquad \mid P_i \step{\alpha} P_i' ~\wedge~ 1 \leq i \leq n ~\wedge~ \alpha, \bar{\alpha} \notin \overrightarrow{a}\} \\
      & + 
        & \sum \{\tau . \new{\overrightarrow{a}}{(\parcomp{\parcomp{\parcomp{\parcomp{\parcomp{\parcomp{P_1}{\ldots}}{P_i'}}{\ldots}}{P_j'}}{\ldots}}{P_n})} \\
      & & \qquad \qquad \mid P_i \step{\lambda} P_i' ~\wedge~ P_j \step{\bar{\lambda}} P_j' ~\wedge~ 1 \leq i < j \leq n ~\wedge~ \lambda, \bar{\lambda} \notin \overrightarrow{a}\}
  \end{array}$
  
\end{proposition}

\subsection{Expansion Law at Work}
 Consider the following process.

\begin{center}
\begin{minipage}[t] {2in}
\begin{center}
% \begin{align*}
% 	D &= a. \tau .D^^\prime \\
% 	D^^\prime &= a.D^{^\prime^\prime} + \bar{c}.D \\
% 	D^{^\prime^\prime} &= \bar{c}. \tau .D^^\prime
% \end{align*}
\begin{mathpar}
 A = a.A' \and b = b.B' \\
 A' = \bar{b}.A \and B' = \bar{c}.B \\
 \new{b}{(\parcomp{A}{B}})
\end{mathpar} 
\end{center}
\end{minipage}
\begin{minipage}[t] {4in}
\begin{center}
\begin{flushright}
 ~
\end{flushright}

\begin{tikzpicture}
	\node (AB) at (0,0) {new $b(A \vert B)$};
	\node (ApB) at (3,0) {new $b(A^\prime \vert B)$}
		edge [<-,bend right=15] node[auto,swap] {$a$} (AB);
	\node (ABp) at (6,0) {new $b(A \vert B^\prime)$}
		edge [<-,bend right=15] node[auto,swap] {$\tau$} (ApB)
		edge [->,bend left=30] node[auto] {$\bar{c}$} (AB);
	\node (ApBp) at (6,2) {new $b(^\prime \vert B^\prime)$}
		edge [<-,bend left=15] node[auto] {$a$} (ABp)
		edge [->,bend right=20] node[auto,swap] {$\bar{c}$} (ApB);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}


By the expansion law, the following properties hold for the above system.

$$\begin{array}{lcl}
  \new{b}{(\parcomp{A}{B}}) &\sim& a. \new{b}{(\parcomp{A'}{B}}) \\
  \new{b}{(\parcomp{A'}{B}}) &\sim& \tau. \new{b}{(\parcomp{A}{B'})} \\
  \new{b}{(\parcomp{A}{B'})} &\sim& a. \new{b}{(\parcomp{A'}{B'})} + \bar{c}. \new{b}{(\parcomp{A'}{B}}) \\
  \new{b}{(\parcomp{A'}{B'})} &\sim& \bar{c}. \new{b}{(\parcomp{A'}{B}}) \\
 \end{array}$$




\section{Sequential Composition as a Derived Form}
We can express sequential composition in CCS as 
$$\comp{P}{Q} = \new{start}{(\parcomp{\subst{P}{start}{done}}{start.Q})}$$
where $P$ signals $\overline{done}$ when it finishes.

\subsubsection*{Exercise}
Show that $\comp{(\comp{P}{Q})}{R} \sim \comp{P}{(\comp{Q}{R})}$

\subsection{Congruence}
  An \textbf{elementary context} is a expression with one hole at the top-level. For instance, the elementary contexts for processes are
\[ E ::= \sum_{i \in \mathcal{I}} \alpha_{i}.P_{i} + \alpha.\hole + \sum_{j \in \mathcal{J}} \alpha_{j}.P_{j} \bnf \parcompcompact{\hole}{P} \bnf \parcompcompact{P}{\hole} \bnf \new{a}{\hole}
\]  

\noindent
  A \textbf{congruence} is a relation closed under substitution in related contexts. \\
  $C$ is a congruence $\iff$ $P~C~Q$ implies $E[P]~C~E[Q]$ for all processes $P$,$Q$ and elementary contexts $E$. 

\begin{proposition}[$\sim$ is a congruence]
 ~ \\[1ex] \indent
 If $P \sim Q$ then
\begin{itemize}
 \item $\alpha.P + M \sim \alpha.Q + M $
 \item $\new{a}{P} \sim \new{a}{Q}$
 \item $\parcompcompact{P}{R} \sim \parcompcompact{Q}{R}$
 \item $\parcompcompact{R}{P} \sim \parcompcompact{R}{Q}$
\end{itemize}

\end{proposition}

\section{Experiment LTS}
\begin{definition}
  An \textbf{experiment} is a sequence $\lambda_1, \ldots, \lambda_n \in \mathcal{L}^*$.
\end{definition}

\noindent
  Based on the labeled transition system (\step{}) we defined for CCS, we now define an \textbf{experiment LTS}, whose transitions will be denoted by $\estep{}$.
\begin{itemize}
 \item $P \estep{} Q \defiff \underbrace{P \step{} \ldots \step{} Q}_{\text{0 or more steps}}$
 \item $P \estep{e} Q \defiff P \estep{} \step{\alpha_1} \step{\alpha_2} \ldots \step{\alpha_n} P_n \estep{} Q$ \\
       where $e = \alpha_1 \ldots \alpha_n$
\end{itemize}

\noindent
We can intuitively interpret each type of transition as follows

\begin{tabular}{l|l}
 $\estep{}$ & 0 or more reactions \\
 $\estep{\tau}$ & 1 or more reactions \\
 $\estep{e}$ & Performing experiment e \\
\end{tabular}

\begin{definition}
 A binary relation $\mathcal{S}$ is a \textbf{weak simulation} if and only if, \\
 $(\rel{P}{S}{Q} \wedge P \estep{e} P')$ implies $\exists Q'.~ (Q \estep{e} Q' \wedge \rel{P'}{S}{Q'})$.
\end{definition}
\noindent
We say $Q$ weakly simulates $P$ if there exists a weak simulation $\mathcal{S}$ such that $\rel{P}{S}{Q}$.

\begin{definition}[Weak Bisimulation]
 ~\\
 A binary relation $\mathcal{S}$ is a weak bisimulation if both $\mathcal{S}$ and its converse $\mathcal{S}^{-1}$ are weak simulations.
\end{definition}

\begin{definition}[Weak Bisimilarity]
  ~\\
 $P$ is weakly bisimilar to $Q$, written $P \approx Q$, if there exists a weak bisimulation $\mathcal{S}$ such that $\rel{P}{S}{Q}$.
\end{definition}

\begin{proposition}
 $\mathcal{S}$ is a weak bisimulation if and only if the following hold whenever $\rel{P}{S}{Q}$.
 \begin{enumerate}
  \item If $P \step{} P'$ then $\exists Q'.~ Q \estep{} Q' \wedge \rel{P'}{S}{Q'}$
  \item If $P \step{\lambda} P'$ then $\exists Q'.~ Q \estep{\lambda} Q' \wedge \rel{P'}{S}{Q'}$
 \end{enumerate}

\begin{center}
\begin{minipage}[t] {0.4\linewidth}
\begin{center}
\begin{tikzpicture}
	\node (P) at (-0.5,1) {$P$};
	\node (S) at (0,1) {$\mathcal{S}$};
	\node (Q) at (0.5,1) {$Q$};

	\node (Pp) at (-1,-0.5) {$P^\prime$}
		edge [<-] node[left] {} (P);
        \node at (-0.5, -0.5) {$\sim$};
	\node (Sp) at (0,-0.5) {$\mathcal{S}$};
        \node at (0.5, -0.5) {$\sim$};
	\node (Qp) at (1,-0.5) {$Q^\prime$}
		edge [<-, double] node[right] {} (Q);
        \node (label) at (0, -1.15) {(1)};
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}[t] {0.4\linewidth}
\begin{center}
\begin{tikzpicture}
	\node (P) at (-0.5,1) {$P$};
	\node (S) at (0,1) {$\mathcal{S}$};
	\node (Q) at (0.5,1) {$Q$};

	\node (Pp) at (-1,-0.5) {$P^\prime$}
		edge [<-] node[left] {$\lambda$} (P);
        \node at (-0.5, -0.5) {$\sim$};
	\node (Sp) at (0,-0.5) {$\mathcal{S}$};
        \node at (0.5, -0.5) {$\sim$};
	\node (Qp) at (1,-0.5) {$Q^\prime$}
		edge [<-, double] node[right] {$\lambda$} (Q);
        \node (label) at (0, -1.15) {(2)};
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\end{proposition}

\begin{proposition} ~
 \begin{enumerate}
  \item $\approx$ is an equivalence relation.
  \item $\approx$ is a weak bisimulation. (In fact, it is the largest one).
  \item Every strong bisimulation is a weak bisimulation.
  \item Similar to the definition of strong bisimulation up to congruence, we can define weak bisimulation up to strong bisimulation.
 \end{enumerate}
\end{proposition}


\begin{proposition}
  The following subset relation holds: 
$= \ \subseteq \ \equiv \ \subseteq \ \sim \ \subseteq \ \approx$
\end{proposition}

\begin{proposition}
  If $\mathcal{S}$ is a weak bisimulation up to strong bisimulation and $\rel{P}{S}{Q}$, then $P \approx Q$
\end{proposition}

\end{document}

