π-calculus
In theoretical computer science, the π-calculus (or pi-calculus) is a process calculus. The π-calculus allows channel names to be communicated along the channels themselves, and in this way it is able to describe concurrent computations whose network configuration may change during the computation.
The π-calculus is elegantly simple, it has very few terms and so is a very small language , yet very expressive. Functional programs can be encoded into the π-calculus, and the encoding emphasises the dialogue nature of computation, drawing connections with game semantics. Extensions of the π-calculus, such as the spi calculus and applied π, have been successful in reasoning about cryptographic protocols. Beside the original use in describing concurrent systems, the π-calculus has also been used to reason about business processes and molecular biology.
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 control flow statements (such as if-then-else, while).
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 , where and and are two processes or threads executed concurrently. 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 is a process waiting for a message that was sent on a communication channel named before proceeding as before proceeding as , binding the name received to the name x. Typically, this models either a process expecting a communication from the network or a label , binding the name received to the name x. Typically, this models either a process expecting a communication from the network or a labelcusable only once by agoto coperation.
-  output prefixing   describes that the name describes that the name is emitted on channel is emitted on channel before proceeding as before proceeding as . Typically, this models either sending a message on the network or a . Typically, this models either sending a message on the network or agoto coperation.
 
-  input prefixing 
-  replication, written  , which may be seen as a process which can always create a new copy of , which may be seen as a process which can always create a new copy of . Typically, this models either a network service or a label . Typically, this models either a network service or a labelcwaiting for any number ofgoto coperations.
-  creation of a new name, written  , which may be seen as a process allocating a new constant x within , which may be seen as a process allocating a new constant x within . The constants of π-calculus are defined by their names only and are always communication channels. Creation of a new name in a process is also called restriction. . The constants of π-calculus are defined by their names only and are always communication channels. Creation of a new name in a process is also called restriction.
-  the nil process, written  , is a process whose execution is complete and has stopped. , 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 first-order functions, truth values, lists and integers. Moreover, extensions of the π-calculus have been proposed which take into account distribution or public-key cryptography. The applied π-calculus due to Abadi and Fournet put these various extensions on a formal footing by extending the π-calculus with arbitrary datatypes.
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  becomes bound to
 becomes bound to  . The next step in the process is therefore
. The next step in the process is therefore
Note that the remaining  is not affected because it is defined in an inner scope.
The second and third parallel components can now communicate on the channel name
 is not affected because it is defined in an inner scope.
The second and third parallel components can now communicate on the channel name  , and the name
, and the name  becomes bound to x. The next step in the process is now
 becomes bound to x. The next step in 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. After that all concurrently executing processes have stopped
Formal definition
Syntax
Let Χ be a set of objects called names. The abstract syntax for the π-calculus is built from the following BNF grammar (where x and y are any names from Χ):[1]
In the concrete syntax below, the prefixes bind more tightly than the parallel composition (|), and parentheses are used to disambiguate.
Names are bound by the restriction and input prefix constructs. Formally, the sets of free and bound names of a process in π–calculus are defined inductively as follows.
| Construct | Free names | Bound names | 
|---|---|---|
|  | None | None | 
|  | a; x; all free names of P | All bound names of P | 
|  | a; free names of P except for x | x; all bound names of P | 
|  | All free names of P and Q | All bound names of P and Q | 
|  | Free names of P except for x | x; all bound names of P | 
|  | All free names of P | All bound names of P | 
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:
Alpha-conversion:
-   if if can be obtained from can be obtained from by renaming one or more bound names in by renaming one or more bound names in . .
 
-  
Axioms for parallel composition:
Axioms for restriction:
Axiom for replication:
Axiom relating restriction and parallel:
-   if x is not a free name of if x is not a free name of . .
 
-  
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. In cases where x is a free name of  , alpha-conversion may be used to allow extension to proceed.
, alpha-conversion may be used to allow extension to proceed.
Reduction semantics
We write  if
 if  can perform a computation step, following which it is now
 can perform a computation step, following which it is now  .
This reduction relation
.
This reduction relation  is defined as the least relation closed under a set of reduction rules.
 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]](../I/m/b87c7644190fc9f57a891bef36bd5343.png) denotes the process denotes the process in which the free name in which the free name has been substituted for the free occurrences of has been substituted for the free occurrences of . If a free occurrence of . If a free occurrence of occurs in a location where occurs in a location where would not be free, alpha-conversion may be required. would not be free, alpha-conversion may be required.
