Picalculus
From Wikipedia, the free encyclopedia
In theoretical computer science, the πcalculus is a process calculus originally developed by Robin Milner, Joachim Parrow and David Walker as a continuation of work on the process calculus CCS (Calculus of Communicating Systems). The aim of the πcalculus is to be able to describe concurrent computations whose configuration may change during the computation.
Contents 
[edit] Informal definition
The πcalculus belongs to the family of process calculi, mathematical formalisms for describing and analyzing properties of concurrent computation. In fact, the πcalculus, like the λcalculus, is so minimal that it does not contain primitives such as numbers, booleans, data structures, variables, functions, or even the usual flow control statements (such as if... then...else
, while...
).
[edit] Process constructs
Central to the πcalculus is the notion of name. The simplicity of the calculus lies in the dual role that names play as communication channels and variables.
The process constructs available in the calculus are the following (a precise definition is given in the following section):
 concurrency, written , where P and Q are two processes or threads executed concurrently.
 communication, where
 input prefixing is a process waiting for a message that was sent on a communication channel named c before proceeding as P, binding the name received to the name x. Typically, this models either a process expecting a communication from the network or a label
c
usable only once by agoto c
operation.  output prefixing describes that the name y is emitted on channel c before proceeding as P. Typically, this models either sending a message on the network or a
goto c
operation.
 input prefixing is a process waiting for a message that was sent on a communication channel named c before proceeding as P, binding the name received to the name x. Typically, this models either a process expecting a communication from the network or a label
 replication, written , which may be seen as a process which can always create a new copy of P. Typically, this models either a network service or a label
c
waiting for any number ofgoto c
operations.  creation of a new name, written , which may be seen as a process allocating a new constant x within P. As opposed to functional programming's
let x=... in...
operation, the constants of πcalculus are defined by their name only and are always communication channels.  the nil process, written 0, is a process whose execution is complete and has stopped.
Although the minimalism of the πcalculus prevents us from writing programs in the normal sense, it is easy to extend the calculus. In particular, it is easy to define both control structures such as recursion, loops and sequential composition and datatypes such as firstorder functions, truth values, lists and integers. Moreover, extensions of the πcalculus have been proposed which take into account distribution or publickey cryptography. The applied πcalculus due to Abadi and Fournet [2] puts these various extensions on a formal footing by extending the πcalculus with arbitrary datatypes.
[edit] A small example
Below is a tiny example of a process which consists of three parallel components. The channel name x is only known by the first two components.
The first two components are able to communicate on the channel x, and the name z becomes bound to y. The continuation of the process is therefore
Note that the remaining y is not affected because it is defined in an inner scope. The second and third parallel components can now communicate on the channel name z, and x is bound to v. The continuation of the process is now
Note that since the local name x has been output, the scope of x is extended to cover the third component as well. Finally, the channel x can be used for sending the name x.
[edit] Formal definition
[edit] Syntax
Let Χ be a set of objects called names. The processes of πcalculus are built from names by the following BNF grammar (where x and y are any names from Χ):^{[1]}
Names can be bound by the restriction and input prefix constructs. The sets of free and bound names of a process in π–calculus are defined inductively as follows.
 The 0 process has no free names and no bound names.
 The free names of are a, x, and the free names of P. The bound names of are the bound names of P.
 The free names of a(x).P are a and the free names of P, except for x. The bound names of a(x).P are x and the bound names of P.
 The free names of P  Q are those of P together with those of Q. The bound names of P  Q are those of P together with those of Q.
 The free names of (νx).P are those of P, except for x. The bound names of (νx).P are x and the bound names of P.
 The free names of !P are those of P. The bound names of !P are those of P.
[edit] Structural congruence
Central to both the reduction semantics and the labelled transition semantics is the notion of structural congruence. Two processes are structurally congruent, if they are identical up to structure. In particular, parallel composition is commutative and associative.
More precisely, structural congruence is defined as the least equivalence relation preserved by the process constructs and satisfying:
Alphaconversion:

 if Q can be obtained from P by renaming one or more bound names in P.
Axioms for parallel composition:
Axioms for restriction:
Axiom for replication:
Axiom relating restriction and parallel:

 if x is not a free name of Q.
This last axiom is known as the "scope extension" axiom. This axiom is central, since it describes how a bound name x may be extruded by an output action, causing the scope of x to be extended.
[edit] Reduction semantics
We write if P can perform a computation step, following which it is now P'. This reduction relation is defined as the least relation closed under a set of reduction rules.
The main reduction rule which captures the ability of processes to communicate through channels is the following:
 where Q[z / y] denotes the process Q in which the free name z has been substituted for the free name y. Note that this substitution may involve alphaconversion to avoid name clashes.
There are three additional rules:
 If then also .
 This rule says that parallel composition does not inhibit computation.
 If , then also .
 This rule ensures that computation can proceed underneath a restriction.
 If and where , then also .
