• Nenhum resultado encontrado

Characterisation of Strongly Normalising lambda-mu-Terms

N/A
N/A
Protected

Academic year: 2017

Share "Characterisation of Strongly Normalising lambda-mu-Terms"

Copied!
17
0
0

Texto

(1)

S. Graham-Lengrand and L. Paolini (Eds.): Sixth Workshop on Intersection Types and Related Systems (ITRS 2012).

EPTCS 121, 2013, pp. 1–17, doi:10.4204/EPTCS.121.1 Steffen van Bakel

Imperial College London London, UK svb@doc.ic.ac.uk

Franco Barbanera Universit`a di Catania

Catania, Italy barba@dmi.unict.it

Ugo de’Liguoro Universit`a di Torino

Torino, Italy

deliguoro@di.unito.it

We provide a characterisation of strongly normalising terms of theλµ-calculus by means of a type system with intersection and product types. The presence of the latter and a restricted use of the type ωenable us to represent the particular notion of continuation used in the literature for the definition of semantics for theλµ-calculus. This makes it possible to lift the well-known characterisation property for strongly-normalisingλ-terms - that uses intersection types - to theλµ-calculus. From this result an alternative proof of strong normalisation for terms typeable in Parigot’s propositional logical system follows, by means of an interpretation of that system into ours.

Introduction

Parigot’s λµ-calculus [20] is an extension of the λ-calculus [11, 9] that was first introduced in [20] to express a notion of (confluent) computation with classical proofs in Gentzen’ssequent calculus LK. That calculus was introduced in [15] as a logical system in which the rules only introduce connectives (but on either side of a sequent), in contrast tonatural deduction (also introduced in [15]) which uses rules that introduce or eliminate connectives in the logical formulae. Natural deduction normally derives statements with a single conclusion, whereasLK allows for multiple conclusions, deriving sequents of the formA1, . . . ,AnB1, . . . ,Bm, where A1, . . . ,Anis to be understood as A1∧. . .∧Anand B1, . . . ,Bm

is to be understood asB1∨. . .∨Bm.

With λµ, Parigot created a multi-conclusion typing system that is, in fact, based on a mixture of Gentzen’s two approaches: the system is a natural deduction system that hasintroductionandelimination rules, but derivable statements have the shape ΓM:A|∆, where A is the main conclusion of the statement, expressed as theactiveconclusion. Here∆contains the alternative conclusions, consisting of pairs of Greek characters and types; the left-hand contextΓ, as usual, contains pairs of Roman characters and types, and represents the types of the free term variables ofM. This yields a logic withfocuswhere the main conclusion is the focus of the proof; derivable judgements correspond to provable statements in minimal classical logic [1]. In addition to the normal λ-calculus reduction rules, Parigot needed to express that the focus of the derivation (proof) changes; he therefore added structuralrules, where elimination takes place for a type constructor that appears in one of the alternative conclusions (the Greek variable is the name given to a subterm). This is achieved by extending the syntax with two new constructs[α]M andµα.M that act as witness todeactivationand activation, which together move the focus of the derivation. The collection of reduction rules Parigot defined are carefully engineered to yield a confluent reduction system; normally, systems based on classical logic are not confluent, as is the case for example for the Symmetricλ-calculus [8],λµµ˜ [14], andX [7].

(2)

to any proof, like fixed-point constructors for example. The basic idea here to turn non-constructive proofs into algorithms is to add a form of continuation by means ofnamesandµ-abstractionto capture (a notion of) control. However, continuations introduce a great deal of complexity to the calculus’ semantics and inspired by the results proven in [4] we decided to explore the possibility of definingfilter semantics for λµ. Starting from Streicher and Reus’ denotational semantics of λµin [25], in [6] we have introduced an intersection type assignment system that induces a filter model. This, essentially, is a logical description of the domain-theoretic model of [25], with the advantage of providing a formal tool to reason about the meaning of terms.

One of the main results for λµ, proved in [21], states that allλµ-terms that correspond to proofs of second-order natural deduction are strongly normalising; the reverse of this property does not hold for Parigot’s system, since there, for example, not all terms in normal form are typeable.

The full characterisation of strong normalisation (Mis strong normalising if and only ifMis typeable) is a property that is shown for various intersection systems for the λ-calculus, and towards the end of [6] we conjectured that in an appropriate subsystem we would be able to type exactly all strongly normalisingλµ-terms as well. The first to state the characterisation result was Pottinger [22] for a notion of type assignment similar to the intersection system of [12, 13], but extended in that it is also closed for η-reduction, and is defined without the type constant ω. However, to show that all typeable terms are strongly normalisable, [22] onlysuggestsa proof using Tait’s computability technique [26]. A detailed proof, using computability, in the context of theω-free BCD-system [10] is given in [2]; to establish the same result saturated sets are used by Krivine in [19] (chapter 4), in Ghilezan’s survey [16], and in [5].

The converse of that result, the property that all strongly normalisable terms are typeable has proven to be more elusive: it has been claimed in many papers but not shown in full (we mention [22, 2, 16]); in particular, the proof for the property that type assignment is closed for subject expansion (the converse of subject reduction) is dubious. Subject expansion can only reliably be shown forleft-most outermost reduction, which is used for the proofs in [19, 3, 5], and our result follows that approach as well.

In the full system of [6], all terms are typeable withωand this clearly interferes with the termination property. However, the problem we face is slightly more complex than straightforwardly removingω, as done in [2, 3]. In the model (for details, see [6]) acontinuation is an infinite tuple of terms, which is typed in the system by (a finite intersection of) typesκ=δ1× · · ·δk×ω for somek>0, where the leadingδ1, . . . ,δkencode the information about the firstkterms in the tuple, while the endingωrepresents

the lack of information about the remaining infinite part. This implies that, for our system for λµ, we cannot remove ω completely. To solve this problem, we first restrict types to those having ω only as the final part of a product type; we then suitably modify the standard interpretation of intersection types, adapting Tait’s argument in such a way that the semantics ofκ is the set of all finite tuples L (called stacks) of strongly normalising terms that begin withkterms L1. . . ,Lkthat belong to the interpretations

of, respectively, δ1, . . . ,δk. For this restricted system, we will show that typeability characterises strong normalisability forλµ-terms.

