Characterisation of Strongly Normalising λµ-terms Ugo de Liguoro joint work with Steffen van Bakel and Franco Barbanera ITRS - June 2012, Dubrovnik
Introduction Parigot s λµ-calculus is an extension of the pure λ-calculus to compute with classical proofs Parigot proved that all typeable λµ-terms (both in first and second order logic) are strongly normalizing, but the larger set of SN terms in his calculus was not considered based on the domain-theoretic model by Streicher and Reus, we have proposed an intersection type assignment system which is invariant under reduction and expansion (TLCA 11) we prove here that Pottinger s characterisation of SN λ-terms extends to λµ by suitably restricting our system
Parigot s λµ-calculus λµ syntax: M, N ::= x λx.m MN µα.q (terms) Q ::= [α]m (commands) Structural substitution: T[α L] the replacement of all [α]n by [α]nl in T Reduction: (β) : (λx.m)n M[N/x] (µ) : (µβ.q)n µβ.q[β N] Example (where α M, N): (µα.[α](m(µβ.[α]n)))l µα.[α](m(µβ.[α]nl)l)
Continuation Semantics (Streicher-Reus) Continuation domain equations R results D = [C R] denotations C = (D C) continuations If (R,D,C) are a solution then D is an extensional λ-model: D [C R] [(D C) R] [D [C R]] [D D] while C is the infinite product: C D D
Term Interpretation Env = (Var D) + (Name C) [[ ]] D : Trm Env D [[ ]] C : Cmd Env C [[x]] D e k = e x k [[λx.m]] D e k = [[M]] D e[x := d]k d,k = k [[MN]] D e k = [[M]] D e [[N]] D e,k [[µα.q]] D e k = d k d,k = [[Q]] C e[α := k] [[[α]m]] C e = [[M]] D e,e α where e Env, d D and k,k C.
Types and type inclusion L R : ρ ::= ν ρ ρ ω L C : κ ::= δ κ κ κ ω L D : δ ::= ρ κ ρ δ δ ω Some axioms for the preorders C and D (= is 1 ): ω ω = C ω, ω ω = D ω, ρ = D ω ρ Filter Domains solving Continuation Equations Let F A = Filt(L A / A ) for A = R,D,C: F D [F C F R ] and F C F D F C
Typing judgements Typing judgements are triples of a basis, a term/command judgement and a context: basis: Γ = {x 1 : δ 1,...,x n : δ n }, with x i Var, δ i L D judgement: term: M : δ with M Trm, δ L D command: Q : κ with Q Cmd, κ L C context: = {α 1 : κ 1,..., α m : κ m }, with α i Name, κ i L C A typing judgement has either forms: Γ M : δ or Γ Q : κ
The full type assignment system (TLCA 11) (Var) Γ,x : δ x : δ Γ,x : δ M : κ ρ ( I) Γ λx.m : δ κ ρ Γ M : δ α : κ, ( ) Γ [α]m : δ κ α : κ, Γ M : δ κ ρ Γ N : δ ( E) Γ MN : κ ρ Γ Q : (κ ρ) κ α : κ, (µ) Γ µα.q : κ ρ (ω) Γ M : ω Γ M : δ Γ M : δ ( ) Γ M : δ δ Γ M : δ Γ M : δ δ δ ( )
Pottinger s Theorem Theorem (Pottinger) A λ-term M is strongly normalisable if and only if there exist Γ,σ such that Γ M : σ is derivable in an intersection type system without the type ω. Can we get rid of ω in the system for λµ? Of course we have to abandon rule: (ω) Γ M : ω but what about the types?
The meaning of ω The type κ = δ 1 δ k ω L C is semantically inhabited by any infinite tuple: d 1,...,d k,d k+1,... C such that d i [[δ i ]] D for i = 1,...,k. We then restrict the occurrences of ω to the end of a product type κ and add the axiom: δ 1 δ 2 ω δ 1 ω By eliminating rule (ω) the meaning of ω changes: lack of information partial information about a total object
The computability interpretation of types L ω R L ω C L ω D : ρ ::= ν ρ ρ ω : κ ::= δ ω δ κ κ κ ω : δ ::= ρ ω ρ κ ρ δ δ ω
The computability interpretation of types L ω R L ω C L ω D : ρ ::= ν ρ ρ : κ ::= δ ω δ κ κ κ : δ ::= ρ ω ρ κ ρ δ δ A stack is a tuple L 1 :: :: L k for some k N. SN is the set of stacks of terms in SN. [[ω ρ]] = [[ρ]] = SN [[κ ρ]] = {M Trm L [[κ]]. M L [[ρ]]} [[δ ω]] = {N :: L N [[δ]], L SN } [[δ κ]] = {N :: L N [[δ]], L [[κ]]} [[σ τ]] = [[σ]] [[τ]] where L is a vector or a stack according to the context.
Types are saturated sets Properties of the computability interpretation of types: [[δ]] SN and [[κ]] SN for δ L ω D and κ L ω C M[N/x] L [[δ]] & N [[δ ]] (λx.m)n L [[δ]] (µα[α](m[α N]N)) L [[δ]] (µα[α]m)n L [[δ]] (µα[β](m[α N])) L [[δ]] & N [[δ ]] (µα[β]m)n L [[δ]] if α β σ τ [[σ]] [[τ]]
Typing judgements for commands are problematic Toward soundness, for ξ (Var Trm) + (Name Trm ) we set: M ξ = M [ξ(x 1 )/x 1,...,ξ(x h )/x h,[α 1 ξ(α 1 )],...,[α k ξ(α k )]] We expect that if ξ(x) [[Γ(x)]] and ξ(α) [[ (α)]] for all x dom(γ) and α dom( ) then: Γ M : δ M ξ [[δ]] How should we interpret a statement like [α]m : κ? Γ M : δ α : κ, ( ) Γ [α]m : δ κ α : κ, Γ Q : (κ ρ) κ α : κ, (µ) Γ µα.q : κ ρ
First solution: two derived rules We replace the rules: Γ M : δ α : κ, ( ) Γ [α]m : δ κ α : κ, Γ Q : (κ ρ) κ α : κ, (µ) Γ µα.q : κ ρ by the admissible rules: Γ M : κ ρ α : κ, (µ1 ) Γ µα.[α]m : κ ρ Γ M : κ ρ α : κ,β : κ, (µ2 ) Γ µα.[β]m : κ ρ β : κ,
First solution: the restricted system with (µ 1 ) and (µ 2 ) (Var) Γ,x : δ x : δ Γ,x : δ M : κ ρ ( I) Γ λx.m : δ κ ρ Γ M : κ ρ α : κ, (µ 1) Γ µα.[α]m : κ ρ Γ M : δ κ ρ Γ N : δ ( E) Γ MN : κ ρ Γ M : κ ρ α : κ, β : κ, (µ 2) Γ µα.[β]m : κ ρ β : κ, Γ M : δ Γ M : δ ( ) Γ M : δ δ Γ M : δ Γ M : δ δ δ ( ) where types are in L ω = L ω R L ω D L ω C and is restricted to L ω.
Second solution: distinct interpretation of judgments For ξ (Var Trm) + (Name Trm ) we set ξ = Γ, iff x dom(γ), α dom( ). ξ(x) [[Γ(x)]] & ξ(α) [[ (α)]] hence we define: Γ = M : δ ξ. ξ = Γ, M ξ [[δ]] Γ = [α]m : κ ξ. ξ = Γ, M ξ :: ξ(α) [[κ]] where N :: L is just the stack obtained by pushing N in front of L and recall that M ξ = M [ξ(x 1 )/x 1,...,ξ(x h )/x h,[α 1 ξ(α 1 )],...,[α k ξ(α k )]]
Second solution: the restricted system with ( ) and (µ) (Var) Γ,x : δ x : δ Γ,x : δ M : κ ρ ( I) Γ λx.m : δ κ ρ Γ M : δ α : κ, ( ) Γ [α]m : δ κ α : κ, Γ M : δ κ ρ Γ N : δ ( E) Γ MN : κ ρ Γ Q : (κ ρ) κ α : κ, (µ) Γ µα.q : κ ρ Γ M : δ Γ M : δ ( ) Γ M : δ δ Γ M : δ Γ M : δ δ δ ( ) where types are in L ω = L ω R L ω D L ω C and is restricted to L ω.
The characterisation theorem Theorem: soundness 1 Γ ω M : δ Γ = M : δ 2 Γ ω Q : κ Γ = Q : κ Therefore if Γ ω M : δ then M SN. Proof. By simultaneous induction on derivation. Finally take ξ 0 s.t. ξ 0 (x) = x and ξ 0 (α) = y. If Γ ω M : δ then: ξ 0 = Γ, so that M ξ0 [[δ]] SN M ξ0 SN M SN Theorem: completeness If M SN then Γ ω M : δ for some Γ,δ and. Proof. Similar to the proof for the λ-calculus.
Final remarks we have a type characterisation of SN-terms of λµ-calculus, that should extend smoothly to De Groote-Saurin variant, and also to Fellaisen s λc-calculus we plan to compare the present proof with Berger s semantic proof of strong normalisation for extended λ-calculi we think that intersection type machinery can be used to obtain elegant analysis of continuations as well as of other non functional aspects of extended λ-calculi, often studied by means of e.g. effect systems