<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% flag to use fancy fonts / graphics
\newif\ifjnf\jnftrue

\documentclass[11pt]{article}

\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usepackage{cmtt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{url}
\usepackage[margin=1in]{geometry}
\usepackage{float}
\usepackage{csnotes}
\usepackage{multicol}

% local definitions for this lecture
\setbox0=\hbox{$\tt\global\chardef\ttfam=\the\fam$}
\newcommand{\thickbar}
{\hbox to\fontdimen2\textfont\ttfam{\hss\the\textfont\ttfam [$\!\!$]\hss}}

\tolerance = 200

\begin{document}

\header{15 September 2011}{Jonathan Tse}

\section{Weak Bisimuluation Discussion}

\subsection{Processes $P$ and $D$}

Building on our discussion of weak bisimulation from last class, we return to
the following two processes from last week, $P$ and $D$, shown in Figures
\ref{fig:process_P} and \ref{fig:process_D} respectively.

% Process P
\begin{figure}[H]
\begin{center}
\begin{minipage}{2in}
% Definition for Process P
\begin{align*}
A &amp;= a \cdot A^{\prime}         \\
A^{\prime} &amp;= \bar{b} \cdot A   \\
B &amp;= b \cdot B^{\prime}         \\
B^{\prime} &amp;= \bar{c} \cdot B   \\
P &amp;= \mathrm{new}~b (A | B)   
\end{align*}
\end{minipage}
\begin{minipage}{4in}
% Transition Graph for Process P
\begin{center}
\begin{tikzpicture}[auto]
    \node (AB)                  {$\mathrm{new}~b(A|B)$};
    \node (ApB)  [right=of AB]  {$\mathrm{new}~b(A^\prime|B)$};
    \node (ABp)  [right=of ApB] {$\mathrm{new}~b(A|B^\prime)$};
    \node (ApBp) [below=of ABp] {$\mathrm{new}~b(A^\prime|B^\prime)$};

    \draw [-&gt;] (AB)   to node {$a$}       (ApB);
    \draw [-&gt;] (ApB)  to node {$\tau$}    (ABp);
    \draw [-&gt;] (ABp)  to node {$a$}       (ApBp);
    \draw [-&gt;] (ABp)  to [bend right] node [swap] {$\bar{c}$} (AB);
    \draw [-&gt;] (ApBp) to [bend left] node {$\bar{c}$} (AB);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\caption{Process $P$ and its transition graph}
\label{fig:process_P}
\end{figure}

% Process D
\begin{figure}[H]
\begin{center}
\begin{minipage}{3in}
% Definition for Process D
\begin{align*}
D &amp;= a \cdot \tau \cdot D^{\prime}                          \\
D^{\prime} &amp;= a \cdot D^{\prime\prime} + \bar{c} \cdot D    \\
D^{\prime\prime} &amp;= \bar{c} \cdot \tau \cdot D^{\prime} 
\end{align*}
\end{minipage}
\begin{minipage}{3in}
% Transition Graph for Process D
\begin{center}
\begin{tikzpicture}[auto]
    \node (AB)                  {$D$};
    \node (ApB)  [right=of AB]  {$\tau \cdot D^\prime$};
    \node (ABp)  [right=of ApB] {$D^\prime$};
    \node (ApBp) [below=of ABp] {$D^{\prime\prime}$};

    \draw [-&gt;] (AB)   to node {$a$}       (ApB);
    \draw [-&gt;] (ApB)  to node {$\tau$}    (ABp);
    \draw [-&gt;] (ABp)  to node {$a$}       (ApBp);
    \draw [-&gt;] (ABp)  to [bend right=60] node [swap] {$\bar{c}$} (AB);
    \draw [-&gt;] (ApBp) to [bend left] node {$\bar{c}$} (AB);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\caption{Process $D$ and its transition graph}
\label{fig:process_D}
\end{figure}

\subsection{Showing Weak Bisimulation}
\label{subsec:showing_weak_bisimulation}

We showed last week that $P \sim D$, i.e they are strong bisimulations of
one another.  This should be fairly obvious from inspecting their transition
graphs. We'd like to show that the following process $E$ is weak
bisimulation of both $P$ and $D$, i.e. $E \approx P$ and $E \approx D$.

We can do this by proving that $E \approx P$.  Recall that the whole point of
weak bisimulation is to capture the specification of a process without having to
deal with the implementation details, i.e. internal transitions.

$E$ is shown below in Figure \ref{fig:process_E}.

% Process E
\begin{figure}[H]
\begin{center}
\begin{minipage}{3in}
% Definition for Process E
\begin{align*}
E &amp;= a \cdot E^{\prime}                                  \\
E^{\prime} &amp;= a \cdot E^{\prime\prime} + \bar{c} \cdot E  \\
E^{\prime\prime} &amp;= \bar{c} \cdot E^{\prime}               
\end{align*}
\end{minipage}
\begin{minipage}{3in}
% Transition Graph for Process E
\begin{center}
\begin{tikzpicture}[auto,bend left]
    \node (E)                 {$E$};
    \node (Ep)  [right=of E]  {$E^{\prime}$};
    \node (Epp) [right=of Ep] {$E^{\prime\prime}$};

    \draw [-&gt;] (E)   to node {$a$}       (Ep);
    \draw [-&gt;] (Ep)  to node {$a$}       (Epp);
    \draw [-&gt;] (Epp) to node {$\bar{c}$} (Ep);
    \draw [-&gt;] (Ep)  to node {$\bar{c}$} (E);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\caption{Process $E$ and its transition graph}
\label{fig:process_E}
\end{figure}

Looking at the transition systems for $P$ and $E$ in Figures \ref{fig:process_P}
and \ref{fig:process_E}, it's apparent that they aren't strong bisimulations of
one another, but it's not clear that they are weak bisimulations.  In order to
\textit{prove} that they are weak bisimulations of one another, we have to find
the set $S$ of pairs of states that satisfy the weak bisimulation criteria shown
in Figure \ref{fig:weak_bisimulation_criteria}.


\begin{figure}[H]
\begin{center}
\begin{minipage}{3in}
\begin{center}
\begin{tikzpicture}[auto]
    \node (P)  at (0,2) {$P$};
    \node (S)  at (1,2) {$S$};
    \node (Q)  at (2,2) {$Q$};
    \node (Pp) at (0,0) {$P^\prime$}; 
    \node (Sp) at (1,0) {$\sim S \sim$}; 
    \node (Qp) at (2,0) {$Q^\prime$}; 

    \draw [-&gt;] (P)  to [bend right] node [swap] {$\lambda$} (Pp);
    \draw [-&gt;,double distance=2pt] (Q)  to [bend left] node {$\lambda$} (Qp);
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}{3in}
\begin{center}
\begin{tikzpicture}[auto]
    \node (P)  at (0,2) {$P$};
    \node (S)  at (1,2) {$S$};
    \node (Q)  at (2,2) {$Q$};
    \node (Pp) at (0,0) {$P^\prime$}; 
    \node (Sp) at (1,0) {$\sim S \sim$}; 
    \node (Qp) at (2,0) {$Q^\prime$}; 

    \draw [-&gt;] (P)  to [bend right]  (Pp);
    \draw [-&gt;,double distance=2pt] (Q) to [bend left] (Qp);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\caption{Weak Bisimulation Criteria}
