% 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{csnotes}

\def\Line{\rule{5in}{0.1pt}}

\newcommand{\thickbar}{\ensuremath{[\!\!]}}

\begin{document}

\header{30 August 2011}{Stephen Longfield}

\begin {itemize}

\item The course: Advanced course in languages focusing on concurrency

\item First half: look at historical side of things, second half:
  papers

\item Each day there will be a scribe, who will take notes that will
  be posted on the course website.

\item Evaluation:
  \begin{itemize}
  \item Participation
  \item Course project
  \end{itemize}

\item 5 minutes at the end of class today to talk about forming up into groups
  \begin{itemize}
  \item Wants us to be in groups of 2 to 3 for the course projects
  \end{itemize}

\item Ideas for Projects:
  \begin{itemize}
  \item Open to anything that involves concurrency in some
    form. Should have producing a document that could be sent to some
    publication venue as a goal.
  \item Possible ideas:
    \begin{itemize}
    \item Survey paper -- look at a bunch of papers, put them in some
      common form, compare them.
    \item Hacking project -- implementing some general and reuseable
      system (interpreter?) in another language.
      \begin{itemize}
      \item $\pi$-calculus has an implementation called Pict; could
        use this to build an interpreter for another language.
      \item Proof assistant -- modeling a system formally, and
        checking the logic with a mechanical proof assistant.
      \end{itemize}
    \end {itemize}
  \item Also open to other kinds of project ideas.
  \end{itemize}