As a consequence of our characterisation result we also obtain an alternative proof of Parigot’s ter-mination result [21] (for the propositional fragment), by interpreting ordinary types into our intersection types and proving that the translation preserves derivability from Parigot’s system to ours.

Outline of this paper. In Section 1, we will briefly recall Parigot’s untypedλµ-calculus [20]. After

(3)

will be developed in Section 3, and we finish by giving concluding remarks.

1

The

λµ

-calculus

In this section we present Parigot’s pureλµ-calculus as introduced in [20], slightly changing the notation.

Definition 1.1 (Term Syntax [20]) 1. The setsTrmofterms andCmdofcommandsare defined

in-ductively by the following grammar (wherexVar, a set of term variables, andαName, a set of names, both denumerable):

M,N ::= x|λx.M|MN|µα.C (terms)

C ::= [α]M (commands)

2. We call LL1:· · ·:Lk a stack of terms; we denote the set of all finite (possibly empty) stacks of terms byTrm∗, and writeǫfor the empty stack. If M∈Trmand LL1:· · ·:Lk then M:LM:L1:· · ·:Lk∈Trm∗, while we define M(P:L) =

MPL, soMLML1· · ·Lk.

We will often speak of a stack rather than a stack of terms. For convenience of notation, for L =

L1:· · ·:Lk∈Trm∗, we introduce the notation:

M[αL] =∆ M[αL1][αL2]· · ·[αLn]

when eachLi does not containα. In particular, M[αǫ] = ∆

M. Notice that, by definition of structural substitution,

[α]M[αL] =∆ [α]M[αL1][αL2]· · ·[αLn] =

[α](M[αL])L

As usual, we consider λ andµto be binders; we adopt Barendregt’s convention on terms, and will assume that free and bound variables are different; the sets fv(M) and fn(M) of, respectively, free variablesandfree namesin a term Mare defined in the usual way.

Definition 1.2 (Substitution [20]) Substitution takes two forms:

term substitution: M[N/x] (Nis substituted forxinM, avoiding capture) structural substitution: T[αL] (every subterm[α]NofMis replaced by[α]NL)

whereM,N,L∈Trm,C∈CmdandT∈Trm∪Cmd. More precisely, T[αL]is defined by:

([α]M)[αL] =∆ [α](M[αL])L

([β]M)[αL] =∆ [β]M[αL] ifα6=β

(µβ.C)[αL] =∆ µβ.C[αL]

x[αL] =∆ x

(λx.M)[αL] =∆ λx.M[αL]

(MN)[αL] =∆ (M[αL])(N[αL])

Definition 1.3 (Reduction [20]) The reduction relationMN, where M,N∈Trm, is defined as the

compatible closure of the following rules:

(4)

2

Characterisation of Strong Normalisation

In this section we will show that we can characterise strong normalisation for pureλµ-terms completely through a notion of intersection typeing which employs product types and a restricted use of the typeω.

2.1 The type system

As mentioned in the introduction, our characterisation can be carried out by means of a precisely tailored version of the type system we presented in [6]. The types of our system will be formed by means of the

→,×, and∧type constructors over a single base typeν.1

Definition 2.1 (Types) The setsTDofterm typesandTCofcontinuation-stack typesare defined

induc-tively by the following grammar, whereνis a type constant:

TD: δ ::= ν|ων|κν|δδ

TC: κ ::= δ×ω|δ×κ|κκ

(we will call the typesδ×ωandδ×κalsoproduct types). We define the setT oftypesasT =TD∪ TC and letσ,τ,ρ, etc. range overT.

Notice that an important feature of our system is the absence ofωas a proper type (and, consequently, the absence of its corresponding typeing rule); notice that we have not removedω completely, since it always occurs at the very end of any product type in order to represent the (unspecified) last part of a continuation stack.

Definition 2.2 The relationsD andC are the least pre-orders over TD and TC, respectively, such

that:

στ στ νν ων δδωω

(δω)∧(δκ)≤C(δ1∧δ2)×κ

(κ1,κ26≡ω) (δκ1)∧(δκ2)≤C(δ1∧δ2)×(κ1∧κ2)

δ1≤2 δωω

δ1≤2 κ1≤2 δκ1≤κ2

σ1 σ2 σ1∧τ2

κ2≤1 κ1→ν2→ν

whereAis eitherDorC. As usual, we define=A= ∆

A∩ ≥A.

For convenience of notation, in the following the subscriptsDandCon≤are normally omitted.

The pre-orders in Definition 2.2 are a restriction toT of the pre-orders defined in [6]. We point out that, in the system defined in that paper, the inequalityδδωδωis derivable. In fact, in [6] we had ω=×ωand henceδδωδω×ω=δω. In the present system, instead,ω6∈ TDso that δω×ω6∈ TC, and therefore this inequality has to be explicitly postulated above.

The notions ofbasis (variable context), denoted byΓ,Γ′, . . . , andname context, denoted by,∆′, . . . , are defined in the standard way as, respectively, mappings of a finite set of term variables to types in TD, and of a finite set of names to types in TC, represented for convenience as sets of statements on variables and names (we call these assumptions). Below we shall writeΓ,x:δfor Γ∪ {x:δ}where x6∈dom); similarly forα:κ,∆(note that the order in which variable and name assumptions are listed in the rules is immaterial).

(5)

Definition 2.3 (Typeing System) 1. Ajudgementin our system has the form ΓM:δ|∆, whereΓ is a basis,M∈Trm∈ TDandis a name context.

2. We definetypeingfor pureλµ-terms (inTrm) through the following natural deduction system:

(ax): Γ,x:δx:δ| (µ): Γ⊢M:κ

ν|α:κ,

Γµα.[β]M:κν|β:κ′,∆

ΓM:κν|α:κ,∆ Γµα.[α]M:κν|∆

(abs): Γ,x:δM:κν|∆

Γλx.M:δ×κν|∆ (app):

ΓM:δ×κν|∆ ΓN:δ|∆ ΓMN:κν|∆

(≤): Γ⊢M:δ|∆ (δδ′)

ΓM:δ′|∆ (∧):

ΓM:δ|∆ ΓM:δ′|∆ ΓM:δδ′|∆

whereκin rules(abs)and(app)2is either a type inT Corω.

