The π-calculus Overview Snta eaction, actions, and transitions eferences obin Milner, Communicating and Mobil Sstems Davide Sangiorgi and David Walker, The π-calculus: A Theor of Mobile Processes obin Milner, Joachim Parrow, David Walker, A Calculus of Mobile Processes, Part I+II 153 From CCS to π-calculus The π-calculus is a model of concurrent computation based upon the notion of naming. The π-calculus is a calculus in which the topolog of communication can evolve dnamicall during evaluation. In the π-calculus communication links are identified b names, and computation is represented purel as the communication of names across links. The π-calculus is an etension of the process algebra CCS, following the work b Engberg and Nielsen who added mobilit to CCS while preserving its algebraic properties. 154 The π-calculus - Basic Ideas The most primitive in the π-calculus is a name, Names, infinitel man, are,, N; the have no structure. In the π-calculus we onl have one other kind of entit: a process. We use P,, to range over processes. Processes evolve b performing actions. The capabilities for actions are epressed via prefies, of which there are four kinds: π :: = (z) [ = ] π 155 1
Prefies Output prefi: The output prefi denotes a process s capabilit to send the name via the name. Input prefi: The input prefi (z) denotes a process s capabilit to receive an name, sa, via the name. The role of z is that of placeholder that will be substituted with the received name. Silent prefi: The silent prefi denotes an unobservable action. As in CCS, the silent prefi can be thought of as epressing an internal action of a process. Match prefi: The match prefi [ = ]π is a conditional capabilit, that is, π if and are the same name. 156 The π-calculus - Snta The set P π of π-calculus process epressions is defined b the following snta: P ::= Σ i I π i.p i P 1 P 2 ν P!P where I is an finite indeing set. The processes Σ i I π i.p i are called summations or sums. We often write simpl M 1 + M 2 for Σ i {1,2} π i.p i. Note, however, that summation binds more tightl than composition, restriction, and replication. If I =, then Σ i I π i.p i is the empt sum, written 0. 157 estriction In the restriction ν P, the scope of the name is restricted to P. Components of P can use to interact with one another, but not with other processes. The process ν (((z).z.0 + wv.0) u.0) has onl two capabilities: to send v via w, and to evolve invisibl as an effect of an interaction between its components via. The scope of a restriction ma change as the result of an interaction between processes. Unlike restriction in concurrent processes (or CCS), names in π-calculus can be transmitted. In the case of a restricted name this means that this name ma etrude its original scope. 158 2
eplication The replication!p can be thought of as an infinite composition P P or, equivalentl, a process satisfing the equation!p = P!P. eplication is an operator that makes it possible to epress infinite behaviors. The process!(z).!z.0 can receive names via repeatedl, and can repeatedl send via an name it does receive. 159 Link Passing Free Channel P The agent P, with fn(), has a link to, and wishes to pass along its link to. is willing to receive it..p (z). in the diagram is {/z}. P' {/z}' 160 Link Passing Private Channel P The agent P, with fn(), has a link to, and wishes to pass along the private to. The scope of the private name include both P and. ν (.P (z).) ν (P' {/z}') ν (.P (z).) =. ν (P' {/z}') 161 3
Scope Intrusion P scope of scope of S S The agent P, with fn(), has a link to, and wishes to pass along its link to. is willing to receive it, but alread possesses a private link to S. The latter needs to be renamed to avoid the capture of the received free name in S..P ν ((z). S) P' ν'({/z}{'/}' {'/}S) 162 Scope Etrusion scope of P scope of ν (.P ) (z). The agent P, with fn(), has a link to, but this link is private. P wishes to pass along its link to. is willing to receive it, and possesses no -link. This situation is eactl that of a program P, with a local variable modeled b a storage register, passing to a procedure, which takes its parameter b reference, not b value. 163 ν (P' {/z}') fn(), fn() scope of P scope of Now suppose both and possess no -link. ν (.P ) (z). ν (P' {/z}') However, there is a general law: ν (P P ) = P ν P 1 2 1 2 so ν (P' {/z}') = P' ν ( {/z}') 164 4
Binding In each of (z).p and νz P, the name z occurs bound with scope P. An occurrence of a name in a process is free if it is not bound. We write fn(p) for the set of names that have free occurrences in P. fn(( z.0 + wv.0) u.0) = {z,, w, v,, u} fn( ν (((z).z.0 + wv.0) νu u.0)) = {, w, v} 165 Substitution The process, σp, obtained b appling the name substitution σ to P is defined as follows: σ0 = 0 σ(π.p) = σπ.σp σ(m 1 + M 2) = σm 1 + σm 2 σ(p 1 P 2) = σp 1 σp 2 σ(νz P) = νz σp σ(!p) =!σp Note σ(σ i I π i.p i ) = Σ i I σπ i.σp i. 166 Process Contet An occurrence of 0 in a process is degenerate if it is the left or right term in a sum M 1 + M 2, and non-degenerate otherwise. A π-calculus process contet C is obtained when the hole [ ] replaces a non-degenerate occurrence of 0 in a process term given b the π-calculus grammar. Eamples: νz ([ ]!z(w).wa.0) (z).! νw (zw.[ ] + (v).0) An equivalence relation S on π-calculus processes is a congruence if (P, ) S implies (C[P], C[]) S for ever contet C. 167 5
Structural Congruence ules Change of bound names (alpha-conversion) Aioms: [ = ]π.p π.p M 1 + (M 2 + M 3) (M 1 + M 2) + M 3 M 1 + M 2 M 2 + M 1 M + 0 M P 1 (P 2 P 3) (P 1 P 2) P 3 P 1 P 2 P 2 P 1 P 0 P νz νw P νw νz P νz 0 0 νz (P 1 P 2) P 1 νz P 2 if z fn(p 1)!P P!P 168 Standard Form A π-caluculus process epression ν ~ (M... M... ), 1 n 1 m where each M i is a non-empt summation, is said to be in standard form. Theorem: Ever π-calculus process is structurall congruent to a standard form. Proof: For an restriction ν a inside a summation, we can bring it to the outermost b using alpha-conversion (if necessar) followed b the rule ν a (P ) ν a P in conjunction with some of the laws of structural congruence. 169 eaction ules The reaction relation over P π contains eactl those transition that can be inferred from the rules in the following table: TAU:.P + M P INTE: ((z).p + M) (. + N) {/z}p P P' PA: P P' P STUCT: P P' ES: ν a P ν a P' P P' P' ' ' 170 6