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

\documentclass[11pt]{article}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage[margin=1in]{geometry}

\usepackage{csnotes}

\begin{document}

\header{6 September 2011}{Norris Xu}

\section{Review: Structural Congruence}
Definition of Structural Congruence [$\equiv$]:
\begin{enumerate}
    \item $\alpha$-conversion
    \item Re-order sums
    \item $P|0 \equiv P$, $P|Q \equiv Q|P$, $P|(Q|R) \equiv (P|Q)|R$
    \item $\mathsf{new} \; a \; (P|Q) \equiv (\mathsf{new} \; a \; Q)|P$ if $a
        \notin \mathsf{fv}(P)$, $\mathsf{new} \; a \; 0 \equiv 0$, $\mathsf{new}
        \; a, b \; P \equiv \mathsf{new} \; b, a \; P$
    \item $A \langle \vec{b} \rangle \equiv \{\vec{b}/\vec{a}\} P_{A}$
        where $A(\vec{a}) = P_{A}$
\end{enumerate}

\section{CCS}
\subsection{Definitions}
\begin{flalign*}
    & & \mathcal{L} & ::= \mathcal{N} \cup \overline{\mathcal{N}} & \lambda, \mu,
        \ldots & & \text{Labels} & & \\
    & & \mathsf{Act} & ::= \mathcal{L} \cup \{\tau\} & \alpha, \beta, \ldots & &
        \text{Actions} & & \\
    & & P & ::= A \langle a_1, \ldots, a_n \rangle \; \left.\left| \;
        \sum_{i \in I} \alpha_{i}.P_{i} \; \right| \; P_{1} | P_{2} \; \right|
        \; \mathsf{new} \; a \; P & P, Q, \ldots & & \text{Processes} & &
\end{flalign*}