3. We write ΓM:δ|∆ whenever there exists a derivation built using the above rules that has this judgement in the bottom line, and D::ΓM:δ|∆ when we want to name that derivation. We writeM:δ|∆ when the variable context is empty, and ΓM:δ| when the name context is.

Note that we use a single name, (µ), for the two rules concerning µ-abstraction; which is the one actually used will always be clear from the context.

We extend Barendregt’s convention to judgements ΓM:δ|∆ by seeing the variables that occur in Γand names inas binding occurrences over Mas well; in particular, we can assume that no variable inΓand no name inis bound inM.

Definition 2.4 1. The relationis naturally extended to bases as follows:

Γ′Γ iff x:δ∈Γ⇒ ∃x:δ′∈Γ′[δδ].

Therelation on name contexts is defined in the same way.

2. Given two basesΓ1andΓ2, we define the basisΓ1Γ2as follows:

Γ1Γ2 ={x:δ1∧δ2|x:δ1∈Γ1&x:δ2∈Γ2} ∪

{x:δ|x:δ∈Γ1&x6∈dom2)} ∪

{x:δ|x:δ∈Γ2&x6∈dom1)}

3. The name context12is constructed out of1and2in a similar way.

Trivially, dom1Γ2) =dom(Γ1)dom(Γ2)and dom(12) =dom(1)dom(2). More-over, it is straightforward to show that:

Proposition 2.5 Γ1Γ2Γiand12ifori=1, 2.

We can also show thatWeakeningandStrengtheningrules are implied by the system:

2We use(app)and(abs)to name the rules concerningλ-abstraction and application, rather than the more usual(→I)and

(6)

Lemma 2.6 (Weakening and Strengthening) The following rules are admissible3:

(W): Γ⊢M:δ|∆ (Γ′Γ,∆′)

Γ′M:δ|∆′

(S): Γ⊢M:δ|∆ (Γ′={x:δ∈Γ|xfv(M)},∆′={α:κ∈∆|αfn(M)})

Γ′M:δ|∆′

The above lemma and Proposition 2.5 lead immediately to the following:

Corollary 2.7 If Γ1M:δ|∆1 then for anyΓ2,2: Γ1Γ2M:δ|∆12.

Notice that, by Barendregt’s convention, the variables inΓ2and names in2are not bound inM. The following substitution results can be proved along the lines of similar ones in [6]:

Lemma 2.8 (Substitution Lemma) 1. ΓM[N/x]:δ|∆ withxfv(M), if and only if there

ex-istsδsuch that ΓN:δ′|∆ and Γ,x:δ′⊢M:δ|∆.

2. ΓM[αL]:δ|α:κ,∆ withαfn(M), if and only if there existsδsuch thatΓL:δ′|∆, and ΓM:δ|α:δ′×κ,∆.

2.2 Typeability implies Strong Normalisation

In this subsection we will show that – as can be expected of a well-defined notion of type assignment that does not type recursion and has no general rule that types all terms – all typeable terms are strongly normalising. Such a property does not hold for the system in [6] where, in fact, by means of types not al-lowed in the present system, it is possible to type the fixed-point constructorλf.(λx.f(xx))(λx.f(xx))

in a non-trivial way, as shown by the following derivation:

(ax)

f:ω×ων,x:ωf:ω×ων| f:ω×ων,x:ωxx:ω| (ω) (app) f:ω×ων,x:ωf(xx):ων|

(abs)

f:ω×ωνλx.f(xx):ω×ων| f:ω×ωνλx.f(xx):ω| (ω) (app) f:ω×ων⊢(λx.f(xx))(λx.f(xx)):ων|

(abs) ⊢λf.(λx.f(xx))(λx.f(xx)):(ω×ωνων|

Notice that this term does not have a normal form, so is not strongly normalisable.

Definition 2.9 The setSN of strongly normalisableterms is defined as usual as the set of all termsM

such that no infinite reduction sequence out ofMexists; we useSN(M)forM∈ SN, andSN∗for the

set of finite stacks of terms inSN.

The following is straightforward:

3We should perhaps point out that Barendregt’s convention, extended to judgements as we do here, is essential for the correctness of this result. By writing Γ′M:δ|∆′, we assume that Γ′ and ∆′ do not contain statements for variables

and names that occur bound in M, so we do not allow contexts to be weakened by statements concerning bound names or variables. As a counter example, take ⊢µα.[α]λx.x:(κν)→κν| and Γ2=x:δ,2 =α:κ; we cannot derive

x:δµα.[α]λx.x:(κν)→κν|α:κ.

This is also the case for systems for theλ-calculus; in past papers it has been claimed that, ifΓ1

λM:AandΓ2⊢λN:B

(without any restrictions), then alsoΓ1Γ2M:AandΓ1Γ2N:B. This is incorrect for the same reason: take ⊢λλy.y:

(7)

Proposition 2.10 1. IfSN(xM)andSN(N), thenSN(xMN).

2. IfSN(M[N/x]P)andSN(N), thenSN((λx.M)NP).

3. IfSN(M), thenSN(µα.[β]M).

4. IfSN(µα.[β]M[αN]L)andSN(N), thenSN((µα.[β]M)N L).

5. IfSN(µα.[α]M[αN]N L), thenSN((µα.[α]M)N L).

Definition 2.11 (Type Interpretation) 1. We define a map

k · k: (TD →℘(Trm)) + (TC→℘(Trm∗))

(whererepresents the powerset constructor) interpreting term types and continuation-stack types as, respectively, sets of terms and sets of stacks, as follows:

kνk = kωνk = SN

kκνk = {M∈Trm| ∀L∈ kκk[ML∈ kνk]} kδ×ωk = {N:L|N∈ kδk,L∈ SN∗}

kδ×κk = {N:L|N∈ kδk,L∈ kκk} kστk = kσk ∩ kτk

2. We define thelengthof a stack type,| · |:TC→N, as follows:

|δ×ω| = 1

|δ×κ| = 1+|κ| |κ1∧κ2| = max|κ1| |κ2|

By this interpretation, the elements of kδ1× · · · ×δn×ωkare stacks of strongly normalisable terms that have an arbitrary length greater than or equal ton. It is easy to check that|κ|returns the minimal length of the stacks inkκk.

We can show:

Lemma 2.12 For anyδ∈ TD andκ∈ TC:

1. kδk ⊆ SN andkκk ⊆ SN∗.

2. xN∈ SN ⇒xN∈ kδk.

3. x =x1: . . . :xn∈ kκk, for allnsuch thatn≥ |κ|.

Proof. By simultaneous induction on the structure of types, using Definition 2.11. We show some of the cases.

1. (κν): M∈ kκνk ⇒(IH(2))

x ∈ kκk&M∈ kκνk ⇒(2.11)

M x ∈ kνk ⇒(2.11)

M x ∈ SN ⇒M∈ SN.

(δ×ω): M∈ kδ×ωk ⇒(2.11))