\label{fig:weak_bisimulation_criteria}
\end{figure}

We can now construct $S$ using Figures \ref{fig:process_P}, \ref{fig:process_E},
and \ref{fig:weak_bisimulation_criteria} as follows:

\begin{align*}
S = \{&amp;(\mathrm{new}~b(A|B),E), \\
      &amp;(\mathrm{new}~b(A^\prime|B),E^\prime), \\
      &amp;(\mathrm{new}~b(A|B^\prime),E^\prime), \\
      &amp;(\mathrm{new}~b(A^\prime|B^\prime),E^{\prime\prime})\}
\end{align*}

So long as the pairs in set $S$ are representative of the states of the
processes and they satisfy the criteria from Figure
\ref{fig:weak_bisimulation_criteria}, we can say that $E \approx P$.  This in
turn implies that $E \approx D$ as well.

\subsection{Additional Examples}

One might be tempted to assume that we can simply collapse any $\tau$
transitions in a process in order to show weak bisimulation.  While this
intuition is a good starting point, it does NOT hold in all cases, as in Figure
\ref{fig:PQR_tau_transitions} where $P \not\approx Q \not\approx R$.


\begin{figure}[H]
\begin{center}
\begin{minipage}[t]{1.25in}
\[
    P = a + b
\]
\begin{center}
\begin{tikzpicture}[auto]
    \node (A) at ( 0, 0) [circle,draw] {};
    \node (B) at (-1,-1) [circle,draw] {};
    \node (C) at ( 1,-1) [circle,draw] {};
    
    \draw [-&gt;] (A) to node [swap] {$a$} (B);
    \draw [-&gt;] (A) to node {$b$} (C);
