Termination in higher-order processes L3 internship under the supervision of Daniel Hirschkoff Simon Castellan December, 1 st 2011
Introduction ◮ a study of termination in higher order π -calculus ( π -calculus where messages can be (parametrized) processes) ◮ talk overview ◮ presentation of HO π ω : termination and non-termination in this calculus ◮ description of λπ : HO π ω with the (simply typed) λ -calculs ◮ Soft- λπ : a subcalculus on which types give information about the length of reductions
Contents HO π ω :Higher order π -calculus λπ : higher order π -calculs with full λ -calculus Soft- λπ : toward a bound on the length of reductions
HO π ω ◮ π -calculus where processes may exchange (parametrised processes) ◮ the grammar for this language is ( names ) a , b ( processes ) P , Q ::= 0 null | ( P || Q ) parallel | a ( x ) . P reception | a � V � message | ( ν a ) P name restriction | V W functional application variables � = names ( values ) V , W ::= x | λ x . P function | ⋆ base value ◮ communication rule : a ( x ) . P || a � V � → P [ V / x ]
Non termination in HO π ω ◮ reduction in HO π ω : ◮ a ( x ) . P || a � V � → P [ V / x ] ◮ ( λ x . P ) V → P [ V / x ] ◮ “concurrent auto-application” : ◮ δ ≡ a ( f ) . ( f ⋆ || a � f � ) ◮ Ω ≡ δ || a � λ x .δ � → Ω
Non termination in HO π ω ◮ reduction in HO π ω : ◮ a ( x ) . P || a � V � → P [ V / x ] ◮ ( λ x . P ) V → P [ V / x ] ◮ “concurrent auto-application” : ◮ δ ≡ a ( f ) . ( f ⋆ || a � f � ) ◮ Ω ≡ δ || a � λ x .δ � → Ω ◮ the similar process : δ ′ ≡ a ( f ) . ( f ⋆ || b ( x ) . ( c � x � || a � f � )) waits for a message on b at each iteration : “ spawning ” (in [LMS10], Dal Lago, Martini and Sangiorgi)
Typing in HO π ω for termination ◮ two strategies developed in [LMS10] and [DHS10] to make a type system that guarantees termination ◮ in this talk, I use a strategy based on [DS06]. the idea is to stratify channels : to each channel, we associate an integer representing the level of the channel Γ ⊢ t ′ : k ′ Γ( a ) = ♯ k τ Γ ⊢ t : k Γ ⊢ t : τ Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ a � t � : k
Typing in HO π ω for termination ◮ two strategies developed in [LMS10] and [DHS10] to make a type system that guarantees termination ◮ in this talk, I use a strategy based on [DS06]. the idea is to stratify channels : to each channel, we associate an integer representing the level of the channel Γ ⊢ t ′ : k ′ Γ( a ) = ♯ k τ Γ ⊢ t : k Γ ⊢ t : τ Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ a � t � : k ◮ controlling inputs : Γ( a ) = ♯ k ( τ ) Γ , x : τ ⊢ P : n < k Γ ⊢ a ( x ) . P : 0
Typing example Γ ⊢ t ′ : k ′ Γ( a ) = ♯ k τ Γ ⊢ t : k Γ ⊢ t : τ Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ a � t � : k Γ( a ) = ♯ k ( τ ) Γ , x : τ ⊢ P : n < k Γ ⊢ a ( x ) . P : 0 ◮ a ( x ) . a � x � is rejected ◮ a ( x ) . ( b � x � || c � x � ) is accepted iff b and c are < a . ◮ a ( x ) . b ( x ) . a � x � may be accepted (the output on a is hidden by the reception on a )
Typing example Γ ⊢ t ′ : k ′ Γ( a ) = ♯ k τ Γ ⊢ t : k Γ ⊢ t : τ Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ a � t � : k Γ( a ) = ♯ k ( τ ) Γ , x : τ ⊢ P : n < k Γ ⊢ a ( x ) . P : 0 ◮ a ( x ) . a � x � is rejected ◮ a ( x ) . ( b � x � || c � x � ) is accepted iff b and c are < a . ◮ a ( x ) . b ( x ) . a � x � may be accepted (the output on a is hidden by the reception on a ) ◮ functions : ◮ if x : τ ⊢ P : n , then ⊢ λ x . P : τ → n +1 ⋄ ◮ application: the term V W has level n iff V has type τ → n ⋄
Termination proof Theorem Every well-typed term of HO π ω is strongly normalizing. Proof. ◮ attach to P , m ( P ) the multiset of outputs ( a k � V � ) at top-level in P and levels of applications (( λ n x . P ) V ) ◮ m ( b � x � || c � x � || a ( x ) . d � x � ) = { lvl( b ) , lvl( c ) } ◮ show that P → P ′ implies m ( P ) > m ( P ′ ) for multiset ordering. ◮ P ≡ a ( x ) . P 0 || a � V � → P ′ ≡ P 0 [ V / x ] ◮ P ≡ ( λ x . P 0 ) V → P ′ ≡ P 0 [ V / x ]
Contents HO π ω :Higher order π -calculus λπ : higher order π -calculs with full λ -calculus Soft- λπ : toward a bound on the length of reductions
λπ : syntax and semantics ◮ λπ is an extension in HO π ω where all functions are available. ◮ grammar where processes and functions coexist : t , u ::= 0 null | ( t || u ) parallel | a ( x ) . t | a � t � reception message | ( ν a ) t name restriction | x variable | λ x . t abstraction | t u application ◮ channels are not first-class values (but π can be encoded)
λπ : syntax and semantics ◮ λπ is an extension in HO π ω where all functions are available. ◮ grammar where processes and functions coexist : t , u ::= 0 null | ( t || u ) parallel | a ( x ) . t | a � t � reception message | ( ν a ) t name restriction | x variable | λ x . t abstraction | t u application ◮ channels are not first-class values (but π can be encoded) ◮ reduction : same two primitve rules as in HO π ω . ◮ strategy : weak reduction for the λ -calculus (although we could reduce under abstraction and inputs), in particular reduction inside messages
A few examples ◮ contains spawning and classic idioms of HO π ω . ◮ messages as localities : ◮ P → P ′ implies a � P � → a � P ′ � ◮ a � P � ( P not a normal form) can be read “ P running at a ” ◮ passivation : a ( X ) . b � X � takes whatever process running at a and transfers it to b
A few examples ◮ contains spawning and classic idioms of HO π ω . ◮ messages as localities : ◮ P → P ′ implies a � P � → a � P ′ � ◮ a � P � ( P not a normal form) can be read “ P running at a ” ◮ passivation : a ( X ) . b � X � takes whatever process running at a and transfers it to b ◮ channels as first-class values : ◮ given a , the couple ( λ x . a � x � ) , ( λ f . a ( x ) . f x ) represents channel a
Typing in λπ ◮ type grammar : σ, τ ::= ⋆ base type σ → τ function type k ( ∈ N ) type of processes at level k α ::= ♯ k ( τ ) channel types carrying values of type τ ◮ for the λ part : simple types ◮ for the concurrent part : tracking receptions’ body for incorrect outputs (as before) ◮ type of a process = maximum of the levels of the channels carrying top-level messages ◮ in particular, spawning is typable
Typing rules Γ( x ) = τ Γ , x : τ ⊢ t : σ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ x : τ Γ ⊢ λ x . t : τ → σ Γ ⊢ t u : τ Γ( a ) = ♯ k τ Γ( a ) = ♯ k τ Γ ⊢ t : τ Γ , x : τ ⊢ t : p < k Γ ⊢ a � t � : k Γ ⊢ a ( x ) . t : 0 Γ ⊢ t ′ : k ′ Γ , a : ♯ k τ ⊢ t : τ Γ ⊢ t : k Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ ( ν a ) t : τ Γ ⊢ 0 : 0
Typing rules Γ( x ) = τ Γ , x : τ ⊢ t : σ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ x : τ Γ ⊢ λ x . t : τ → σ Γ ⊢ t u : τ Γ( a ) = ♯ k τ Γ( a ) = ♯ k τ Γ ⊢ t : τ Γ , x : τ ⊢ t : p < k Γ ⊢ a � t � : k Γ ⊢ a ( x ) . t : 0 Γ ⊢ t ′ : k ′ Γ , a : ♯ k τ ⊢ t : τ Γ ⊢ t : k Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ ( ν a ) t : τ Γ ⊢ 0 : 0
Typing rules Γ( x ) = τ Γ , x : τ ⊢ t : σ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ x : τ Γ ⊢ λ x . t : τ → σ Γ ⊢ t u : τ Γ( a ) = ♯ k τ Γ( a ) = ♯ k τ Γ ⊢ t : τ Γ , x : τ ⊢ t : p < k Γ ⊢ a � t � : k Γ ⊢ a ( x ) . t : 0 Γ ⊢ t ′ : k ′ Γ , a : ♯ k τ ⊢ t : τ Γ ⊢ t : k Γ ⊢ t || t ′ : max( k , k ′ ) Γ ⊢ ( ν a ) t : τ Γ ⊢ 0 : 0
Subtyping ◮ there are two (related) problems with the previous rules : ◮ f ( a ( x ) . 0 || a � ⋆ � ) → f 0, does f have the type level( a ) → .. or 0 → ... (subject reduction) ? ◮ if we have a process of level k why can’t we pass it to a function expecting a process of level k ′ > k (polymorphism) ? ◮ one way to resolve that problem is to introduce subtyping. ◮ k ⊑ k ′ iff k ≤ k ′ (types of processes) ◮ σ → τ ⊑ σ ′ → τ ′ iff σ ′ ⊑ σ and τ ⊑ τ ′ ◮ then we add the subsumption rule Γ ⊢ t : σ σ ⊑ τ Γ ⊢ t : τ
Termination in λπ Theorem Every well-typed term of λπ is strongly normalizing. Proof. ◮ proof by reducibility candidates. ◮ [[ k ]] = { t , Γ ⊢ t : k and t is strongly normalizing } ◮ for the λ part, everything goes as usual ◮ for the concurrent part, we need a lemma : ◮ if P || Q reduces to R with a communication between P and Q , then w ( R ) < w ( P || Q ) ◮ same argument as in HO π ω .
Comparison with the λ -calculus with regions ([Ama09]) ◮ the λ -calculus with regions is a calculus that abstracts references, channels into the the concept of regions ◮ two primitive operations ◮ get( r ) to read from a store (receive) ◮ write( r , v ) to write a value to a store (send) ◮ difference in operational semantics : ◮ listen (in λπ ) : blocking, erases the value ◮ get (in [Ama09]) : non-blocking, leaves the value
Recommend
More recommend