Termination in a -calculus with Subtyping Ioana Cristescu Daniel - - PowerPoint PPT Presentation

termination in a calculus with subtyping
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Termination in a π-calculus with Subtyping

Ioana Cristescu Daniel Hirschkoff

ENS Lyon

Express 2011, 5 September 2011

slide-2
SLIDE 2

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

slide-3
SLIDE 3

Outline

Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks

slide-4
SLIDE 4

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

slide-5
SLIDE 5

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’.

slide-6
SLIDE 6

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

slide-7
SLIDE 7

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!

slide-8
SLIDE 8

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

slide-9
SLIDE 9

Outline

Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks

slide-10
SLIDE 10

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

slide-11
SLIDE 11

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
slide-12
SLIDE 12

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)

slide-13
SLIDE 13

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

slide-14
SLIDE 14

Outline

Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks

slide-15
SLIDE 15

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

slide-16
SLIDE 16

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)

slide-17
SLIDE 17

Accomodating functional computation

maybe remove the slide

◮ translate the construct let f

= (x)P1 in P2 Γ, x : T • − ⊢ P : w k ≥ w Γ • f : okT ⊢ !f (x).P : 0 Γ, g : okT • f : onU ⊢ P : w Γ • g : okT ⊢ (νf ) P : w Γ, c : ♯nT • f : okU ⊢ P : w Γ • f : okU ⊢ (νc) P : w where f is functional, c is imperative

slide-18
SLIDE 18

Outline

Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks

slide-19
SLIDE 19

Concluding remarks: Type inference

Inference in Lπ

◮ transmit only the output capabilities on names ◮ types of the form ooo... and ♯ ooo.. ◮ a(x).x(y) not in Lπ ◮ JoCaml, Erlang ◮ a type inference procedure for Lπ available in the paper

Inference in i/o

◮ ongoing work