\end{tikzpicture}
\end{center}
\end{minipage}
\hspace{0.5in}
\begin{minipage}[t]{1.25in}
\[
    Q = a + \tau \cdot b
\]
\begin{center}
\begin{tikzpicture}[auto]
    \node (A) at ( 0, 0) [circle,draw] {};
    \node (B) at (-1,-1) [circle,draw] {};
    \node (C) at ( 1,-1) [circle,draw,fill] {};
    \node (D) at ( 1,-2) [circle,draw] {};    

    \draw [-&gt;] (A) to node [swap] {$a$} (B);
    \draw [-&gt;] (A) to node {$\tau$} (C);
    \draw [-&gt;] (C) to node {$b$} (D);
\end{tikzpicture}
\end{center}
\end{minipage}
\hspace{0.5in}
\begin{minipage}[t]{1.25in}
\[
    R = \tau \cdot a + \tau \cdot b
\]
\begin{center}
\begin{tikzpicture}[auto]
    \node (A) at ( 0, 0) [circle,draw] {};
    \node (B) at (-1,-1) [circle,draw,fill] {};
    \node (C) at ( 1,-1) [circle,draw,fill] {};
    \node (D) at (-1,-2) [circle,draw] {};
    \node (E) at ( 1,-2) [circle,draw] {};    

    \draw [-&gt;] (A) to node [swap] {$\tau$} (B);
    \draw [-&gt;] (A) to node {$\tau$} (C);
    \draw [-&gt;] (B) to node [swap] {$a$} (D);
    \draw [-&gt;] (C) to node {$b$} (E);
\end{tikzpicture}
\end{center}
\end{minipage}
\end{center}
\caption{Transition Graphs for $P$, $Q$, and $R$.  Filled in nodes denote states
which cannot bisimulate states of $P$.}
\label{fig:PQR_tau_transitions}
\end{figure}

In Figure \ref{fig:PQR_tau_transitions}, we claim that $P \not\approx Q$.  We'll
now show a proof sketch by contradiction.

Suppose $P \approx Q$.  Then $\exists$ a weak bisimulation $S$ such that $P S
Q$. This would imply the following:

\begin{itemize}
\item $Q \rightarrow b \cdot 0$
\item $\exists P^\prime \mathrm{such~that}~P \Rightarrow P^\prime \mathrm{and}~P S b \cdot 0$
\item $P = P^\prime \mathrm{implies}~ P S b \cdot 0$
\end{itemize}

However, $P$ can do $P \overset{a}\rightarrow 0$ and $\overset{a}\Rightarrow$ doesn't
exist, therefore $S$ is not a weak bisimulation and $P \not\approx Q$.

\subsection{Weak Bisimulation as a \textit{Process Congruence}}

The following are facts:

\begin{itemize}
\item $P \approx \tau \cdot P$
\item $M + N + \tau \cdot N \approx M + \tau \cdot N \Rightarrow N + \tau \cdot N \approx \tau \cdot N$
\item $M + \alpha \cdot P + \alpha \cdot (\tau \cdot P + N) \approx M + \alpha \cdot (\tau \cdot P + N)$
\end{itemize}

