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 has few terms and is a small, yet expressive language (see). 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[1] and molecular biology.
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
).
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[2] (a precise definition is given in the following section):
P\midQ
P
Q
c\left(x\right).P
c
c
usable only once by a goto c
operation.\overline{c}\langley\rangle.P
y
c
goto c
operation.!P
c
waiting for any number of goto c
operations.\left(\nux\right)P
0
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 have been proposed which take into account distribution or public-key cryptography. The applied due to Abadi and Fournet https://www.soe.ucsc.edu/~abadi/Papers/isss02.pdf put these various extensions on a formal footing by extending the with arbitrary datatypes.
Below is a tiny example of a process which consists of three parallel components. The channel name is only known by the first two components.
\begin{align} (\nux)& ( \overline{x}\langlez\rangle. 0\\ & | x(y). \overline{y}\langlex\rangle. x(y). 0 )\\ & | z(v). \overline{v}\langlev\rangle.0 \end{align}
The first two components are able to communicate on the channel, and the name becomes bound to . The next step in the process is therefore
\begin{align} (\nux)& ( 0\\ & | \overline{z}\langlex\rangle. x(y). 0 )\\ & | z(v). \overline{v}\langlev\rangle. 0 \end{align}
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, and the name becomes bound to . The next step in the process is now
\begin{align} (\nux)& ( 0\\ & | x(y). 0\\ & | \overline{x}\langlex\rangle. 0 ) \end{align}
Note that since the local name has been output, the scope of is extended to cover the third component as well. Finally, the channel can be used for sending the name . After that all concurrently executing processes have stopped
\begin{align} (\nux)& ( 0\\ & | 0\\ & | 0 ) \end{align}
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 Χ):[3]
\begin{align} P,Q::=& x(y).P&Receiveonchannelx,bindtheresulttoy,thenrunP\\ & | \overline{x}\langley\rangle.P&Sendthevalueyoverchannelx,thenrunP\\ & | P|Q&RunPandQsimultaneously\\ & | (\nux)P&CreateanewchannelxandrunP\\ & | !P&RepeatedlyspawncopiesofP\\ & | 0&Terminatetheprocess \end{align}
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 set of free names of a process in –calculus are defined inductively by the table below. The set of bound names of a process are defined as the names of a process that are not in the set of free names.
Construct | Free names | |
---|---|---|
0 | None | |
\overline{a}\langlex\rangle.P | a; x; all free names of P | |
a(x).P | a; free names of P except for x | |
P | Q | All free names of P and Q |
(\nux)P | Free names of P except for x | |
!P | All free names of P |
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:
P\equivQ
Q
P
P
Axioms for parallel composition:
P|Q\equivQ|P
(P|Q)|R\equivP|(Q|R)
P|0\equivP
Axioms for restriction:
(\nux)(\nuy)P\equiv(\nuy)(\nux)P
(\nux)0\equiv0
Axiom for replication:
!P\equivP|!P
Axiom relating restriction and parallel:
(\nux)(P|Q)\equiv(\nux)P|Q
Q
This last axiom is known as the "scope extension" axiom. This axiom is central, since it describes how a bound name may be extruded by an output action, causing the scope of to be extended. In cases where is a free name of
Q
We write
P → P'
P
P'
→
The main reduction rule which captures the ability of processes to communicate through channels is the following:
\overline{x}\langlez\rangle.P|x(y).Q → P|Q[z/y]
where
Q[z/y]
Q
z
y
y
z
There are three additional rules:
P → Q
P|R → Q|R
This rule says that parallel composition does not inhibit computation.
P → Q
(\nux)P → (\nux)Q
This rule ensures that computation can proceed underneath a restriction.
P\equivP'
P' → Q'
Q'\equivQ
P → Q
The latter rule states that processes that are structurally congruent have the same reductions.
Consider again the process
(\nux)(\overline{x}\langlez\rangle.0|x(y).\overline{y}\langlex\rangle.x(y).0)|z(v).\overline{v}\langlev\rangle.0
Applying the definition of the reduction semantics, we get the reduction
(\nux)(\overline{x}\langlez\rangle.0|x(y).\overline{y}\langlex\rangle.x(y).0)|z(v).\overline{v}\langlev\rangle.0 → (\nux)(0|\overline{z}\langlex\rangle.x(y).0)|z(v).\overline{v}\langlev\rangle.0
Note how, applying the reduction substitution axiom, free occurrences of
y
z
Next, we get the reduction
(\nux)(0|\overline{z}\langlex\rangle.x(y).0)|z(v).\overline{v}\langlev\rangle.0 → (\nux)(0|x(y).0|\overline{x}\langlex\rangle.0)
Note that since the local name has been output, the scope of is extended to cover the third component as well. This was captured using the scope extension axiom.
Next, using the reduction substitution axiom, we get
(\nux)(0|0|0)
Finally, using the axioms for parallel composition and restriction, we get
0
Alternatively, one may give the pi-calculus a labelled transition semantics (as has been done with the Calculus of Communicating Systems).
In this semantics, a transition from a state
P
P'
\alpha
P\xrightarrow{\overset{}\alpha}P'
P
P'
\alpha
a(x)
\overline{a}\langlex\rangle
A standard result about the labelled semantics is that it agrees with the reduction semantics up to structural congruence, in the sense that
P → P'
P\xrightarrow{\overset{}\tau}\equivP'
The syntax given above is a minimal one. However, the syntax may be modified in various ways.
A nondeterministic choice operator
P+Q
A test for name equality
[x=y]P
P
y
The asynchronous -calculus[6] [7] allows only outputs with no continuation, i.e. output atoms of the form
\overline{x}\langley\rangle
The polyadic -calculus allows communicating more than one name in a single action:
\overline{x}\langlez1,...,zn\rangle.P
x(z1,...,zn).P
\overline{x}\langley1, … ,yn\rangle.P
(\nuw)\overline{x}\langlew\rangle.\overline{w}\langley1\rangle. … .\overline{w}\langleyn\rangle.[P]
x(y1, … ,yn).P
x(w).w(y1). … .w(yn).[P]
All other process constructs are left unchanged by the encoding.
In the above,
[P]
P
The full power of replication
!P
!x(y).P
!x(y).P\equivx(y).P|!x(y).P
Replicated input process such as
!x(y).P
P[a/y]
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}\langleR\rangle.P|x(Y).Q → P|Q[R/Y]
Here,
Y
The -calculus is a universal model of computation. This was first observed by Milner in his paper "Functions as Processes",[9] 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, " is bound to term " – as replicating agents that respond to requests for their bindings by sending back a connection to the term
M
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-complete. 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.[10]
See also: Bisimulation.
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
p
q
R
Early and late bisimilarity were both formulated by Milner, Parrow and Walker in their original paper on the -calculus.[11]
A binary relation
R
(p,q)\inR
p\xrightarrow{a(x)}p'
y
q'
q\xrightarrow{a(x)}q'
(p'[y/x],q'[y/x])\inR
\alpha
{ p\xrightarrow{\overset{}{\alpha}}p' }
q'
q\xrightarrow{\overset{}{\alpha}}q'
(p',q')\inR
p
q
Processes
p
q
p\simeq
(p,q)\inR
R
In late bisimilarity, the transition match must be independent of the name being transmitted.A binary relation
R
(p,q)\inR
p\xrightarrow{a(x)}p'
q'
q\xrightarrow{a(x)}q'
(p'[y/x],q'[y/x])\inR
\alpha
p\xrightarrow{\overset{}{\alpha}}p'
q'
q\xrightarrow{\overset{}{\alpha}}q'
(p',q')\inR
p
q
p
q
p\simlq
(p,q)\inR
R
Both
\sime
\siml
p
q
p\simeq
a(x).p\not\simea(x).q
\sime
\siml
Fortunately, a third definition is possible, which avoids this problem, namely that of open bisimilarity, due to Sangiorgi.[12]
A binary relation
R
(p,q)\inR
\sigma
\alpha
p\sigma\xrightarrow{\overset{}{\alpha}}p'
q'
q\sigma\xrightarrow{\overset{}{\alpha}}q'
(p',q')\inR
Processes
p
q
p\simoq
(p,q)\inR
R
Early, late and open bisimilarity are distinct. The containments are proper, so
\simo\subsetneq\siml\subsetneq\sime
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.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.
Alternatively, one may define bisimulation equivalence directly from the reduction semantics. We write
p\Downarrowa
p
a
A binary relation
R
(p,q)\inR
(1)
p\Downarrowa
q\Downarrowa
a
and
(2) for every reduction
p → p'
q → q'
such that
(p',q')\inR
We say that
p
q
R
(p,q)\inR
Defining a context as a term with a hole [] we say that two processes P and Q are barbed congruent, written
P\simbQ
C[]
C[P]
C[Q]
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 http://www.proverif.ens.fr/ due to Bruno Blanchet, based on a translation of the applied -calculus into Blanchet's logic programming framework. Another example is Cryptyc http://www.cryptyc.org, 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 modeling 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.[13]
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.[14] Following this seminal paper, other authors described the whole metabolic network of a minimal cell.[15] In 2009, Anthony Nash and Sara Kalvala proposed a -calculus framework to model the signal transduction that directs Dictyostelium discoideum aggregation.[16]
The -calculus was originally developed by Robin Milner, Joachim Parrow and David Walker in 1992, based on ideas by Uffe Engberg and Mogens Nielsen.[17] 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.[18]
The following programming languages implement the -calculus or one of its variants: