Interpreting the Full λ-calculus in the π-calculus Xiaojuan Cai Joint work with Yuxi Fu BASICS Lab October 12, 2009
Motivation The λ-calculus: sequential model; The π-calculus: concurrent model A deep comparison between them is necessary; to reveal the expressiveness of π-calculus; to study the λ-calculus in a concurrent context; Encoding from the lazy λ-calculus to the π-calculus [Milner, 1992][Sangiorgi, 1994] Comparisons between the full λ-calculus and the π-calculus are still absent.
1 Technical background 2 Encoding the full λ-calculus into the π-calculus Tree structure in the π-calculus 3 How does the encoding work? 4 Conclusion
The λ-calculus Full λ-calculus M := x λx.m MM 1 2 3 (λx.m)n M{N/x} M M MN M N N N MN MN β-rule structure rule eager evaluation 4 M M λx.m λx.m Lazy λ-calculus 1 + 2 partial evaluation
The π-calculus Syntax P := i I ϕ i µ i.p i P P (x)p D( x) µ := a(b) a b τ ϕ := x = y x y ϕ ϕ D 1 ( x) = P 1 D n ( x) = P n.
Some abbreviations a x 1,.., x n.p a(x 1,.., x n ).P def = a(v).vx 1...vx n.p def = a(v).v(x 1 )...v(x n ).P begin case ϕ 1 µ 1.P 1 ϕ n µ n.p n end case. def = i {1,,n} ϕ i µ i.p i
Lazy λ-calculus to π-calculus by Milner x (u) λx.m (u) MN (u) def = xu def = u(x).u(v). M (v) def = (xv)( M (v) vx.vu!x(w). N (w)) Which part must be changed in order to interpret ALL FOUR reduction rules?
Lazy λ-calculus to π-calculus by Milner x (u) λx.m (u) MN (u) def = xu def = u(x).u(v). M (v) def = (xv)( M (v) vx.vu!x(w). N (w)) Which part must be changed in order to interpret ALL FOUR reduction rules?
Lazy λ-calculus to π-calculus by Milner x (u) λx.m (u) MN (u) def = xu def = u(x).u(v). M (v) def = (xv)( M (v) vx.vu!x(w). N (w)) Which part must be changed in order to interpret ALL FOUR reduction rules?
1 Technical background 2 Encoding the full λ-calculus into the π-calculus Tree structure in the π-calculus 3 How does the encoding work? 4 Conclusion
λ-terms as trees x x variable node λx.m λx abstraction node M MN M N application node
An example (λx.(λy.y)(xx))((λz.z)(λw.w)) λx λz λw λy z w y x x
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) β-rule (λx.m)n M{N/x} λx λz λw λy z w y x x
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λy.y)(((λz.z)(λw.w))((λz.z)(λw.w))) λx λz λw λy z w y x x β-rule (λx.m)n M{N/x}
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λy.y)(((λz.z)(λw.w))((λz.z)(λw.w))) λx λy y x x λz λw z w β-rule (λx.m)n M{N/x}
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λy.y)(((λz.z)(λw.w))((λz.z)(λw.w))) β-rule (λx.m)n M{N/x} λy y x x λz λw z w
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λy.y)(((λz.z)(λw.w))((λz.z)(λw.w))) λy y λz λw λz λw λz λw z β-rule (λx.m)n M{N/x} w z w z w
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) Eager evaluation N N MN MN λx λz λw λy z w y x x
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.(λy.y)(xx))(λw.w) λx λz λw λy z w y x x Eager evaluation N N MN MN
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.(λy.y)(xx))(λw.w) λx λz λy z y x x λw w Eager evaluation N N MN MN
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.(λy.y)(xx))(λw.w) λx z Eager evaluation N N MN MN λy y x x λw w
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.(λy.y)(xx))(λw.w) λx λw Eager evaluation N N MN MN λy y x x w λw w
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) Partial evaluation M M λ.m λ.m λx λz λw λy z w y x x
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.xx)((λz.z)(λw.w)) λx λz λw λy z w y x x Partial evaluation M M λ.m λ.m
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.xx)((λz.z)(λw.w)) λx λz λw λy z w y x x Partial evaluation M M λ.m λ.m
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.xx)((λz.z)(λw.w)) λx y λz λw Partial evaluation M M λ.m λ.m x x z w
λ-rules (λx.(λy.y)(xx))((λz.z)(λw.w)) (λx.xx)((λz.z)(λw.w)) λx λz λw x x z w x x Partial evaluation M M λ.m λ.m
Redex node (λx.(λy.y)(xx))((λz.z)(λw.w)) λx λz λw λy z w y x x
λ-term = tree β-reduction = manipulation of trees Let s program in π!
Tree structure in the π-calculus Outline design Tree := Node 1 Node 2 Node n Node := n info + Operations Operations := reduction if the node is a redex node substitution reduction := (change the structure). substitution := x info if the node is a variable node (freeze and backup the disconnected subtree) info := name, parent, leftchild, rightchild,
Tree structure in the π-calculus Node info name parent lchild rchild var fun lchild = rchild =. variable node lchild = rchild. abstraction node lchild rchild. application node lchild = rchild fun =. redex node
Tree structure in the π-calculus Node operations - move n l r n r λx N M N n M Move(n, n ) def = n(p, l, r, v, f ).n (p, l, r, v, f ). (Node(n, p, l, r, v, f ) begin case l = r l(p, l, r, v, f ).Node(l, n, l, r, v, f ) l r l(p, l, r, v, f ).r(p, l, r, v, f ). (Node(l, n, l, r, v, f ) Node(r, n, l, r, v, f )) end case)
Tree structure in the π-calculus Node operations - freeze and backup n l r n r n r λx N M N M N n M Freeze(r, x) def = r(p, l, r, v, f ).(x 0 x 1 ) begin case l r Freeze(l, x 0 ) Freeze(r, x 1 )!x(p, n, f ).(l r )(Node(n, p, l, r, v, f ) l = r Freeze(l, x 0 )!x(p, n, f ). l=r=!x(p, n, f ).Node(n, p,,, v, f ) end case
Tree structure in the π-calculus Node operations - freeze and backup n l r n r n r λx N M N M N n M Freeze(r, x) Tree(r, N) = Replica(x, N) def = (x 0 x 1 x n )!x(p, n, f ).(l r )(Node(n, p, l, r, v, f ) x 0 n, l, x 1 n, r, )!x 0 (p, n, f ).(l r )...!x 1 (p, n, f ).(l r )......
Tree structure in the π-calculus Node operations - substitute n l r n r n r n r λx N M N M N M N n M N N N Substitution(m, p, x, f ) def = x p, m, f Substitution(m, p, x, f ) Replica(x, N) = Tree(m, N) Replica(x, N)
Tree structure in the π-calculus The encoding M λ x f n,p λx.m f n,p MN f n,p def = (n, s, )( M n,λ Sem(s)) def = L(n, p,,, x, f ) def = (m, x)(l(n, p, m, m, x, f ) M m,n) def = (l, r)(l(n, p, l, r,, f ) M l,n N r,n) Sem(s) def = s.s.sem(s)
Tree structure in the π-calculus The encoding the definition of node process
1 Technical background 2 Encoding the full λ-calculus into the π-calculus Tree structure in the π-calculus 3 How does the encoding work? 4 Conclusion
Correctness full abstraction Theorem 1. For all closed λ-terms M, N, M = a N if and only if M λ N λ. Definition A symmetric binary relation R on Λ 0 is an applicative bisimulation if the following properties hold whenever MRN: If M λx.m then N λx.n for some N such that M {L/x}RN {L/x} for every L Λ 0. The applicative bisimilarity = a is the largest applicative bisimulation.
Correctness operational correspondence Theorem 2. There is a subbisimilarity R from the set of closed λ-terms to the set of π-processes. Preservation If M M, then M = M ; Reflection τ If M P, then there exists some M such that M M and P = M ; Termination M iff M ; τ
1 Technical background 2 Encoding the full λ-calculus into the π-calculus Tree structure in the π-calculus 3 How does the encoding work? 4 Conclusion
Conclusion What we have done An encoding from the full λ-calculus to the π-calculus with mismatch and parametric definition is proposed; It is proved to be good. Question Can the encoding be implemented in the π-calculus without guarded choice?
Thank you! Questions?
Some definitions Operational semantics of π-calculus I Prefix Composition a(x).p ay P{y/x} ax.p ax P P µ P P Q µ P Q P ax P Q ax Q P Q τ P Q Restriction ax P P Q P Q τ (x)(p Q ) Q a(x) P ax P (x)p a(x) P P µ P x not in µ (x)p µ (x)p
Some definitions Operational semantics of π-calculus II Replication Case P!P µ P!P µ P µ ϕ i µ i.p i i P i i I ϕ µ iµ i.p i i P i Definition P i {ỹ i / x i } µ P µ D i (ỹ i ) P
Some definitions Definition: subbisimilarity R Λ 0 P is a subbisimilarity if : 1 M Λ 0. P.MRP; 2 If MRP and M M then P = τ P and M RP for some P ; 3 If MRP τ P then MRP or M M RP for some M ; 4 τ τ If MRP 0 and P 0 P 1 P i τ is an infinite sequence of τ-actions, then there must be some k 1 and M, such that M M RP k ; 5 If (λx.m)rp, then P = P λz P for some P, P and some fresh z such that λx.mrp and M{N/x}R(z)(P T (z, N)) for every closed λ-term N. 6 If MRP and P λz P for some fresh z, then M λx.m for some x, M such that M {N/x}R(z)(P T (z, N)) for every closed λ-term N.
Some definitions References 1 R. Milner. Functions as Processes. Mathematical Structures in Computer Science, 2:119C146, 1992. 2 D. Sangiorgi. The Lazy λ-calculus in a Concurrency Scenario. Information and Computation, 111:120C 153, 1994.