M=N:L&N∈ kδk&L∈ SN ⇒(IH(1))

(8)

(δ×κ): M∈ kδ×κk ⇒(2.11))

M=N:L&N∈ kδk&L∈ kκk ⇒(IH(1))

N∈ SN &L∈ SN∗ N:L∈ SN.

2. (κν): xN∈ SN ⇒(2.11 &IH(1))

L∈ kκk ⇒xN∈ SN &L∈ SN∗ ⇒(2.10)

L∈ kκk ⇒xN L∈ SN ⇒(IH(2))

L∈ kκk ⇒xN L∈ kνk ⇒(2.11) xN∈ kκνk.

3. (δ×ω): x =x:x′ ⇒(IH(2))

x∈ kδk&x′∈ SN∗ (2.11) x ∈ kδ×ωk.

(δ×κ): x =x:x′ ⇒(IH(2)&IH(3))

x∈ kδk& x′∈ kκk ⇒(2.11) x ∈ kδ×κk.

The following result follows immediately from Lemma 2.12 (2):

Corollary 2.13 For anyxVar and anyδ∈ TD: x∈ kδk.

The following lemma shows that our type interpretation is closed under the type inclusion relation.

Lemma 2.14 For allσ,τ∈ T: ifστ, thenkσk ⊆ kτk.

Proof. By induction on the definition of≤. We show some of relevant cases.

(δω)∧(δκ)≤(δ1∧δ2)×κ): k(δω)∧(δκ)k =

{M:L|M∈ kδ1k,L∈ SN∗} ∩ {M:L|M∈ kδ2k,L∈ kκk} = (kκk ⊆ SN∗by 2.12 (1))

{M:L|M∈ kδ1k ∩ kδ2k,L∈ kκk} =

{M:L|M∈ kδ1∧δ2k,L∈ kκk} =

k(δ1∧δ2)×κk

.

(κ2≤κ1⇒κ1→νκ2→ν): kκ1→νk =

{M∈Trm| ∀L∈ kκ1k[ML∈ SN]} ⊆ (kκ2k ⊆ kκ1kby induction)

{M∈Trm| ∀L∈ kκ2k[ML∈ SN]} =

kκ2→νk

Our type interpretation is closed under expansion for the logical and for the structural reduction, with the proviso that the term or stack to be substituted is an element of an interpreted type as well.

Lemma 2.15 For anyδ,δ′∈ TD andκ∈ TC:

1. If M[N/x]P∈ kδkandN∈ kδ′k, then(λx.M)NP∈ kδk.

2. Ifµα.[β]M[αN]P∈ kδkandN∈ kκk, then(µα.[β]M)N P∈ kδk.

3. Ifµα.[α]M[αN]NP∈ kδk, then(µα.[α]M)NP∈ kδk.

Proof. By induction on the structure of types, using 2.10, 2.11 and 2.12.

(9)

Definition 2.16 1. A partial mappingξ :(Var→Trm) + (Name→Trm∗)is aparallel substitution if, for everyp,q∈dom(ξ), ifp6=qthenp6∈fv(ξq)andp6∈fn(ξq).

2. Borrowing a notation for valuations, for a parallel substitutionξ we define the application ofξto a term by:

([α]M)ξ =

[α]MξL ifξα=L

([β]M)ξ =

[β] ifβ6∈dom(ξ)

(µβ.Q)ξ =

µβ.

=

N ifξx=N

=

y ify6∈dom(ξ)

(λx.M)ξ =λx.Mξ

(MN)ξ =

MξNξ

3. We defineξ[N/x]andξ[αL]by, respectively,

ξ[N/x]y =∆

N ify=x

ξy otherwise

ξ[αL]β =∆

L ifα=β

ξ β otherwise

4. We will say thatξextendsΓand, if, for allx:δ∈Γandα:κ∈∆, we have, respectively,ξ(x)

kδkandξ(α)∈ kκk.

Notice that we do allow a variable to appear in its own image under ξ. Since xdoes not appear in M[N/x], this does not violate Barendregt’s convention.

Lemma 2.17 (Replacement Lemma) Letξ be a parallel substitution that extendsΓand. Then:

if ΓM:δ|∆ then ∈ kδk.

Proof. By induction on the structure of derivations. We show some more illustrative cases.

(abs): ThenM=λx.M′,δ=δ′×κν, andΓ,x:δ′⊢M′:κν|∆. TakeN∈ kδk; sincexis bound, by Barendregt’s convention we can assume that it does not occur free in the image ofξ, soξ[N/x]

is a well-defined parallel substitution that extends Γ,x:δ′ and ∆. Then by induction, we have Mξ[N/x] ∈ kκνk. Since x does not occur free in the image of ξ, Mξ[N/x] = Mξ[N/x], so also Mξ[N/x]∈ kκνk. By Lemma 2.15 (1), also (λx.Mξ)N∈ kκνk. By definition of

kκνk, for anyL∈ kκkwe have(λx.Mξ)NL∈ kνk; notice thatN:L∈ kδ×κk, so(λx.M′)ξ∈ kδ′×κνk.

(µ): ThenM=µα.[β]M′, andδ=κν. We distinguish two different sub-cases.

α=β: ThenM=µα.[α]M′,δ=κν, and ΓM′:κν|α:κ,∆. TakeL∈ kκk; sinceαis bound in M, we can assume it does not occur free in the image of ξ, so ξ[αL] is a well-defined parallel substitution that extends Γ and ∆,α:κ, and by induction, Mξ[αL] ∈ kκνk. Since α does not occur free in the image of ξ, Mξ[αL] = Mξ[αL], so we have Mξ[αL]∈

(10)