The latter rule states that processes that are structurally congruent have the same reductions.
[edit] The example revisited
Consider again the process
Applying the definition of the reduction semantics, we get the reduction
Next, we get the reduction
Note that since the local name x has been output, the scope of x is extended to cover the third component as well. This was captured using the scope extension axiom.
[edit] Labelled semantics
Alternatively, one may give the picalculus a labelled transition semantics (as has been done with the Calculus of Communicating Systems). Transitions in this semantics are of the form:
This notation signifies that P after the action α becomes P'. α can be an input action a(x), an output action , or a tauaction τ corresponding to an internal communication.
A standard result about the labelled semantics is that it agrees with the reduction semantics in the sense that if and only if for some action τ.
[edit] Extensions and variants
The syntax given above is a minimal one. However, the syntax may be modified in various ways.
A nondeterministic choice operator P + Q can be added to the syntax.
A test for name equality [x = y]P can be added to the syntax. This match operator can proceed as P if and only if x and y are the same name. Similarly, one may add a mismatch operator for name inequality. Practical programs which can pass names (URLs or pointers) often use such functionality: for directly modelling such functionality inside the calculus, this and related extensions are often useful.
The asynchronous πcalculus allows only outputs with no continuation, i.e. output atoms of the form , yielding a smaller calculus. However, any process in the original calculus can be represented by the smaller asynchronous πcalculus using an extra channel to simulate explicit acknowledgement from the receiving process. Since a continuationfree output can model a messageintransit, this fragment shows that the original πcalculus, which is intuitively based on synchronous communication, has an expressive asynchronous communication model inside its syntax.
The polyadic πcalculus allows communicating more than one name in a single action: (polyadic output) and x(z_{1},...z_{n}) (polyadic input). This polyadic extension, which is useful especially when studying types for name passing processes, can be encoded in the monadic calculus by passing the name of a private channel through which the multiple arguments are then passed in sequence. The encoding is defined recursively by the clauses
is encoded as
is encoded as
All other process constructs are left unchanged by the encoding.
In the above, [P] denotes the encoding of all prefixes in the continuation P in the same way.
The full power of replication !P is not needed. Often, one only considers replicated input !x(y).P, whose structural congruence axiom is .
Replicated input process such as !x(y).P can be understood as servers, waiting on channel x to be invoked by clients. Invocation of a server spawns a new copy of the process P[a / y], where a is the name passed by the client to the server, during the latter's invocation.
A higher order πcalculus can be defined where not only names but processes are sent through channels. The key reduction rule for the higher order case is
Here, Y denotes a process variable which can be instantiated by a process term. Sangiorgi established the surprising result that the ability to pass processes does not increase the expressivity of the πcalculus: passing a process P can be simulated by just passing a name that points to P instead.
[edit] Properties
[edit] Turing completeness
The πcalculus is a universal model of computation. This was first observed by Milner in his paper "Functions as Processes" (Mathematical Structures in Computer Science, Vol. 2, pp. 119141, 1992), in which he presents two encodings of the lambdacalculus in the πcalculus. One encoding simulates the callbyvalue reduction strategy, the other encoding simulates the lazy (callbyname) strategy.
The features of the πcalculus that make these encodings possible are namepassing and replication (or, equivalently, recursively defined agents). In the absence of replication/recursion, the πcalculus ceases to be Turingpowerful. This can be seen by the fact the bisimulation equivalence becomes decidable for the recursionfree calculus and even for the finitecontrol πcalculus where the number of parallel components in any process is bounded by a constant (Mads Dam: On the Decidability of Process Equivalences for the piCalculus. Theoretical Computer Science 183, 1997, pp. 215228.)
[edit] Bisimulations in the πcalculus
As for process calculi, the πcalculus allows for a definition of bisimulation equivalence. In the πcalculus, the definition of bisimulation equivalence (also known as bisimilarity) may be based on either the reduction semantics or on the labelled transition semantics.
There are (at least) three different ways of defining labelled bisimulation equivalence in the πcalculus: Early, late and open bisimilarity. This stems from the fact that the πcalculus is a valuepassing process calculus.
In the remainder of this section, we let p and q denote processes and R denote binary relations over processes.
[edit] Early and late bisimilarity
Early and late bisimilarity were both discovered by Milner, Parrow and Walker in their original paper on the πcalculus.^{[2]}
A binary relation R over processes is an early bisimulation if for every pair of processes ,
 whenever then for every name y there exists some q' such that and ;
 for any noninput action α, if then there exists some q' such that and ;
 and symmetric requirements with p and q interchanged.
Processes p and q are said to be early bisimilar, written if the pair for some early bisimulation R.
In late bisimilarity, the transition match must be independent of the name being transmitted. A binary relation R over processes is a late bisimulation if for every pair of processes ,
 whenever then for some q' it holds that and for every name y;
 for any noninput action α, if implies that there exists some q' such that and ;
 and symmetric requirements with p and q interchanged.