\item On the course webpage:
  \begin{itemize}
  \item \url{http://www.cs.cornell.edu/courses/CS6112/2011fa}
  \item Number changed to 6112.
  \item Course project preliminary proposal is due on September 11th
    (half page to one page).
  \item Project check-up at the end of October.
  \item Presentations on the last day of class, final writeup can be
    turned in then or a few days later.
  \end{itemize}
  
\item Course web page:
  \begin{itemize}
  \item Tentative plans in grey, solid plans in black.
  \item If there are things you really want to talk about, but is not
    on the list, please bring it up.
  \end{itemize}
  
\item Finishing up a few things from last time:
\item CSP:
\begin{align*}
a ::=& É (\text{arithmetic operations}) \\
b ::=& É (\text{boolean operations}) \\
c ::=& skip | x := a | \alpha ? x | \alpha ! x |  c \ \alpha | c_1 || c_2 | c_1; c_2 | \text{if } g \text{ fi} | \text{do } g \text{ od} \\
g ::=& b \rightarrow c | b \wedge \alpha ? x \rightarrow c | b \wedge \alpha ! a \rightarrow c | g_1 \thickbar g_2 \\
\end{align*}
\begin{itemize}
\item $g$ -- Dijkstra's guarded command syntax.
\item All of the operational semantics rules are represented in the
  CS4110 lecture notes, lectures 26-27.
  \url{http://www.cs.cornell.edu/Courses/cs4110/2010fa/lectures/lecture26.pdf}.
\end{itemize}

\item What do programs look like in this CSP language?
  \begin{itemize}
  \item $if ( x \leq y -> m!y \thickbar y \leq x -> m!x) fi$.
  \item This program sends the maximum of $x$ and $y$ over channel $m$.
  \item If they are equal, there is no way to distinguish which was
    sent.
  \item Remember that $\thickbar$ is actually a non-deterministic selection.
  \end{itemize}

\item Another example:
  \begin{itemize}
  \item $\text{do } (\text{true} \wedge \alpha ? x \rightarrow \beta!x) \text{ od}$
  \item Hooks up $\alpha$ to $\beta$
  \item Buffering!
  \item Remember that when receivers receive, they block
  \end{itemize}

\item One more example:
  \begin{itemize}
  \item $\text{do }( \text{true} \wedge \alpha ? x) -> \gamma !x \thickbar \text{true} \wedge \beta ? x -> \gamma ! x)\text{ od}$
  \item Nondeterministic merge from $\alpha$ and $\beta$.
  \end{itemize}

\item Are guards atomic?
  \begin{itemize}
  \item Yes! Once a guarded command begins, the two occurrences of $x$
    cannot interfere with each other.
  \end{itemize}

\item We might look at CHP at some point in the future
  \begin{itemize}
  \item Note to Async crew: figure out a good paper to look for that
  \end{itemize}

\item Starting point for the pi calculus: 
  \begin {itemize}
  \item Finite automata!
  \end {itemize}
  
\item Typically, we will present these graphically:
  
\item $L(A)$ -- language of strings over an automata, with internal
  symbols $\Sigma$

\item Two automata, $A_1$ and $A_2$ are considered to be equivalent if
  their languages are equivalent, $L(A_1) = L(A_2)$

\item The language that can be accepted by a finite automata can also
  be expressed as a regular expression (e.g., $a((bc+c)a)*$).

\item Kleene proved that the set of things that you can match with a
  regex is the same as the one that you can match with finite automata
  \begin{itemize}
  \item There are rich equational theories---e.g., Prof. Kozen has
    done work on this.
  \item Some examples of laws include:
    \begin {itemize}
    \item $R\epsilon = R$
    \item $R|S = S|R$
    \item $R|$
    \item $T(R|S) = TR|TS$
    \end{itemize}
  \end{itemize}

\item Expected to familiar with several operations on finite automata.
  \begin{itemize}
  \item There are a handful of operations and axioms that can be used
    to prove many things about them.
  \end{itemize}
	
\item Sequential computation: a trace through a finite automata.
  \begin{itemize}
  \item Can change a nondeterministic machine and embed it in a
    deterministic machine.
  \end{itemize}
  
\item Milner thinks that this is problematic:
  \begin{itemize}
  \item We will have graphs of a process, and we will interact with it
    by doing certain actions.
  \item Accepting alphabet is things that we can do, and bring us into
    different states.
  \item Different model of interaction with computers.
  \item Don't want to be so committed to equivalences that we get
    through some of the well-known transforms.
  \end{itemize}

\item Deterministic systems are very different to interact with than
  non-deterministic systems.
  \begin{itemize}
  \item Do not want axioms like $T(R|S) = TR|TS$, since which $T$ you
    pick matters in the second.
  \end{itemize}

\item Theory of simulations and bisimulations will be talking about
  today.

\item First thing:
  \begin {itemize}
  \item tweak our basic model of computation
  \end{itemize}
  
\item A Labeled Transition System (LTS) 
  \begin{itemize}
  \item Call it that instead of a finite automata.
  \item Get rid of final states -- any possible states are final states.
  \item Accepting strings are not the right kind of equivalence for LTS.
  \item Also, we will be getting rid of the start state.
    \begin{itemize}
    \item Will only be talking about what we can do from some arbitrary states.
    \end {itemize}
  \end{itemize}

\item An LTS is just a set of states and a transition relation.

\item Why is language equivalence not what we want for these kind of systems?

\item Milner likes to think about all the processes as black boxes.
  \begin{itemize}
  \item All you can see is what buttons you can press in each state.
  \item If you are in a state, you cannot press a button that is not active.
  \end{itemize}


\item State diagram for vending machine:
  \begin{center}
    \includegraphics[width=3in]{images/tea1}
  \end{center}
  \begin{itemize}
  \item From some state, you can insert a 2p coin in, and then you can get tea out of it, or you can insert another 2p coin and then get coffee out.
  \item Two kinds of actions:
    \begin{itemize}
    \item Actions that we can initiate (will be written normally), and actions that the system can initiate (will be written with an overbar).
    \end{itemize}
  \end{itemize}

\item Another automaton: 
  \begin{center}
    \includegraphics[width=3in]{images/tea2}
  \end{center}
  \begin{itemize}
  \item Inserting a 2p coin, you either go into a state where you can
    get tea, or into a state where you can insert another 2p coin, and
    then get coffee.
  \item The original is very much the one we want.
    \begin{itemize}
    \item This system, if the box chooses that you can get tea, then
      you can buy tea. However, it might force you to put in another
      2p coin to get coffee.
    \item Nondeterministic if you can get tea or coffee.
    \end{itemize}
  \end{itemize}

\item We don't need to distinguish bar actions from unbared actions in
  this example, but it will be useful in future systems.
  \begin{itemize}
  \item An example might be in a lottery system, where a bared action
    would be a win dispensing coins.
  \end{itemize}
  
\item Language equivalence doesn't work for these two systems:
  \begin{itemize}
  \item The two system we made up accept the same languages, however,
    they don't allow us to have the same modes of interactions.
  \end{itemize}

\item David Park and Milner worked out: theory of simulation and
  bisimulation (lots of varieties of these will be defiend in the next
  few weeks) that allows you to compare two different (possibly
  nondeterministic) systems, and say when they are behaving the same
  to some outside observer.
  \begin{itemize}
  \item We will be able to say that the two are equivalent or
    non-equivalent in some formal way
	\end{itemize}

\item Even more boiled down example: (really strong tea, eh?)
  \begin{center}
    \includegraphics[width=4in]{images/graph1}
  \end{center}
  \begin{itemize}
  \item These two will accept the same language, but they will not be
    the same, since the nondeterminism in the second state screws
    things up.
  \end{itemize}

\item In our formalization, we will be able to say if states are able
  to simulate other states.

\item if $p~S~q$, and $p$ can go to $p'$ through $a$, then there
  exists a $q'$ such that $q$ can go to $q'$ through $a$, and
  $p'~S~q'$.
  \begin{itemize}
  \item In this case, we will say that $q$ simulates $p$.
  \item $S$ needs to be big enough, that if we start to do something
    in $p$, then we can do something in $q$, and the property will still
    hold.
  \item Whenever we have something related by $S$, then both the state
    on the lefts and right can do something, and $S$ will still hold.
  \item $S$ is directional.
  \end{itemize}

\item When $S$ exists, we say that one state can simulate another.
  \begin{itemize}
  \item $S$ is not an equivalence relation -- it could be empty.
  \item We would like to build up to a notion of equivalence.
  \end{itemize}

\item Example:
  \begin{center}
    \includegraphics[width=5in]{images/graph2}
  \end{center}
  \begin{itemize}
  \item Would like to show that $p_0$ simulations $q_0$.
  \item $S$ will be a set of pairs of states: $S = \{ (q_0, p_0)\cdots \}$.
  \item Start by adding those states:
    \begin{itemize}
    \item For every $(q,p)$ in $S$, then if $q$ can transition through
      some action, than $p$ can transition through the same action.
    \item Since $q_0$ can trasition on $a$, the process $p_0$ must be
      able to transition on $a$.  It can!  It will transition to $p_1$
      in both cases, therefore, $S$ now contains:
      \[
      S = \{ (q_0, p_0), (q_1, p_1), (q_1', p_1) \cdots  \}
      \]
    \item $q_1$ can do a $b$, which $p_1$ can do, and $q_1$ can do a
      $c$, which $p_1$ can also do, therefore the complete $S$ is:
      \[
      S = \{ (q_0, p_0), (q_1, p_1), (q_1', p_1), (q_2, p_2), (q_3, p_3) \}
      \]
      There is a complete simulation in the $p_i$s of the $q_i$s.
    \end{itemize}
  \end{itemize}
  
\item This is a directed notion of simulation
  \begin{itemize}
  \item Would like to use it to make an equivalence relation, but it is not reflexive or symmetric.
  \end{itemize}

\item Strong bisimulation -- a (strong) simulation whose converse is
  also a strong simulation.

\item Recall that the converse of a relation S is defined by $S^{-1}
  \overset{\triangle}{=} \{ (x,y) | (y,x)\} $.

\item We are a tiny bit short on time:
  \begin{itemize}
  \item Definition: a relation $S$ is a strong bisimulation iff $S$
    and $S^{-1}$ is a strong simulation
  \item The example we did above is not a strong bisimulation since $S^{-1}$ is not a strong simulation.
  \item The core of the reason for this is: ``what can simulate $p_0$
    in the other system?'' -- needs to take to a state that can also
    accept $b$ and $c$, which neither $q_1$ nor $q_1'$ can do.
  \end{itemize}

\item Definition:
  \begin{itemize}
  \item Notation: write $p\sim q$ if there exists a strong
    bisimulation $S$ s.t. $p\; S\; q$
  \item This is the notation that we will be using for the rest of the course, though with a handful of different variations.
    \begin{itemize}
    \item For example, might not care about the number of internal transitions.
    \end{itemize}
  \end{itemize}

\item Two interesting propositions:
  \begin{itemize}
  \item $\sim$ is an equivalence -- it is a binary relation on states.
  \item $\sim$ is often called ``bisimularity''.
  \end{itemize}

\item Two case are easy:
  \begin{itemize}
  \item Reflexive: Have to show that every process $p$ is
    $\sim$-equivalent to $p$.
    \begin{itemize}
    \item Trivially a strong simulation -- equality.
    \end{itemize}
  \item Symmetric: for all $p$, $q$ in $Q$ we have $p\sim q \Rightarrow q\sim p$.
    \begin{itemize}
    \item This holds by definition 
    \end{itemize}
  \item Transitive: for all $p$, $q$, $r$ in $Q$, if $p \sim q$ and $q \sim r$, then $p \sim r$
    \begin{itemize}
    \item This can be worked out by a pasting argument -- string it
      together and it works.
    \item Left as an exercise.
    \end{itemize}
  \end{itemize}

\item Now is where some heads will explode (maybe):
  \begin{itemize}
  \item Second proposition: $\sim$ is a strong bisimulation.
  \item The property itself is a strong bisimulation.
  \item $\sim$ defines bisimilarity, and it could have different
    relationships inside of it.
  \item This is the biggest one---the union of all bisimulations---we
    will be talking about these kinds of problems more later on.
  \end{itemize}

\item These definitions are ``seductively simple'' but actually are
  quite rich.
  \begin{itemize}
  \item We will be using them quite a bit over the next few weeks.
  \item One thing that people often confuse: to be a bisimulation, the
    relation and its converse have to be strong simulations.
    \begin{itemize}
    \item Not the case: that if you have a state that can be simulated
      by some state, and that state can be simulated by the first
      state (possibly in a different way) that those things are
      bisimilar.
    \end{itemize}
  \end{itemize}

  \begin{center}
    \includegraphics[width=4in]{images/graph3}
  \end{center}
  
\item These two systems can strongly simulate each other, but
  they are still different.
  \begin{itemize}
  \item The left state can take an $a$ and then deadlock.
  \end{itemize}
  
\item There doesn't exist a bisimulation for this, since the converse
  doesn't hold.

\end{itemize}

\end{document}