α6=β: Then∆=β:κ′,∆′, and ΓM′:κ′→ν|α:κ,β:κ′,∆. AssumeL∈ kκk, thenξ[αL]extends Γandα:κ,β:κ′,∆′. Then, by induction,M

ξ[αL]∈ kκ′→νk. Now letQ∈ kκ′k, thenMξ[αL]Q∈ kνkand then also(MQ)ξ[αL]∈ kνk.

ThenSN((MQ)ξ[αL])by Definition 2.11, andSN(µα.[β](MQ)ξ[αL])by Lemma 2.10 (3),

so, again by Definition 2.11,µα.[β](MQ)ξ[αL]∈ kνk. As in the previous part,αis not free in the image ofξ, and therefore alsoµα.[β](MQ)ξ[αL]∈ kνk.

Then, by Lemma 2.15 (2),(µα.[β](MQ)ξ)L∈ kνk. Notice that[β]MξQ= [β]Mξ[βQ]; since ξβ=Q, we can infer that[β]MξQ= [β]Mξ, so (µα.[β]M′)ξL∈ kνk. But then(µα.[β]M′)ξ

kκνk.

We now come to the main result of this section, that states that all terms typeable in our system are strongly normalisable.

Theorem 2.18 (Typeable terms areSN) If ΓM:δ|∆for someΓ,andδ, thenM∈ SN.

Proof. Letξbe a parallel substitution such that

ξ(x) = x forxdom) ξ(α) = yα forαdom(∆)

where the length of the stack yα is |κ| ifα:κ∈∆ (notice that ξ is well defined). By Lemma 2.12, ξ extendsΓand. Hence, by Lemma 2.17, Mξ∈ kδk, and thenMξ∈ SN by Lemma 2.12 (1). Now

M[x1/x1, . . . ,xn/xn,α1⇐yα1, . . . ,αmyαm]

M[α1⇐yα1, . . . ,αmyαm]

Then, by Proposition 2.10, for any β also (µα1.[β1]· · ·µαm.[βm]M)yα1· · ·yαm∈ SN, and therefore

alsoM∈ SN .

2.3 Strongly Normalising Terms are Typeable

In this section we will show the counterpart of the previous result, namely that all strongly normalisable terms are typeable in our intersection system. This result has been claimed in many papers [22, 2], but has rarely been proven completely.

First we describe the shape of the terms in normal form.

Definition 2.19 (Normal Forms) The setN ⊆Trmof normal formsis defined by the grammar:

N ::= xN1· · ·Nk|λx.N|µα.[β]N

It is straightforward to verify that the terms inN are precisely the irreducible ones.

We can show that all terms inN are typeable.

Lemma 2.20 IfN∈ N then there existΓ,, and a typeκνsuch that ΓN:κν|∆.

(11)

(NxN1. . .Nk): SinceN1, . . . ,Nk∈ N, by induction we have that, for allikthere existΓi,∆iand δi such thatΓiNi:δi |∆i(the structure of eachδiplays no role in this part). Take

Γ=Γ1∧ · · · ∧Γkx:(δ1× · · · ×δk×δ×ω)→ν, and∆=∆1∧ · · · ∧∆k.

where δ is any element of TD. Then, by Lemma 2.6, Γ⊢ Ni:δi|∆ for all in, and Γ⊢ x:(δ1× · · · ×δk×δ×ω)→ν|∆. By repeated application of(app)we getΓ⊢xN1· · ·Nk:κν|∆

forκ=δ×ω.

(Nµα.[β]N′): By induction, ΓN′:κν|∆. We distinguish two cases:

(αβ): In caseαfn(N′)and∆=α:κ′,∆′, we can construct:

ΓN′:κν|α:κ′,∆′

(W)

ΓN′:κν|α:κκ′,∆′

(≤)

ΓN′:κκ′→ν|α:κκ′,∆′

(µ)

Γµα.[α]N′:κκ′→ν|∆′

In caseα6∈fn(N′), we can construct

ΓN′:κν|∆

(W)

ΓN′:κν|α:κ,∆′

(µ)

Γµα.[α]N′:κν|∆′

(α6≡β): We can proceed as in the previous case, obtaining now ΓN:κν|α:κ′,β:κ,∆′. So by rule(µ)we get Γµα.[β]N′:κ′→ν|β:κ′′,∆′.

We will now show that typeing is closed under expansion with respect to both logical and structural reduction, with the proviso that the term (stack) that gets substituted is typeable as well in the same contexts.

Lemma 2.21 (Contractum Expansion) 1. If ΓM[N/x]:δ|∆ and ΓN:δ′ |∆then

Γ(λx.M)N:δ|∆.

2. If Γµα.[β]M[αN]:δ|∆and ΓN:δ′|∆ then Γ(µα.[β]M)N:δ|∆.

Proof. 1. Much the same as the similar result for the intersection systems for theλ-calculus.

2. We need to consider two different cases:

(α6∈fn([β]M)): Then ([β]M)[αN]≡ [β]M and α6≡ β. We consider all the n minimal sub-derivations (n≥1) havingµα.[β]M as subject, from which conclusions we derive Γ µα.[β]M[αN]:δ|∆by applying any number of()and()rules.

The last step in each of these derivations is of the shape:

ΓM:κν|α:κi,β:κ,∆′

(µ)

(12)

where∆=β:κ,∆′. Sinceα6∈fn([β]M), by strengthening (Lemma 2.6) we can removeα:κi from the name context, so also ΓM:κν|β:κ,∆′; then, by weakening (Lemma 2.6), we can addα:δ′×κi,, soΓ⊢M:κν|α:δ′×κi,β:κ,∆′, and then we can construct

ΓM:κν|α:δ′×κi,β:κ,∆′

(µ)

Γµα.[β]M:δ′×κiν|β:κ,∆′ Γ⊢N:δ′|∆

(app)

Γ(µα.[β]M)N:κiν|∆

from which it is possible to derive Γ(µα.[β]M)N:δ|∆ by applying the same ()and

(∧)rules mentioned above.

(αfn([β]M)): We distinguish two further cases:

(α=β): Then([β]M)[αN]≡([α]M)[αN]≡[α](M[αN])N; we can assume, with-out loss of generality, thatδ= (κ1→ν)∧ · · · ∧(κnν), and that for allinthere are sub-derivations constructed like