Processes p and q are said to be late bisimilar, written if the pair for some late bisimulation R.
Both and suffer from the problem that they are not congruence relations in the sense that they are not preserved by all process constructs. More precisely, there exist processes p and q such that but . One may remedy this problem by considering the maximal congruence relations included in and , known as early congruence and late congruence, respectively.
[edit] Open bisimilarity
Fortunately, a third definition is possible, which avoids this problem, namely that of open bisimilarity, due to Sangiorgi ^{[3]}.
A binary relation R over processes is an open bisimulation if for every pair of elements and for every name substitution σ and every action α, whenever then there exists some q' such that and .
Processes p and q are said to be open bisimilar, written if the pair for some open bisimulation R.
Early, late and open bisimilarity are in fact all distinct. The containments are proper, so .
In certain subcalculi such as the asynchronous picalculus, late, early and open bisimilarity are known to coincide. However, in this setting a more appropriate notion is that of asynchronous bisimilarity.
The reader should note that, in the literature, the term open bisimulation usually refers to a more sophisticated notion, where processes and relations are indexed by distinction relations; details are in Sangiorgi's paper cited above.
[edit] Barbed equivalence
Alternatively, one may define bisimulation equivalence directly from the reduction semantics. We write if process p immediately allows an input or an output on name a.
A binary relation R over processes is a barbed bisimulation if it is a symmetric relation which satisfies that for every pair of elements we have that
 (1) if and only if for every name a
and
 (2) for every reduction there exists a reduction
such that .
We say that p and q are barbed bisimilar if there exists a barbed bisimulation R where .
Definying a context as a π term with a hole [] we say that two processes P and Q are barbed congruent, written if for every context C[] we have that . It turns out that barbed congruence coincides with the congruence induced by early bisimilarity.
[edit] Applications
The πcalculus has been used to describe many different kinds of concurrent systems. In fact, some of the most recent applications lie outside the realm of computer science.
In 1997, Martin Abadi and Andrew Gordon proposed an extension of the πcalculus, the Spicalculus, as a formal notation for describing and reasoning about cryptographic protocols. The spicalculus extends the πcalculus with primitives for encryption and decryption. There is now a large body of work devoted to variants of the spicalculus, including a number of experimental verification tools. One example is the tool ProVerif [3] due to Bruno Blanchet, based on a translation of the applied πcalculus into Blanchet's logic programming framework. Another example is Cryptyc [4], due to Andrew Gordon and Alan Jeffrey, which uses Woo and Lam's method of correspondence assertions as the basis for type systems that can check for authentication properties of cryptographic protocols.
Around 2002, Howard Smith and Peter Fingar became interested in using the πcalculus as a description tool for modelling business processes. As of July 2006, there is discussion in the community as to how useful this will be. Most recently, the πcalculus has been used as the theoretical basis of Business Process Modeling Language (BPML), and of Microsoft's XLANG.^{[4]}
The πcalculus has also attracted interest in molecular biology. In 1999, Aviv Regev and Ehud Shapiro showed that one can describe a cellular signaling pathway (the socalled RTK/MAPK cascade) and in particular the molecular "lego" which implements these tasks of communication in an extension of the πcalculus.^{[5]}
[edit] Implementations
The following programming languages are implementations either of the πcalculus or of its variants:
 Acute
 Business Process Modeling Language (BPML)
 Nomadic Pict
 occamπ
 Pict
 JoCaml (based on the Joincalculus a variant of πcalculus)
 Funnel (A JREcompatible join calculus implementation)
 The CubeVM (a stackless implementation)
 The SpiCO language: a stochastic picalulus for concurrent objects
 BioSPI and SPiM: simulators for the stochastic picalculus
[edit] Notes
 ^ A Calculus of Mobile Processes part 1 page 10, by R. Milner, J. Parrow and D. Walker published in Information and Computation 100(1) pp.140, Sept 1992
 ^ Milner, R.; J. Parrow and D. Walker (1992). "A calculus of mobile processes". Information and Computation 100 (100): 140. doi: .
 ^ Sangiorgi, D. (1996). "A theory of bisimulation for the πcalculus". Acta Informatica 33: 69–97. doi: .
 ^ "BPML  BPEL4WS: A Convergence Path toward a Standard BPM Stack." BPMI.org Position Paper. August 15, 2002.[1]
 ^ Regev, Aviv; William Silverman and Ehud Y. Shapiro. "Representation and Simulation of Biochemical Processes Using the piCalculus Process Algebra". Pacific Symposium on Biocomputing 2001: 459–470.
[edit] References
 Robin Milner: Communicating and Mobile Systems: the PiCalculus, Cambridge Univ. Press, 1999, ISBN 0521658691
 Robin Milner: The Polyadic πCalculus: A Tutorial. Logic and Algebra of Specification, 1993.
 Davide Sangiorgi and David Walker: The Picalculus: A Theory of Mobile Processes, Cambridge University Press, ISBN 0521781779
[edit] External links
 PiCalculus on the C2 wiki
 Calculi for Mobile Processes
 FAQ on PiCalculus by Jeannette M. Wing