Lecture 24 — 2017-11-28

Pi calculus

This lecture is written in literate Haskell; you can download the raw source.

c is a channel name
x is a variable

Types
t ::= Chan t
    | t1 * ... * tn

Expressions
e ::= x | c | (e1, ..., en)

Values
v ::= c | (v1, ..., vn)

Patterns
pat ::= x | _ | (pat1, ..., patn)

Pi calculus processes
p, q ::= 0 | p|q | new x:t. p | send e1(e2) | rec e(pat). p | rec! e(pat). p

Channels (set)
C ::= {c1, ..., cn}

Running processes (list)
R ::= [p1, ..., pm]

Machine state
M ::= <C; R>

Substitutions
Θ ::= - | Θ[x |-> v]

Pattern matching

----------
v ~ _ |> -

-------------------
v ~ x |> -[x |-> v]

v1 ~ pat1 |> Θ1     ...     vn ~ patn |> Θn
-------------------------------------------- where each Θ has a disjoint domain
(v1, ..., vn) ~ (pat1, ..., patn) |> Θ1...Θn

Operational semantics

---------------------------------------------------------------------------
<C; [p1, ..., pi-1, 0, pi+1, ..., pn]> --> <C; [p1, ..., pi, pi+1 ..., pn]>

------------------------------------------------------------------------------------
<C; [p1, ..., pi-1, (p|q), pi+1, ..., pn]> --> <C; [p1, ..., pi, p, q pi+1 ..., pn]>

q = new x:t. p    q in R    c not in C
-------------------------------------------
<C; R> --> <C U {c}; (R \ [q]) ++ [p[c/x]]>

q = send c(v)    p = rec c(pat). p'    q, p in R    v ~ pat |> Θ
----------------------------------------------------------------
<C; R> --> <C; (R \ [q, p]) ++ [Θp']>

q = send c(v)    p = rec! c(pat). p'    q, p in R    v ~ pat |> Θ
-----------------------------------------------------------------
<C; R> --> <C; (R \ [q]) ++ [Θp']>