\subsection{Operational Semantics Rules}
$$\frac{}{(a.P + M) | (\overline{a}.Q + N) \rightarrow P | Q} \; \text{React}
    \qquad \frac{P \rightarrow P'}{P|Q \rightarrow P'|Q} \; \text{Par} \qquad
    \frac{P \rightarrow P'}{\mathsf{new} \; a \; P \rightarrow \mathsf{new} \; a
    \; P'} \; \text{Res}$$
$$\frac{}{\tau.P + M \rightarrow P} \; \text{Tau} \qquad \frac{Q \equiv P \quad
    P \rightarrow P' \quad P' \equiv Q'}{Q \rightarrow Q'} \; \text{Struct}$$

\subsection{Example: Lottery}
Suppose we wish to model a lottery. There is a set of $N$ balls with outcomes
written on them, and we want to non-deterministically choose a ball, output its
outcome, and reset to the initial state. We can use the following definitions:
\begin{flalign*}
    \text{Lottery} & = \tau.b_{1}.\text{Lottery} + \ldots +
        \tau.b_{n}.\text{Lottery} \\
    \text{Main} & = (\text{Lottery} | \overline{b_{1}}.P_{1} | \ldots |
        \overline{b_{n}}.P_{n})
\end{flalign*}
This definition simulates a one-ball lottery. The process Lottery picks a ball
$i$ and sends the corresponding action $b_{i}$, which reacts with the
corresponding parallel observer process $\overline{b_{i}}.P_{i}$, triggering the
appropriate reward process $P_{i}$. We could also extend this to a multi-ball
lottery by adding more actions to the observer processes:
$\overline{b_{i}}.\overline{b_{j}}.\overline{b_{k}}.P_{ijk}$. However, we must
take care to avoid having a $b_{i}$ possibly interact with the wrong
$\overline{b_{i}}$ in a process; i.e., if the second ball drawn is $b_{i}$, we
don't want that action to react with a process that has $\overline{b_{i}}$ as
its first action.

We can also use the following alternative definitions:
\begin{flalign*}
    & & A(a, b, c) & = \overline{a}.C \langle a, b, c \rangle \\
    & & B(a, b, c) & = \overline{b}.C \langle a, b, c \rangle \\
    & & C(a, b, c) & = \tau.B \langle a, b, c \rangle + c.A \langle a, b, c
        \rangle \\
    & & A_{i} & = A \langle a_{i}, b_{i}, a_{i + 1} \rangle & &
        \text{for $i \in \{1, 2, 3\}$, with $3 + 1 = 1$} & & \\
    & & B_{i} & = B \langle a_{i}, b_{i}, a_{i + 1} \rangle \\
    & & C_{i} & = C \langle a_{i}, b_{i}, a_{i + 1} \rangle \\
    & & L_{1} & = \mathsf{new} \; a_{1}, a_{2}, a_{3} \; (C_{1}|A_{2}|A_{3}) \\
    & & L_{2} & = \mathsf{new} \; a_{1}, a_{2}, a_{3} \; (A_{1}|C_{2}|A_{3}) \\
    & & L_{3} & = \mathsf{new} \; a_{1}, a_{2}, a_{3} \; (A_{1}|A_{2}|C_{3})
\end{flalign*}
To see how this works, we start by expanding the definition of $L_{1}$:
$$L_{1} = \mathsf{new} \; a_{1}, a_{2}, a_{3} \; (C_{1}|A_{2}|A_{3}) \equiv
    \mathsf{new} \; a_{1}, a_{2}, a_{3} \; (\tau.B \langle a_{1}, b_{1}, a_{2}
    \rangle + a_{2}.A \langle a_{1}, b_{1}, a_{2} \rangle | A_{2}|A_{3})$$
Thus from $L_{1}$, we can take one of two actions: either $\tau$, or $a_{2}$. In
the latter case, we get (after $a_{2}$ reacts with $\overline{a_{2}}$ in $A_{2}$):
$$\mathsf{new} \; a_{1}, a_{2}, a_{3} \; (A \langle a_{1}, b_{1}, a_{2} \rangle
    | C \langle a_{2}, b_{2}, a_{3} \rangle | A_{3}) \equiv L_{2}$$
In the former case, we get:
$$\mathsf{new} \; a_{1}, a_{2}, a_{3} \; (b_{1}.C \langle a_{1}, b_{1}, a_{2}
    \rangle | A_{2}|A_{3}) \equiv \mathsf{new} \; a_{1}, a_{2}, a_{3} \;
    (b_{1}.C_{1} | A_{2}|A_{3})$$
Once the $b_{1}$ reacts with an external observer process, we are left with
$L_{1}$. Thus at each of the $L_{i}$, we can either draw a ball $b_{i}$ or
transition to $L_{i + 1}$.

\section{CCS as an LTS}

\subsection{Operational Semantics Rules}
$$\frac{}{M + \alpha.P + N \xrightarrow{\alpha} P} \; \text{L-Sum} \qquad
\frac{P \xrightarrow{\lambda} P' \quad Q \xrightarrow{\overline{\lambda}}
    Q'}{P|Q \xrightarrow{\tau} P'|Q'} \; \text{L-React} \qquad \frac{P
    \xrightarrow{\alpha} P' \quad \alpha \notin \{a,
    \overline{a}\}}{\mathsf{new} \; a \; P \xrightarrow{\alpha} \mathsf{new} \;
    a \; P'} \; \text{L-Res}$$
$$\frac{P \xrightarrow{\alpha} P'}{P|Q \xrightarrow{\alpha} P'|Q} \; \text{L-Par
    L} \qquad \frac{Q \xrightarrow{\alpha} Q'}{P|Q \xrightarrow{\alpha} P|Q'} \;
    \text{L-Par R} \qquad \frac{\{\vec{b}/\vec{a}\} P_{A} \xrightarrow{\alpha}
    P' \quad A(\vec{a}) = P_{A}}{A \langle \vec{b} \rangle \xrightarrow{\alpha}
    P'} \; \text{L-Ident}$$
%
There are two important things to notice. The first is that we no longer make
use of structural congruence; consequently, we now require separate rules for
left- and right-parallel composition, and we need summands on both sides for the
L-Sum rule. The second thing to notice is that in the L-React rule, since
$\lambda$ is internal to the process, we label the transition with $\tau$ so
that $\lambda$ is hidden from any external processes. Also, we still have
$\alpha$-equivalence for $\mathsf{new} \; a \; P$ expressions: $\mathsf{new} \;
a \; P = \mathsf{new} \; b \; P\{b/a\}$ for any other label $b$.

\subsection{Theorems}
First, we want to show that even though we no longer have a structural
congruence rule, structural congruence in fact still holds. We therefore have
the following theorem:
\begin{theorem}
If $P \xrightarrow{\alpha} P'$ and $P \equiv Q$, then $\exists Q'$ such that $Q
    \xrightarrow{\alpha} Q'$ and $Q' \equiv P'$.
\end{theorem}
\begin{proof}
    Here is a partial proof, containing only a few subcases. Proof by induction
    on $P \xrightarrow{\alpha} P'$. Case L-Par L: $P = P_{1}|P_{2}$, $P_{1}
    \xrightarrow{\alpha} P_{1}'$, $P' = P_{1}'|P_{2}$. Consider $P \equiv Q$. We
    now look at all of the ways $Q$ could be structurally congruent to $P$:
   
   Subcase $Q = P_{2}|P_{1}$. Then let $Q' = P_{2}|P_{1}'$. By L-Par R, $Q
   \xrightarrow{\alpha} Q'$. \checkmark

   Subcase $Q = Q_{1}|P_{2}$, $Q_{1} \equiv P_{1}$. By the induction hypothesis,
   $\exists Q_{1}'$ such that $Q_{1} \xrightarrow{\alpha} Q_{1}'$, $Q_{1}'
   \equiv P_{1}$. By L-Par L, $Q \xrightarrow{\alpha} Q_{1}'|P_{2} \equiv P'$.
   Then let $Q' = Q_{1}'|P_{2}$. \checkmark
\end{proof}

We would also like to show that the transitions in this system correspond to
those in the original CCS:
\begin{theorem}
$P \rightarrow P'$ iff $P \xrightarrow{\tau} \equiv P'$ (where
$\xrightarrow{\tau} \equiv$ indicates relational composition of
$\xrightarrow{\tau}$ and $\equiv$).
\end{theorem}

\end{document}