Furthermore, $P \approx Q$ implies:

\begin{itemize}
\item $\alpha \cdot P + M \approx \alpha \cdot Q + M$
\item $\mathrm{new}~a~P \approx \mathrm{new}~a~Q$
\item $P|R \approx Q|R$
\item $R|P \approx R|Q$
\end{itemize}

Note that $N_1 \approx N_2 \not\Rightarrow M + N_1 \approx M + N_2$. A counter
example can be seen in Figure \ref{fig:PQR_tau_transitions} or in the following
system:

\begin{align*}
N_1 &amp;= b \\
N_2 &amp;= \tau \cdot b \\
M &amp;= a
\end{align*}

\section{Weak Bisimulation Examples}

\subsection{Agency vs Job Shop}

In this example, we will look at \textit{agents} and \textit{jobbers}.  They can
each do one of three types of jobs at a time: easy (E), neutral (N), or hard (H)
jobs.  The agents are experienced workers and can do one job at a time without
assistance, but the jobbers are new to the job--no pun intended--and require the
use of tools to accomplish any jobs harder than easy jobs.  They require the use
of a mallet to do neutral jobs, and a hammer to do hard jobs.  Note that they
can do neutral jobs with a hammer as well.  Once an agent or jobber is done they
will use an $\bar{o}$ transition to signal they have output, i.e. they are
ready for a new job.

We will first examine an agent, $A$. Two agents make up an \textit{Agency}.

\begin{align*}
A &amp;= \sum_{x\in\{E,N,D\}} i_x \cdot A^\prime \\
&amp;= i_E \cdot A^\prime + i_N \cdot A^\prime + i_D \\ \\
A^\prime &amp;= \bar{o} \cdot A \\ \\
Agency &amp;= A|A
\end{align*}

Jobbers $J$ and Job Shops are slightly more complicated.  They require the
mallets and hammers, and the actions $gm$ and $gh$ to get the mallet and
hammer--and the corresponding $pm$ and $ph$ to replace the tools.

\begin{align*}
M &amp;= gm \cdot M^\prime \\
M^\prime &amp;= pm \cdot M \\ \\
H &amp;= gh \cdot H^\prime \\
H^\prime &amp;= ph \cdot H \\ \\
J &amp;= \sum_{x\in\{E,N,D\}} i_x \cdot J^\prime \\ \\
J_E &amp;= \overline{o} \cdot J \\
J_N &amp;= \overline{gm} \cdot \overline{pm} \cdot J_E + \overline{gh} \cdot \overline{ph} \cdot J_E \\
J_D &amp;= \overline{gh} \cdot \overline{ph} \cdot J_D \\ \\
Job~Shop &amp;= \mathrm{new}~\vec{t}(H|M|J|J)
\end{align*}

We'd like to show that $Agency \approx Job~Shop$.  We can do this the same way
we showed $E \approx P$ in Section \ref{subsec:showing_weak_bisimulation}.

For $x,y\in\{E,N,D\}$,