There are three additional rules:
-  If  then also then also . .
- This rule says that parallel composition does not inhibit computation.
-  If  , then also , then also . .
- This rule ensures that computation can proceed underneath a restriction.
-  If  and and where where , then also , then also . .
The latter rule states that processes that are structurally congruent have the same reductions.
The example revisited
Consider again the process
Applying the definition of the reduction semantics, we get the reduction
Note how, applying the reduction substitution axiom, free occurrences of  are now labeled as
 are now labeled as  .
.
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.
Labelled semantics
Alternatively, one may give the pi-calculus 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  after the action
 after the action  becomes
 becomes  .
.  can be an input action
 can be an input action  , an output action
, an output action  , or a tau-action τ corresponding to an internal communication.
, or a tau-action τ 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
 if and only if  for some action
for some action  .
.
Extensions and variants
The syntax given above is a minimal one. However, the syntax may be modified in various ways.
A nondeterministic choice operator  can be added to the syntax.
 can be added to the syntax.
A test for name equality ![[x=y]P](../I/m/8f9ddc4f3c87597ba27c7ae8a95bf3e5.png) can be added to the syntax. This match operator can proceed as
 can be added to the syntax. This match operator can proceed as  if and only if x and
 if and only if x and  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.
 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 suffix, 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 continuation-free output can model a message-in-transit, this fragment shows that the original π-calculus, which is intuitively based on synchronous communication, has an expressive asynchronous communication model inside its syntax. However, the nondeterministic choice operator defined above cannot be expressed in this way, as an unguarded choice would be converted into a guarded one; this fact has been used to demonstrate that the asynchronous calculus is strictly less expressive than the synchronous one (with the choice operator).[2]
, 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 continuation-free output can model a message-in-transit, this fragment shows that the original π-calculus, which is intuitively based on synchronous communication, has an expressive asynchronous communication model inside its syntax. However, the nondeterministic choice operator defined above cannot be expressed in this way, as an unguarded choice would be converted into a guarded one; this fact has been used to demonstrate that the asynchronous calculus is strictly less expressive than the synchronous one (with the choice operator).[2]
The polyadic π-calculus allows communicating more than one name in a single action:  (polyadic output) and
 (polyadic output) and  (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
 (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 ![(\nu w) \overline{x}\langle w \rangle.\overline{w}\langle y_1\rangle.\cdots.\overline{w}\langle y_n\rangle.[P]](../I/m/c238603fbebaae0e3b8308a446582ef0.png)
 is encoded as
 is encoded as ![x(w).w(y_1).\cdots.w(y_n).[P]](../I/m/5faa4f06bea5bc7fc991344a683aec36.png)
All other process constructs are left unchanged by the encoding.
In the above, ![[P]](../I/m/6f585df5b3729ad672d28b2bd7c5b25d.png) denotes the encoding of all prefixes in the continuation
 denotes the encoding of all prefixes in the continuation  in the same way.
 in the same way.
The full power of replication  is not needed. Often, one only considers replicated input
 is not needed. Often, one only considers replicated input  , whose structural congruence axiom is
, whose structural congruence axiom is  .
.
Replicated input process such as  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
 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]](../I/m/8d4385fd5da9b9fbca8a8f179f751c92.png) , where a is the name passed by the client to the
server, during the latter's invocation.
, 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
![\overline{x}\langle R \rangle.P | x(Y).Q \rightarrow P | Q[R/Y]](../I/m/0cb090b01f4001a38ed6dd782fea0002.png)
Here,  denotes a process variable which can be instantiated by a process term. Sangiorgi
established 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.
 denotes a process variable which can be instantiated by a process term. Sangiorgi
established 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.
Properties
Turing completeness
The π-calculus is a universal model of computation. This was first observed by Milner in his paper "Functions as Processes",[3] in which he presents two encodings of the lambda-calculus in the π-calculus. One encoding simulates the eager (call-by-value) evaluation strategy, the other encoding simulates the normal-order (call-by-name) strategy. In both of these, the crucial insight is the modeling of environment bindings – for instance, "x is bound to term  " – as replicating agents that respond to requests for their bindings by sending back a connection to the term
" – as replicating agents that respond to requests for their bindings by sending back a connection to the term  .
.
The features of the π-calculus that make these encodings possible are name-passing and replication (or, equivalently, recursively defined agents). In the absence of replication/recursion, the π-calculus ceases to be Turing-powerful. This can be seen by the fact that bisimulation equivalence becomes decidable for the recursion-free calculus and even for the finite-control π-calculus where the number of parallel components in any process is bounded by a constant.[4]
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 value-passing process calculus.
In the remainder of this section, we let  and
 and  denote processes and
 denote processes and  denote binary relations over processes.
 denote binary relations over processes.