ΓM[αN]:δi×κiν|α:κi,∆ Γ⊢N:δi|∆

(app)

Γ(M[αN])N:κiν|α:κi,∆

(µ)

Γµα.[α](M[αN])N:κiν|∆

Then there existsδi′ such that ΓN:δi′|∆, and ΓM:δi×κiν|α:δi′×κi,∆ by Lemma 2.8 (2); so we can build the derivation:

ΓM:δi×κiν|α:δi′×κi,∆

(≤)

ΓM:δiδi′×κiν|α:δi′×κi,∆

(W)

ΓM:δiδi′×κiν|α:δiδi′×κi,∆

(µ)

Γµα.[α]M:δiδi′×κiν|∆

ΓN:δi|∆ Γ⊢N:δi′|∆ (∧)

ΓN:δiδi′|∆

(app)

Γ(µα.[α]M)N:κiν|∆

We derive Γ(µα.[α]M)N:δ|∆by rule().

(α6=β): Then([β]M)[αN]≡[β](M[αN]); as aboveδ= (κ1→ν)∧ · · · ∧(κnν), and for allinthere are derivations structured like:

ΓM[αN]:κiν|α:κi,β:κi′,∆′

(µ)

Γµα.[β](M[αN]):κiν|β:κi,∆′

where∆=β:κi,∆′. As above, by Lemma 2.8 (2) there existsδisuch that both ΓN:δi|β:κi,∆′ and Γ⊢M:κiν|α:δi×κi,β:κi,∆′. We can then construct:

ΓM:κiν|α:δi×κi,β:κi,∆′ (µ)

Γµα.[β]M:δi×κiν|∆ Γ⊢N:δi|∆

(app)

(13)

As above, we conclude thatΓ(µα.[β]M)N:δ|∆by rule().

We will now show that all strongly normalisable terms are typeable in our system. The proof of the crucial lemma for this result as presented below (Lemma 2.23) goes by induction on the left-most outer-most reduction path.

Definition 2.22 An occurrence of a redexR= (λx.P)Qor(µα.[β]P)Qin a termMis called the left-most outer-left-most redex ofM(lor(M)), if and only if:

1. there is no redexR′inMsuch thatR′=C[R](outer-most);

2. there is no redexR′inMsuch thatM=C0[C1[R′]C2[R]](left-most).

MlorNis used to indicate that Mreduces toNby contractinglor(M).

The following lemma formulates a subject expansion result for our system with respect to left-most outer-most reduction. A proof for this property in the context of strict intersection type assignment for theλ-calculus appeared in [3, 5].

Lemma 2.23 Let Mlor N, lor(M) =RQ, Γ1⊢N:δ1|∆1 with δ1 not an intersection, and Γ2⊢

Q:δ2|∆2, then there existΓ3,∆3andδ3such thatΓ3≤Γ1,∆3≤∆11≤δ3, and Γ3⊢M:δ3|∆3.

Proof. By induction on the structure of terms.

M=VP1· · ·Pn: Then either:

1. Vis a redex(λy.P)Q, solor(M) =V; letV′≡P[Q/y]; or

2. Vis a redex(µα.[β]P)Q, solor(M) =V; letV′≡µα.[β]P[αQ]; or

3. Vzand there is aninsuch thatlor(M) =lor(Pj),NzP1· · ·Pi′· · ·Pn, andPilorPi′;

letV′=z.

By assumptionδ1=κ1→ν. Then there areδj(jn), such thatΓ1⊢V′:δ1′× · · · ×δn′×κ1→ν|∆1

and Γ1Pi:δi′|∆1, for allin. We distinguish:

1. V′≡P[Q/y], where the substitution is capture avoiding, so all free variables in Qare free inP[Q/y]whenyfv(P), and we can assume thatΓ2and2do not have types for bound variables and names in P. Let Γ3=Γ1Γ2 and3=12, then by Corollay 2.7 and Lemma 2.21,Γ3(λy.P)Q:δ1′× · · · ×δn′×κ1→ν|∆3.

2. V′≡µα.[β]P[αQ]; we can assume thatΓ2and2do not have types for bound variables and names inµα.[β]P. LetΓ3=Γ1Γ2and3=12, then by Corollay 2.7 and Lemma 2.21,Γ3(µα.[β]P)Q:δ1× · · · ×δn×κ1→ν|∆3.

3. V′≡z. Then, by induction, there areΓ′,∆′,δ′′

j such thatδj′′≤δj′, andΓ′⊢Pj:ψj |∆′. Take Γ3=Γ1Γ′,z:δ1′× · · · ×δ′′j× · · · ×δn×κ1ν, and∆3=1∆′, then

Γ3z:δ1′× · · · ×δj′′× · · · ×δn′×κ1′→ν|∆3.

In all cases,Γ3Γ1,31, and Γ3VP1· · ·Pn:δ|∆3.

M=λy.M′: If Mlor N, then N= λy.N′ and M′ →lor N′. Then there exists δ and κ such that

δ1=δ×κν, and Γ1,y:δN′:κν|∆1. By induction, there existsΓ′≤Γ1,∆′ ≤∆1,δ′ ≤δ,

(14)

M=µα.[β]M′: IfMlor N, thenN=µα.[β]N′ and M′→lor N′. Then there existsκ1and κ2such

that δ1=κ1→ν, ∆1=α:κ2,∆′1 and Γ1⊢N′:κ2→ν|β:κ1,∆′1. By induction, there exists Γ′ ≤ Γ1, ∆′ 1, κκ1 and κ′′κ2 such that Γ′M′:κ′′→ν|α:κ′,∆′. Then, by rule(µ), Γ′ µα.[β]M′:κ′→ν|β:κ′′,∆′. Notice that κ1νκν, and β:κ′′,∆′ β:κ2,∆′1; take Γ3=Γ′, ∆3=β:κ′′,∆′, andδ3=κν.

M=µα.[α]M′ : If Mlor N, then N= µα.[α]N′ and M′ →lor N′. Then there exists κ such that

δ1=κν,∆1=α:κ,∆′1andΓ1⊢N′:κν|α:κ,∆′1. By induction, there existsΓ′≤Γ1,∆′≤∆1,

