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 ◮ 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 | a � v � − → P [ v / x ] ! a ( x ) . P | a � v � − → ! 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 ) . b � x � with lvl( a ) > lvl( b ) ◮ but not ! a ( x ) . b � x � | ! b ( y ) . a � y �
The level-based termination approach of [DS, Dem] Processes and values � ( ν a ) P � ! a ( x ) . P � � P 1 | P 2 � � a � v � � � � a ( x ) . P � P ::= 0 � a � ::= ⋆ v Types ♯ k T : the channel has level k and carries � U ♯ k T � T ::= names of type T Typing rules (two of them) Γ ⊢ a : ♯ k T Γ ⊢ v : T Γ ⊢ a � v � : k Γ ⊢ a : ♯ k T Γ , x : T ⊢ P : w k > w Γ ⊢ ! a ( x ) . P : 0 If Γ ⊢ P : w ∈ N then ‘P has weight w’ .
Some examples Examples: ◮ ! p ( t ) . q � t � p : ♯ lvl( p ) T q : ♯ lvl( q ) T lvl( p ) > lvl( q ) ◮ ! p ( t ) . ( q � t � | q � t � ) same typing ◮ ! a ( x ) . x � s � a : ♯ lvl( a ) ♯ lvl( x ) T lvl( a ) > lvl( x ) ◮ ! p ( t ) . q � t � | ! a ( x ) . x � s � | a � p � | a � q � ♯ 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 ) . q � t � | b � p � | b � q � ♯ lvl( p ) T = ♯ lvl( q ) T Not typable!
But the example should be typable ◮ ! a 4 ( x ) . x 3 � s � | ! p 3 ( t ) . q 1 � t � | a 4 � p 3 � | a 4 � q 1 � Should be typable because ◮ lvl( p ) < lvl( a ) and lvl( q ) < lvl( a ) ◮ x only used in output ◮ ! a 4 ( x ) . ( x 3 � s � | x 3 ( t )) ◮ lvl( x ) < lvl( a ) ◮ x used both as input and output 4 � p 6 � | b 4 � q 5 � ◮ ! b 4 ( y ) . ! y 4 ( z ) . c 3 | ! p 6 ( t ) . q 5 � t � | b 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 : i T ◮ output a : o T capabilities can be seen as rights ◮ both a : ♯ T Example ◮ a : ♯ (o T ) the channel can both send and receive a name of type o T a ( x ) . x � t � OK a ( x ) . x ( y ) not OK
Extending the level-based approach to termination with subtyping Typing values Γ( a ) = T Γ ⊢ a : T T ≤ U Γ ⊢ ⋆ : U Γ ⊢ a : T Γ ⊢ a : U Subtyping ≤ is the least relation that is reflexive, transitive, and satisfies the following rules: T ≤ S k 1 ≤ k 2 T ≤ S k 1 ≤ k 2 ♯ k T ≤ i k T ♯ k T ≤ o k T i k 2 T ≤ i k 1 S o k 1 S ≤ o k 2 T
Typing processes Deng&Sangiorgi’s system unchanged Γ ⊢ a : o k T Γ ⊢ a : i k T Γ ⊢ v : T Γ , x : T ⊢ P : w Γ ⊢ 0 : 0 Γ ⊢ a � v � : k Γ ⊢ a ( x ) . P : w Γ ⊢ a : i k T Γ , x : T ⊢ P : w k > w Γ , a : T ⊢ P : w Γ ⊢ ! a ( x ) . P : 0 Γ ⊢ ( ν a ) P : w Γ ⊢ P 1 : w 1 Γ ⊢ P 2 : w 2 Γ ⊢ P 1 | P 2 : max ( w 1 , w 2 )
Apply subtyping to a channel with the output capability T ≤ S k 1 ≤ k 2 ♯ k T ≤ o k T o k 1 S ≤ o k 2 T Example ◮ ! a 4 ( x ) . x 3 | ! p 3 . q 1 | a 4 � p 3 � | a 4 � q 1 � a : ♯ 4 o 3 T p : ♯ 3 T q : o 1 T subtyping on a ♯ 4 o 3 T < o 4 o 3 T < o 4 ♯ 3 T ♯ 4 o 3 T < o 4 o 3 T < o 4 o 1 T
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” def def [ [ λ x . M ] ] p = ( ν y ) (! y ( x , q ) . [ [ M ] ] q | p � y � ) [ [ x ] ] p = p � x � def � � [ [ M N ] ] p = ( ν 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)
Accomodating functional computation maybe remove the slide ◮ translate the construct let f = ( x ) P 1 in P 2 Γ , x : T • − ⊢ P : w k ≥ w Γ • f : o k T ⊢ ! f ( x ) . P : 0 Γ , g : o k T • f : o n U ⊢ P : w where f is functional, Γ • g : o k T ⊢ ( ν f ) P : w c is imperative Γ , c : ♯ n T • f : o k U ⊢ P : w Γ • f : o k U ⊢ ( ν c ) P : w
Outline Some limitations of the level-based approach Introducing i/o capabilities Expressiveness: accomodating functions Concluding remarks
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
Recommend
More recommend