Early and late bisimilarity
Early and late bisimilarity were both formulated by Milner, Parrow and Walker in their original paper on the π-calculus.[5]
A binary relation  over processes is an early bisimulation if for every pair of processes
 over processes is an early bisimulation if for every pair of processes  ,
,
-  whenever  then for every name then for every name there exists some there exists some such that such that and and![(p'[y/x],q'[y/x]) \in R](../I/m/7a13637574638d88190420ed6d3adbba.png) ; ;
-  for any non-input action  , if , if then there exists some then there exists some such that such that and and ; ;
-  and symmetric requirements with  and and interchanged. interchanged.
Processes  and
 and  are said to be early bisimilar, written
 are said to be early bisimilar, written  if the pair
 if the pair  for some early bisimulation
 for some early bisimulation  .
.
In late bisimilarity, the transition match must be independent of the name being transmitted.
A binary relation  over processes is a late bisimulation if for every pair of processes
 over processes is a late bisimulation if for every pair of processes  ,
,
-  whenever  then for some then for some it holds that it holds that and and![(p'[y/x],q'[y/x]) \in R](../I/m/7a13637574638d88190420ed6d3adbba.png) for every name y; for every name y;
- for any non-input action  , if , if implies that there exists some implies that there exists some such that such that and and ; ;
-  and symmetric requirements with  and and interchanged. interchanged.
Processes  and
 and  are said to be late bisimilar, written
 are said to be late bisimilar, written  if the pair
 if the pair  for some late bisimulation
 for some late bisimulation  .
.
Both  and
 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
 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  and
 and  such that
 such that  but
 but  . One may remedy this problem by considering the maximal congruence relations included in
. One may remedy this problem by considering the maximal congruence relations included in  and
 and  , known as early congruence and late congruence, respectively.
, known as early congruence and late congruence, respectively.
Open bisimilarity
Fortunately, a third definition is possible, which avoids this problem, namely that of open bisimilarity, due to Sangiorgi.[6]
A binary relation  over processes is an open bisimulation if for every pair of elements
 over processes is an open bisimulation if for every pair of elements  and for every name substitution
 and for every name substitution  and every action
 and every action  , whenever
, whenever  then there exists some
 then there exists some  such that
 such that  and
 and  .
.
Processes  and
 and  are said to be open bisimilar, written
 are said to be open bisimilar, written  if the pair
 if the pair  for some open bisimulation
 for some open bisimulation  .
.
Early, late and open bisimilarity are distinct
Early, late and open bisimilarity are distinct. The containments are proper, so  .
.
In certain subcalculi such as the asynchronous pi-calculus, 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.
Barbed equivalence
Alternatively, one may define bisimulation equivalence directly from the reduction semantics. We write  if process
 if process  immediately allows an input or an output on name
 immediately allows an input or an output on name  .
.
A binary relation  over processes is a barbed bisimulation if it is a symmetric relation which satisfies that for every pair of elements
 over processes is a barbed bisimulation if it is a symmetric relation which satisfies that for every pair of elements  we have that
 we have that
- (1)  if and only if if and only if for every name for every name 
and
- (2) for every reduction  there exists a reduction there exists a reduction 
such that  .
.
We say that  and
 and  are barbed bisimilar if there exists a barbed bisimulation
 are barbed bisimilar if there exists a barbed bisimulation  where
 where  .