andκ1≤κ,κ2≤κsuch thatΓ′⊢M′:κ2→ν|α:κ1,∆′. Takeκ′ =κ1∧κ2, then by weakening and

rule (≤), also Γ′ M′:κ′→ν|α:κ′,∆′. Then, by rule (µ), Γ′µα.[α]M′:κ′→ν|∆′. Notice thatκνκ′→ν; takeΓ3=Γ′,3=∆′, andδ3=κν.

We can now show that all strongly normalisable terms are typeable in our system.

Theorem 2.24 (Typeability ofSN-Terms) For allM∈ SN there existΓandand a typeδsuch that

ΓM:δ|∆.

Proof. By induction on the maximum of the lengths of reduction sequences for a strongly normalisable term to its normal form (denoted by#(M)).

1. If #(M) =0, then Mis in normal form, and by Lemma 2.20, there exist Γ andδ such that Γ M:δ|∆.

2. If#(M)≥1, soMcontains a redex, then letMlorNby contracting PQ. Then#(N)<#(M),

and#(Q)<#(M)(sinceQis a proper subterm of a redex in M), so by induction ΓN:δ1|∆

and Γ′ Q:δ2|∆, for some Γ,Γ′, δ1, andδ2. Then, by Lemma 2.23, there existΓ1, ∆1 and δ

such that Γ1M:δ′|∆1.

In the following section we will prove strong normalisation for terms typeable in the propositional fragment of Parigot’s logical system [20] via an interpretation in our system.

3

Interpretation of Parigot’s Logical System

We use a version of Parigot’s logical system (as presented in [20] which is equivalent to the original one if only terms (so not also proper commands, i.e. elements ofCmd) are typed. This implies that the rule for⊥does not need to be taken into account.4 We call this propositional fragment of Parigot’s original system thesimply-typedλµ-calculus.

Definition 3.1 (Simply Typedλµ-calculus) 1. The setLFofLogical Formulasis defined by

A,B::=ϕ|AB

whereϕranges over an infinite set of Proposition (Type) Variables.

2. The inference rules of this system are:

(ax): Γ,x:Ax:A| (µ1):

ΓM:A|α:A,∆

Γµα.[α]M:A|∆ (µ2):

ΓM:B|α:A,β:B,∆ Γµα[β]M:A|β:B,∆

(15)

(→I): Γ,x:AM:B|∆

Γλx.M:AB|∆ (→E):

ΓM:AB|∆ ΓN:A|∆ ΓMN:B|∆

We writeΓPM:A|∆to denote that this judgement is derivable in this system.

We can interpret formulas into types of our system as follows.

Definition 3.2 The translation functions(·)D :LF→T

Dand (·)C:LF→TC are defined by (remember thatνis the (only) base type):

ϕC = ν×ω

(AB)C = (ACν)×BC

AD = ACν

For example,(ϕ1→ϕ2→ϕ3)C= (ν×ων)×(ν×ων)×(ν×ων).

It is straightforward to show that the above translations are well defined. We extend them to bases and name contexts as follows:ΓD={x:AD|x:AΓ}andC={α:AC|α:A}.

Theorem 3.3 (Derivability preservation) IfΓPM:A|∆, then ΓDM:AD|∆C.

Proof. By induction on the structure of derivations. Each rule of the simply-typed λµ-calculus has a corresponding one in our intersection type system (allowing for the fact that rule (→I)gets mapped unto(abs)and (→E)gets mapped unto(app)); hence it suffices to show that rules are preserved when translating formulas into types. We show just the cases for theµ-abstraction.

ΓDM:AD|α:AC,∆C

(µ1)

ΓDµα.[α]M:AD|∆C

becomes ΓDM:ACν|α:AC,∆C

(µ)

ΓDµα.[α]M:ACν|∆C

ΓDM:BD|α:AC,β:BC,∆C

(µ2)

ΓDµα.[β]M:AD|β:BC,∆C

becomes ΓDM:BCν|α:AC,β:BC,∆C

(µ)

ΓDµα.[β]M:ACν|β:BC,∆C

notice that the applications of rule(µ)are valid instances of that rule.

Strong normalisation of typeable terms in Parigot’s simply typedλµ-calculus now follows as a con-sequence of our characterisation result.

Theorem 3.4 (Strong Normalisability of Parigot’s Simply Typedλµ-calculus) IfΓPM:A|∆, then

M∈ SN.

Proof. By Theorem 3.3, if ΓP M:A|∆ then ΓD M:AD|∆C is derivable in the intersection type system. HenceM∈ SN by Theorem 2.18.

Conclusion

We have defined an intersection type system which characterises strongly normalisingλµ-terms, extend-ing the strong normalisation result for theλ-calculus to the pureλµ-calculus.

(16)

As we have observed in [6], our intersection-type assignment system can be adapted to de Groote’s variant of the λµ-calculus (see e.g. [17]) (called Λµby Saurin [23]), that satisfies stronger properties than Parigot’s original calculus, such as B ¨ohm’s theorem. We leave the question whether the present characterisation result extends to those cases to future work.

Acknowledgements The authors wish to thank Mariangiola Dezani-Ciancaglini for her unceasing

sup-port.

References

[1] Z.M. Ariola & H. Herbelin (2003):Minimal Classical Logic and Control Operators. In J.C.M. Baeten, J.K. Lenstra, J. Parrow & G.J. Woeginger, editors:Proceedings of Automata, Languages and Programming, 30th International Colloquium, ICALP 2003, Eindhoven, The Netherlands, June 30 - July 4, 2003,Lecture Notes in Computer Science2719, Springer Verlag, pp. 871–885, doi:10.1007/3-540-45061-0_68.

[2] S. van Bakel (1992):Complete restrictions of the Intersection Type Discipline.Theoretical Computer Science 102(1), pp. 135–163, doi:10.1016/0304-3975(92)90297-S.

[3] S. van Bakel (2004):Cut-Elimination in the Strict Intersection Type Assignment System is Strongly Normal-ising.Notre Dame journal of Formal Logic45(1), pp. 35–63, doi:10.1305/ndjfl/1094155278. [4] S. van Bakel (2010):Sound and Complete Typing forλµ. In:Proceedings of 5th International Workshop

In-tersection Types and Related Systems(ITRS’10), Edinburgh, Scotland,Electronic Proceedings in Theoretical Computer Science45, pp. 31–44, doi:10.4204/EPTCS.45.3.

[5] S. van Bakel (2011): Strict intersection types for the Lambda Calculus. ACM Computing Surveys43, pp. 20:1–20:49, doi:10.1145/1922649.1922657.

[6] S. van Bakel, F. Barbanera & U. de’Liguoro (2011):A Filter Model forλµ. In L. Ong, editor:Proceedings of10th International Conference on Typed Lambda Calculi and Applications(TLCA’11),Lecture Notes in Computer Science6690, Springer Verlag, pp. 213–228, doi:10.1007/978-3-642-21691-6_18. [7] S. van Bakel & P. Lescanne (2008): Computation with Classical Sequents. Mathematical Structures in

Computer Science18, pp. 555–609, doi:10.1017/S0960129508006762.

[8] F. Barbanera & S. Berardi (1996): A Symmetric Lambda Calculus for Classical Program Extraction. Infor-mation and Computation125(2), pp. 103–117, doi:10.1006/inco.1996.0025.

[9] H. Barendregt (1984): The Lambda Calculus: its Syntax and Semantics, revised edition. North-Holland, Amsterdam.

[10] H. Barendregt, M. Coppo & M. Dezani-Ciancaglini (1983):A filter lambda model and the completeness of type assignment.Journal of Symbolic Logic48(4), pp. 931–940, doi:10.2307/2273659.

[11] A. Church (1936):A Note on the Entscheidungsproblem.Journal of Symbolic Logic1(1), pp. 40–41, doi:10.

2307/2269326.

[12] M. Coppo & M. Dezani-Ciancaglini (1978):A New Type Assignment forλ-Terms.Archiv f¨ur Mathematische Logic und Grundlagen Forschung19, pp. 139–156, doi:10.1007/BF02011875.

[13] M. Coppo, M. Dezani-Ciancaglini & B. Venneri (1980): Principal type schemes andλ-calculus semantics. In J.R. Hindley & J.P. Seldin, editors: To H.B. Curry, Essays in combinatory logic, lambda-calculus and formalism, Academic press, New York, pp. 535–560.

[14] P.-L. Curien & H. Herbelin (2000):The Duality of Computation. In:Proceedings of the 5th ACM SIGPLAN International Conference on Functional Programming (ICFP’00), ACM Sigplan Notices35.9, ACM, pp. 233–243, doi:10.1145/351240.351262.

(17)

[16] S. Ghilezan (1996): Strong Normalization and Typability with Intersection Types. Notre Dame journal of Formal Logic37(1), pp. 44–52, doi:10.1305/ndjfl/1040067315.

[17] Ph. de Groote (1994): On the Relation between theλµ-Calculus and the Syntactic Theory of Sequential Control. In:Proceedings of 5th International Conference on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR’94),Lecture Notes in Computer Science822, Springer Verlag, pp. 31–43, doi:10.

1007/3-540-58216-9_27.

[18] H. Herbelin & A. Saurin (2010):λµ-calculus andλµ-calculus: a Capital Difference. Manuscript. [19] J.-L Krivine (1993):Lambda calculus, types and models. Ellis Horwood.

[20] M. Parigot (1992):An algorithmic interpretation of classical natural deduction. In:Proceedings of 3rd Inter-national Conference on Logic for Programming, Artificial Intelligence, and Reasoning (LPAR’92),Lecture Notes in Computer Science624, Springer Verlag, pp. 190–201, doi:10.1007/BFb0013061.

[21] M. Parigot (1997):Proofs of Strong Normalisation for Second Order Classical Natural Deduction. Journal of Symbolic Logic62(4), pp. 1461–1479, doi:10.2307/2275652.

[22] G. Pottinger (1980):A Type Assignment for the Strongly Normalizableλ-terms. In J.P. Seldin & J.R. Hindley, editors: To H. B. Curry, Essays in Combinatory Logic, Lambda-Calculus and Formalism, Academic press, New York, pp. 561–577.

[23] A. Saurin (2008):On the Relations between the Syntactic Theories ofλµ-Calculi. In M. Kaminski & S. Mar-tini, editors: Computer Science Logic, 22nd International Workshop (CSL’08), Bertinoro, Italy,Lecture Notes in Computer Science 5213, Springer Verlag, pp. 154–168, doi:10.1016/j.entcs.2005.11. 072.

[24] A. Saurin (2010): Standardization and B¨ohm Trees for λµ-calculus. In M. Blume, N. Kobayashi & G. Vidal, editors: Functional and Logic Programming, 10th International Symposium, (FLOPS’10), Sendai, Japan,Lecture Notes in Computer Science6009, Springer Verlag, pp. 134–149, doi:10.1007/

978-3-642-12251-4_11.

[25] Th. Streicher & B. Reus (1998):Classical logic: Continuation Semantics and Abstract Machines.Journal of Functional Programming11(6), pp. 543–572, doi:10.1017/S0956796898003141.

Referências

Documentos relacionados

A Lei Federal nº 8.080/1990 dispõe sobre as condições para promoção, proteção e recuperação da saúde, a organização e o funcionamento dos serviços correspondentes. Sobre

A estação que, pela ordem, está para usar a freqüência é a única que deve atender a outra que chamar e se identificar num espaço entre câmbios.. A razão para isso é manter

As diferenças entre as duas bases de dados estão dentro de uma margem já observada na proporção de domicílios que recebem renda do trabalho, que não foi imputada.. A última

SUGESTÕES PARA TRABALHOS FUTUROS - Avaliar o impacto do teor de filler calcário no fator de intensidade de tensão em pastas de cimento em um sistema que permita a ruptura

O objeto desse estudo foi realizar uma intervenção de educação nutricional com pré-escolares, frequentadores de uma Escola Municipal de Educação Infantil, da

Sendo bem receptiva, a Diretora administrativa do IPHAEP foi bastante atenciosa e me citou as formas necessárias de procedimento - em contrapartida contei a ela sobre o projeto,

O tema da migração internacional de goianos para os Estados Unidos da América, em especial para o estado da Califórnia e para a cidade de San Francisco, tem sido tema e

• Remova a grelha para apoiar xícara (7) e o depósito para recolhimento de cápsulas usadas (6), retire as cápsulas utilizadas e lave as três peças com detergente