Termination in a -calculus with Subtyping Ioana Cristescu Daniel - - PowerPoint PPT Presentation
Termination in a -calculus with Subtyping Ioana Cristescu Daniel - - PowerPoint PPT Presentation
Termination in a -calculus with Subtyping Ioana Cristescu Daniel Hirschkoff ENS Lyon Express 2011, 5 September 2011 Type systems for termination in -calculus Termination in a concurrent setting eventual access to shared resources
Type systems for termination in π-calculus
Termination in a concurrent setting
◮ eventual access to shared resources ◮ lock-freedom properties ◮ challenging in presence of allocation of new channels and
threads
A type system for termination
◮ build on simply typed π-calculus ◮ two approaches:
◮ level-based ◮ Deng Sangiorgi[2006], Demangeon et al. [2009] ◮ using a decreasing measure on processes ◮ semantic-based ◮ Sangiorgi[2006], BergerHondaYoshida[2004] ◮ logical relations
Outline
Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks
Level-based approach for the termination of the π-calculus processes Reduction of processes
a(x).P | av − → P[v/x] !a(x).P | av − → !a(x).P | P[v/x]
◮ !a(x).P - a server granting access to a resource P
The level-based approach
◮ Prevent infinite loops by assigning levels to names ◮ In !a(x).P, P cannot trigger a reduction on the channel a. ◮ Example
◮ type !a(x).bx with lvl(a) > lvl(b) ◮ but not !a(x).bx | !b(y).ay
The level-based termination approach of [DS, Dem]
Processes and values
P ::=
- P1|P2
- av
- (νa) P
- a(x).P
- !a(x).P
v ::= ⋆
- a
Types
T ::= ♯kT
- U
♯kT: the channel has level k and carries names of type T
Typing rules (two of them)
Γ ⊢ a : ♯kT Γ ⊢ v : T Γ ⊢ av : k Γ ⊢ a : ♯kT Γ, x : T ⊢ P : w k > w Γ ⊢ !a(x).P : 0
If Γ ⊢ P : w ∈ N then ‘P has weight w’.
Some examples
Examples:
◮ !p(t).qt
p : ♯lvl(p)T q : ♯lvl(q)T lvl(p) > lvl(q)
◮ !p(t).(qt | qt)
same typing
◮ !a(x).xs
a : ♯lvl(a)♯lvl(x)T lvl(a) > lvl(x)
◮ !p(t).qt | !a(x).xs | ap | aq
♯lvl(p)T = ♯lvl(q)T Not typable!
Theorem
If Γ ⊢ P : w, then P terminates. maybe i should put this after we presented our type system? this is not our proof
Similar phenomena, on inputs
maybe remove the slide
More examples:
◮ !b(y).!y(z).c
b : ♯lvl(b)♯lvl(y)T lvl(y) > lvl(c)
◮ !b(y).!y(z).c | !p(t).qt | bp | bq
♯lvl(p)T = ♯lvl(q)T Not typable!
But the example should be typable
◮ !a4(x).x3s | !p3(t).q1t | a4p3 | a4q1
Should be typable because
◮ lvl(p) < lvl(a) and lvl(q) < lvl(a) ◮ x only used in output
◮ !a4(x).(x3s | x3(t))
◮ lvl(x) < lvl(a) ◮ x used both as input and output
◮ !b4(y).!y4(z).c3 | !p6(t).q5t | b 4p6 | b 4q5
maybe remove this example Should be typable because
◮ lvl(p) > lvl(c) and lvl(q) > lvl(c) ◮ y only used in input
Outline
Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks
Introducing capabilities
input/output types [PierceSangiorgi96]
distinguish the capabilities associated to a given channel
◮ input
a : iT
◮ output
a : oT capabilities can be seen as rights
◮ both
a : ♯T Example
◮ a : ♯(oT)
the channel can both send and receive a name of type oT a(x).xt OK a(x).x(y) not OK
Extending the level-based approach to termination with subtyping Typing values
Γ ⊢ ⋆ : U Γ(a) = T Γ ⊢ a : T Γ ⊢ a : T T ≤ U Γ ⊢ a : U
Subtyping
≤ is the least relation that is reflexive, transitive, and satisfies the following rules: ♯kT ≤ ikT ♯kT ≤ okT T ≤ S k1 ≤ k2 ik2T ≤ ik1S T ≤ S k1 ≤ k2
- k1S ≤ ok2T
Typing processes
Deng&Sangiorgi’s system unchanged Γ ⊢ 0 : 0 Γ ⊢ a : okT Γ ⊢ v : T Γ ⊢ av : k Γ ⊢ a : ikT Γ, x : T ⊢ P : w Γ ⊢ a(x).P : w Γ ⊢ a : ikT Γ, x : T ⊢ P : w k > w Γ ⊢ !a(x).P : 0 Γ, a : T ⊢ P : w Γ ⊢ (νa) P : w Γ ⊢ P1 : w1 Γ ⊢ P2 : w2 Γ ⊢ P1|P2 : max(w1, w2)
Apply subtyping to a channel with the output capability
♯kT ≤ okT T ≤ S k1 ≤ k2
- k1S ≤ ok2T
Example
◮ !a4(x).x3 | !p3.q1 | a4p3 | a4q1
a : ♯4o3T p : ♯3T q : o1T subtyping on a ♯4o3T < o4o3T < o4♯3T ♯4o3T < o4o3T < o4o1T
Outline
Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks
Analysing the type system’s expressiveness
Encoding simply typed λ-calculus
◮ “parallel call by value”
[ [λx.M] ]p
def
= (νy) (!y(x, q).[ [M] ]q | py) [ [x] ]p
def
= px [ [M N] ]p
def
= (νq, r)
- [
[M] ]q | [ [N] ]r | q(f ).r(z).f z, p
- Can we recognise the encoding of simply typed λ-calculus as
terminating using our type system?
◮ more expressive than Deng&Sangiorgi’s ◮ still does not cover the encoding of simply typed λ-calculus
Accomodating functional computation
Expanding the system of levels and capabilities into an impure π-calculus
◮ based on [DHS10] ◮ distinguish two kinds of names
◮ functional (arising in the encoding of λ) ◮ imperative (no particular constraints)