.
Defining a context as a π term with a hole [] we say that two processes P and Q are barbed congruent, written  , if for every context
, if for every context ![C[]](../I/m/8c85223757bdc7bf10f468aad90b3ca7.png) we have that
 we have that ![C[P]](../I/m/6e0247aef9796f5916532981f0b22117.png) and
 and ![C[Q]](../I/m/924e2b55d2860859ebe17be65b59b881.png) are barbed bisimilar. It turns out that barbed congruence coincides with the congruence induced by early bisimilarity.
 are barbed bisimilar. It turns out that barbed congruence coincides with the congruence induced by early bisimilarity.
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 traditional computer science.
In 1997, Martin Abadi and Andrew Gordon proposed an extension of the π-calculus, the Spi-calculus, as a formal notation for describing and reasoning about cryptographic protocols. The spi-calculus extends the π-calculus with primitives for encryption and decryption. In 2001, Martin Abadi and Cedric Fournet generalised the handling of cryptographic protocols to produce the applied π calculus. There is now a large body of work devoted to variants of the applied π calculus, including a number of experimental verification tools. One example is the tool ProVerif due to Bruno Blanchet, based on a translation of the applied π-calculus into Blanchet's logic programming framework. Another example is Cryptyc , 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 that π-calculus would become a description tool for modelling business processes. By July 2006, there is discussion in the community about how useful this would be. Most recently, the π-calculus has formed the theoretical basis of Business Process Modeling Language (BPML), and of Microsoft's XLANG.[7]
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 so-called RTK/MAPK cascade) and in particular the molecular "lego" which implements these tasks of communication in an extension of the π-calculus.[8] Following this seminal paper, other authors described the whole metabolic network of a minimal cell.[9]
History
The π-calculus was originally developed by Robin Milner, Joachim Parrow and David Walker in 1992, based on ideas by Uffe Engberg and Mogens Nielsen. It can be seen as a continuation of Milner's work on the process calculus CCS (Calculus of Communicating Systems). In his Turing lecture, Milner describes the development of the π-calculus as an attempt to capture the uniformity of values and processes in actors.[10]
Implementations
The following programming languages are implementations either of the π-calculus or of its variants:
- Business Process Modeling Language (BPML)
- occam-π
- Pict
- JoCaml (based on the Join-calculus)
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.1-40, Sept 1992
- ↑ Palamidessi, Catuscia (1997). "Comparing the expressive power of the Synchronous and the Asynchronous pi-calculus". Proceedings of the 24th ACM Symposium on Principles of Programming Languages: 256–265. Retrieved October 12, 2013.
- ↑ Milner, Robin (1992). "Functions as Processes". Mathematical Structures in Computer Science 2: 119–141. doi:10.1017/s0960129500001407.
- ↑ Dam, Mads (1997). "On the Decidability of Process Equivalences for the pi-Calculus". Theoretical Computer Science 183 (183): 215–228. doi:10.1016/S0304-3975(96)00325-8.
- ↑ Milner, R.; J. Parrow; D. Walker (1992). "A calculus of mobile processes". Information and Computation 100 (1): 1–40. doi:10.1016/0890-5401(92)90008-4.
- ↑ Sangiorgi, D. (1996). "A theory of bisimulation for the π-calculus". Acta Informatica 33: 69–97. doi:10.1007/s002360050036.
- ↑ "BPML | BPEL4WS: A Convergence Path toward a Standard BPM Stack." BPMI.org Position Paper. August 15, 2002.
- ↑ Regev, Aviv; William Silverman; Ehud Y. Shapiro (2001). "Representation and Simulation of Biochemical Processes Using the pi-Calculus Process Algebra". Pacific Symposium on Biocomputing: 459–470.
- ↑ Chiarugi, Davide; Pierpaolo Degano; Roberto Marangoni (2007). "A computational approach to the functional screening of genomes". PLOS Computational Biology: 1801–1806.
- ↑ Robin Milner. 1993. Elements of interaction: Turing award lecture. Commun. ACM 36, 1 (January 1993), 78-89. DOI=10.1145/151233.151240 http://doi.acm.org/10.1145/151233.151240
References
- Milner, Robin (1999). Communicating and Mobile Systems: The π-calculus. Cambridge, UK: Cambridge University Press. ISBN 0-521-65869-1.
- Milner, Robin (1993). "The Polyadic π-Calculus: A Tutorial". In F. L. Hamer, W. Brauer, H. Schwichtenberg. Logic and Algebra of Specification. Springer-Verlag.
- Sangiorgi, Davide; Walker, David (2001). The π-calculus: A Theory of Mobile Processes. Cambridge, UK: Cambridge University Press. ISBN 0-521-78177-9.
External links
- PiCalculus on the C2 wiki
- FAQ on π-Calculus by Jeannette M. Wing











![\overline{x}\langle z \rangle.P | x(y).Q \rightarrow P | Q[z/y]](../I/m/5f9f0781945efba95a0d3f7ed6323939.png)