\begin{align*}
S = \{ &amp;((A|A),~\text{new}~\vec{t}~(J|J|H|M)), \\
&amp;((A|A^\prime),~\text{new}~\vec{t}~(J|J_x|H|M)), \\
&amp;((A|A^\prime),~\text{new}~\vec{t}~(J|\overline{ph} \cdot J_E|H^\prime|M)), \\
&amp;((A|A^\prime),~\text{new}~\vec{t}~(J|\overline{pm} \cdot J_E|H|M^\prime), \\
&amp;((A^\prime|A^\prime),~\text{new}~\vec{t}~(J_y|J_x|H|M)), \\
&amp;((A^\prime|A^\prime),~\text{new}~\vec{t}~(J_y|\overline{ph}\cdot J_E|H^\prime|M)), \\
&amp;((A^\prime|A^\prime),~\text{new}~\vec{t}~(J_y|\overline{pm}\cdot J_E|H|M^\prime)), \\
&amp;((A^\prime|A^\prime),~\text{new}~\vec{t}~(\overline{ph} \cdot
J_E|\overline{pm}\cdot J_E|H^\prime|M^\prime))\}
\end{align*}

The system we just described has the Jobbers return the hammer and mallet to the
public tool set after they are done using them.  We could envision a system
where this is NOT the case, i.e. we kept holding the tool until we didn't need
it--we got an easy job, or we we need a better tool--we have the mallet but we
need the hammer.

If we have Jobbers that don't put down tools unless they have to, it could be
that for a Job Shop with two Jobbers, there is a trace where one Jobber is
starved for tools.  In other words, one Jobber is hogging the hammer or mallet.
If we have some notion of job ordering, and we submit three hard jobs in a 123
ordering we cannot have jobs finishing in the following orders: 312, 321, 213.

It's relatively clear why 3 cannot come first, but the 213 ordering is slightly
more subtle.  In this case, if a Jobber servicing job 2 picks up the hammer, he
will keep holding the hammer and service job 3, assuming the other Jobber is
servicing job 1.  Thus, if all three jobs are hard jobs, the only correct trace
is 231.

\subsection{Scheduler Example}

Now we're going to turn our attention to a token-ring based scheduler.  If we
look at a single node in the ring, it has 4 ports: $a,b,c,\bar{d}$.  $c$ and
$\bar{d}$ are for communicating to its neighbors in the ring and $a$ and $b$ are
for scheduling.

$a$ is connected to another process which requests a job start for the task
scheduled by that node.  $b$ is connected to the task scheduled by that node and
a communication action occurs when the task finishes.

Thus, the scheduler can be defined as follows.  $X$ defines the set of tasks
that are running.  $b_j$ represents a task in that set finishing, and $a_i$
represents a task at node $i$ starting.  We've loosened the syntax a little, so
$X-j$ is effectively a removal of $j$ from the set, i.e. the job at node $j$ has
finished.

\begin{equation}
Sched_{i,X} = \left\{
    \begin{array}{lr}
        \displaystyle\sum_{j \in X} b_j \cdot Sched_{i,X-j}  &amp; : i \in X \\
        \displaystyle\sum_{j \in X} b_j \cdot Sched_{i,X-j} + a_i \cdot Sched_{i+1,x:=x \cup i} &amp; : i \notin X
    \end{array} \nonumber 
\right. 
\end{equation}

The process $Scheduler$ is initialized as such:

\[
    Scheduler = Sched_{1,\emptyset} \nonumber
\]

Another way of defining the scheduler is shown below as $S$:

\begin{align*}
A_j &amp;= A&lt;a_i,b_i,c_i,c_{i-1}&gt; \\
A(a,b,c,d) &amp;= a \cdot c \cdot b \cdot \bar{d} \cdot A \\
A &amp;= a \cdot C \\
C &amp;= c \cdot B \\
B &amp;= b \cdot D \\
D &amp;= \bar{d} \cdot A \\
S &amp;= \text{new}~\vec{c}~(A_1|D_1|\ldots|D_n) 
\end{align*}

A sample partial trace of this process as follows:
\begin{enumerate}
\item $S$ takes an $a$ transition to:
\item $\text{new}~\vec{c}~(C_1|D_2|\ldots|D_n)$ transitions to
\item $\text{new}~\vec{c}~(B_1|A_2|D_2|\ldots|D_n)$
\end{enumerate}

We'd like to show that $S \approx Scheduler$, but it does \emph{NOT}.  Once you
get to the $C$ state in $S$, your neighbor MUST be ready to act on $\bar{d}$
before you can release on $b$.  In $Scheduler$, you can release your $b$ at any
time.  To fix this, we can change $S$ to be the following:

\begin{align*}
A &amp;= a \cdot C \\
C &amp;= c \cdot E \\
E &amp;= b\cdot D + \bar{d} \cdot  \\
B &amp;= b \cdot A \\
D &amp;= \bar{d} \cdot A \\
S &amp;= \text{new}~\vec{c}~(A_1|D_1|\ldots|D_n) 
\end{align*}

$E$ alloows us to terminate a process \emph{or} interact with our neighbor. This
new process $S \approx Scheduler$.
\end{document}
</pre></body></html>