# Introduction to the π-calculus

### Pages to are hidden for

"Introduction to the π-calculus"

```					Introduction to the -calculus

Stefan Kahrs
source: Joachim Parrow’s chapter in the
Handbook of Process Algebra
What is it?

• In short: a process algebra, invented by Robin
Milner around 1990. Process algebra are like
toy programming languages for parallel
programming
• Special features:
– Name creation is internal to the calculus
– Orthogonality: names serve both as data and as
channels (mobility)
Syntax
P ::=   P1 | P2           parallel
|     P1 + P2           n.d. choice
|     (x)P             new name
|     x1(x2). P         input
|     x1 x2 . P         output
|     0                 stop
|      . P             silent action
|     A(x1,…,xn)        defined process
|     if x1=x2 then P   match
|     if x1x2 then P   mismatch
Slight Variations

• the original paper by Milner et.al. had match
but not mismatch; some papers omit both
• instead of (recursively) defined agents, some
papers have replication (!P) instead of
recursion
• at least one paper omits non-det. choice
• syntactic variants: [x=y]P, (x)P, x.P
Standard Process Algebra Stuff

• communication on a channel a:

a(b).P | ad .Q  P{d / b} | Q


• notice: this is synchronous, but...
• aside: substitution avoids name capture
...and also

process descriptions of A(x1,...,xn)
• note: the xi are just name parameters
• can be (mutually) recursive
• no renaming operator
Names

The distinguishing feature of the -calculus!
• originated in Standard ML semantics
(implementations)
– type checking (for datatypes or abstract types)
– exception constructors
• not fundamentally different from object
creation in OO-programming
Eh?

• the  operator generates a new name
• or – if you prefer – hides a free name
• however: these names are mobile –
communication can move them into other
areas that seemingly were outside the scope
• this is achieved by the congruence relation
which equates (some) equivalent processes
Example of moving scope

• on the left:  inside parallel composition
a (b).P | (d )ad .Q  (d )( P{d / b} | Q)


• on the right: it has moved outside
Congruence  (note: Parrow)

 is the smallest congruence such that:
• both ‘+’ and ‘|’ form commutative monoids
with neutral element 0
• it includes -conversion
• ...and the unfolding of definitions
• ...and most importantly, the scope extension
laws
Scope Extension Laws
(x)0  0       garbage collection

(vx)( P | Q)  P | (x)Q, if x  fn( P )

(vx)( P  Q)  P  (x)Q, if x  fn( P )

(x) if u  v then P  if u  v then (x) P, if x  u  x  v

(x) if u  v then P  if u  v then (x) P, if x  u  x  v

(x)(y ) P  (y )(x) P
Consequences and non-Consequences

• all binders can be moved to the top – only
recursive descriptions are in the way
• we do not have
(x)( P | Q )  (x) P | (x)Q

• it should be clear why; however, for + we do
not have this either and there it is less clear
Operational Semantics
• defines a labelled transition relation
• when we have t  u  
...then t can evolve to u, and the outside world can
observe the action 
• three actions:
– input a(x)
– output ab, ab
– silent 
• one of many presentations...
Rules I
P'  P, P  Q, Q  Q'

STRUCT
P'  Q'


PREFIX
             for input, output and 
 .P  P


P  P'

SUM
P  Q  P'


P  P' , bn( )  fn(Q)  {}

PAR
P | Q  P' | Q


• because of the input prefix (also x labels,
but they play only a minor rule) there are
bound names in labels
• non-deterministic choice commits by making
a transition (which can be silent), and this is
the only thing it can do
Rules II
)         
P a  P' , Q au Q'
(x
COM
P | Q  P'{u / x} | Q'


P  P' , x 

RES
(x) P  (x) P'



P ax P ' , a  x
OPEN
ax
(x) P  P'

P a  P' , Q au Q'
)
(u

CLOSE
P | Q  (u )( P' | Q' )


• because of the side-condition on the RES
rule, any attempt to immediately send or
• the CLOSE rule is not really necessary,
because its effect can be achieved through the
other rules, but without it the OPEN rule
would fire blanks
Bisimulation

...cannot quite be defined as usual, because we
have two problems
• bound names in labels
• even if we take care of them, we do not get a
congruence relation
Reminder: Standard Definition

• a (strong) bisimulation is a symmetric binary
relation  such that if P  P' and PQ

then Q’. Q  Q' and P’  Q’.

• modification for input prefix (=a(x)):
assume x is fresh and: u.P'{u / x}Q'{u / x}

• write PQ if it holds for some bisimulation
Input Prefix

• may not preserve strong bisimilarity
• because  is not preserved by (arbitrary)
substitutions – an aliasing problem
• ...and input prefix can introduce aliasing
Example

• a( x)0 | bb0 is bisimilar to a( x).bb.0  bb.a( x).0
• but the substitution {b/a} would break the
equivalence since the left could silently evolve
to 0, the right cannot
• therefore, the input prefix c(a) breaks
bisimilarity as well
Getting out of jail

• two agents P and Q are (strongly) congruent
if and only if P  Q for all substitutions .
• note: strong congruence is the largest
congruence relation in bisimilarity
• other bisimulations: barbed, early, open,...
• also: weak bisimilation, i.e. making 
unobservable
Asynchronous -calculus

As most process algebras, the -calculus is
essentially synchronous.
However, when we constrain the agents we can
write in a certain way, we end up with an
asynchronous calculus.
What are the constraints?
Constraints for asynchronous calculus

• Only 0 can follow an output prefix
• an output prefix may not occur as an
unguarded operand of +
Rationale: the agent .(ax.0 | P) is essentially
asynchronously outputting on a and
continuing as P
Recover...

• it is possible to recover from these
constraints by using acknowledgements, e.g.
 .(b)(ab.0 | b( x).P)

• the binder protects the name b and thus
protects the acknowledgement
Lots of other stuff

if others are willing to continue that theme...
• PICT, a programming language based on the
asynchronous -calculus
• proving (various) bisimilarities
• applications
• higher-order -calculus
• action semantics

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 18 posted: 11/21/2008 language: English pages: 26