Approximation Theorems for Intersection Type Systems

MARIANGIOLA DEZANI-CIANCAGLINI, Dipartimento di Informatica, Universita` di Torino, Corso Svizzera 185, 10149 Torino, Italy. E-Mail: [email protected]

FURIO HONSELL, Dipartimento di Matematica ed Informatica, Universita` di Udine, Via delle Scienze 208, 33100 Udine, Italy. E-Mail: [email protected]

YOKO MOTOHAMA, Dipartimento di Informatica, Universita` di Torino, Corso Svizzera 185, 10149 Torino, Italy. E-Mail: [email protected]

Abstract

In this paper we prove that many intersection type theories of interest (including those which induce as filter models, D

Scott’s and Park’s ½ models, the models studied in Barendregt Coppo Dezani, Abramsky Ong, and Honsell Ronchi) satisfy an Approximation Theorem with respect to a suitable notion of approximant. This theorem implies

that a -term has a type if and only if there exists an approximant of that term which has that type. We prove this result uniformly for all the intersection type theories under consideration using a Kripke version of stable sets where bases correspond to worlds.

Keywords: -calculus, intersection types, approximation theorem, -theoretical semantics of types.

1 Introduction Intersection types were introduced in the late 1970s by Dezani and Coppo [8, 9, 6], to over- come the limitations of Curry’s type discipline. They are a very expressive type language

which allows one to describe and capture various properties of -terms. For instance, they have been used in [27] to give the first type theoretic characterization of strongly normaliz- able terms and in [10] to capture persistently normalizing terms and normalizing terms.See [13] for a more complete account of this line of research concerning intersection types. Intersection types have also a very significant realizability semantics with respect to ap- plicative structures. This is a generalization of Scott’s natural semantics [31] of simple types.

According to this interpretation, types denote subsets of the applicative structure, arrow types

! B A

A denoting the sets of terms which map all terms belonging to the interpretation of

A \ B

into terms belonging to the interpretation of B , and intersection types denoting the B intersections of the interpretation of A and the interpretation of . Building on this, intersec- tion types have been used in [6] to give a proof of the completeness of the natural semantics of Curry’s simple type assignment system in applicative structures, introduced in [31]. See [12] for a more complete treatment of the completeness problem of intersection type assignment systems.

J. Logic Computat., Vol. 11 No. 3, pp. 395Ð417 2001 ­c Oxford University Press 396 Approximation Theorems for Intersection Type Systems

But intersection types have also an alternative semantics, based on duality, which is related to Abramsky’s ‘domain theory in logical form’ [1]. This semantics amounts to the application

of that paradigm to the special case of ! -algebraic complete lattice models of pure lambda

calculus, [11]. Namely, types correspond to compact elements: the type ª denoting the least element, intersections denoting joins of compact elements, and arrow types denoting step functions of compact elements. According to this semantics, a typing judgment can

be interpreted as saying that a given term belongs to a pointed compact open set in a ! -

algebraic complete lattice model of -calculus. Hence, by duality, type theories give rise to

filter -models. Intersection type assignment systems can then be viewed as finitary logical  definitions of the interpretation of -terms in such models, hence the meaning of a -term is the set of types which are deducible for it. This duality lies at the heart of the success of intersection types as a powerful tool both for

the analysis and the synthesis of -models [2, 6, 11, 10, 3, 15, 19, 14, 26, 18, 28].

As proved in [3, 11, 4] there is a very large class of ! -algebraic models which have natural D readings as filter models. This class includes for example all the ½ inverse limit models, such as Scott’s [31] and Park’s models [23], the model in [2] which has been studied in

connection with the lazy -calculus, and the model [6] which realizes equality of B¬ohm trees [29].

It is often the case that the very nature of the syntactical properties of -terms that one is

interested in might suggest a particular intersection types theory, which induces a filter model D

which captures semantically such properties. Important examples in this respect are the ½ Á limit models characterizing normalizing terms [10] and terms reducible to - -calculus [19],

respectively. ! A crucial result in the study of the fine structure, and hence the -theory, of -algebraic

-models is the, so called, approximation theorem, [33, 21, 7, 30, 19]. An approximation

theorem allows one to express the interpretation of any -term, even a non terminating one, as the supremum of the interpretations of suitable normal forms, called the approximants of the term, in an appropriate extended language. Approximation theorems are very useful in proving, for instance, computational adequacy of models with respect to operational se- mantics [7, 19]. There are other possible methods of showing computational adequacy, both semantical and syntactical [2, 33, 19, 24], but the method based on approximation theorems is usually the most straightforward. However, proving an approximation theorem for a given model theory is usually rather difficult. Most of the proofs in the literature are based on the technique of indexed reduction [33, 19]. However, when the model in question is a filter model, by applying duality, the approxi- mation theorem can be rephrased as follows: the types of a given term are all and only the types of its approximants. This change in perspective opens the way to proving approxima- tion theorems using the syntactical machinery of proof theory, such as logical predicates and computability techniques. The aim of the present paper is to show in a uniform way that all the type assignment systems which induce filter models isomorphic to the models in [2, 6, 30, 19, 10] satisfy the Approximation Theorem. To this end we use a technique which can be construed as a version of stable sets over a Kripke applicative structure [22]. The present paper is organized as follows. In Section 2 we present type assignment sys- tems for intersection types and we prove some meta-theoretic properties including a genera- tion theorem and subject conversion. In Section 3 we introduce approximants and we prove the approximation theorem using a Kripke interpretation of intersection types in which the Approximation Theorems for Intersection Type Systems 397 bases play the role of worlds. In Section 4 we give some applications of the approximation theorems. Finally we mention directions for future work.

2 Intersection type theories and type assignment systems

Intersection types are syntactical objects built inductively by closing a given set C of type

atoms (constants) under the constructor ! and the intersection

ª C \. We always assume that the universal type is a member of .

DEFINITION 2.1 (Intersection type languages)

Ì = Ì´Cµ The intersection type language over C, denoted by , is defined by the following

abstract syntax:

Ì = C j Ì!Ì j Ì \ Ì:

NOTATION 2.2

Upper case Roman letters, i.e. A; B ; : : : , will denote arbitrary types. In writing intersection-

types we shall use the following convention: the constructor \ takes precedence over

Ò

A ! B

the constructor ! and both associate to the right. Moreover abbreviates

! B !¡¡¡!A

A .

ßÞ } | Ò Much of the expressive power of intersection type disciplines comes from the fact that

types can be endowed with a preorder relation , which induces the structure of a meet ª semi-lattice with respect to \, the top element being .

DEFINITION 2.3 (Intersection type preorder)

= Ì´Cµ Ì

Let Ì be an intersection type language. An intersection type preorder over is a

¼

Ì 5

binary relation  on satisfying the following set (‘nabla-zero’) of axioms and rules:

 A A  A \ A

(refl) A (idem)

A \ B  A A \ B  B Ê

(inclÄ ) (incl )

¼ ¼

 A B  B A  B B  C

(mon) A (trans)

¼ ¼

A \ B  A \ B A  C

A  ª ! \ ´A! B µ \ ´A! C µ  A!B \ C

( ª) ( - )

¼ ¼

A  A B  B

(  )

¼ ¼

A!B  A !B

NOTATION 2.4

 B A  B B  A

We will write A for and .  Notice that associativity and commutativity of \ (modulo ) follow easily from the above axioms and rules.

NOTATION 2.5

Ì

\ A \ ::: \ A A

½ Ò

Being commutative and associative, we will write i for . Similarly

iÒ

Ì

Á; Â;Ã A

we will write i . We convene that etc., when referred to as sets of indexes for

i¾Á types, always denote finite non-empty sets.

The meaning of the above axioms and rules can be grasped if we take types to denote ! subsets of a domain of discourse and we view \ as set-theoretic intersection and as the

398 Approximation Theorems for Intersection Type Systems

 ª  ª!ª

( ª- )

A!B  ª!ª

( ª-lazy)

ª!!  !

( ! -Scott)

! !!  !

( ! -Park)

´!³µ !  ³

´³! ! µ ³!!  !

´! !³µ ! !³  ³

´Á µ ´³!³µ \ ´! !! µ  ³

FIGURE 1. Some special purpose axioms concerning 

!B

function space constructor in the light of CurryÐScott semantics [32]. Thus the type A B

denotes the set of total functions which map each element of A into an element of . \

The intended interpretation of arrow types motivates axiom (!- ), which implies that if a

B A C

function maps A into , and the same function maps also into , then, actually, it maps

B C B \ C

the whole A into the intersection between and (i.e. into ), see [6].

 µ Rule ´ is also very natural in view of the set-theoretic interpretation. It implies that the

arrow constructor is contravariant in the first argument and covariant in the second one. It is

¼ ¼

B A A B B

clear that if a function maps A into , and we take a subset of and a superset of ,

¼ ¼ B

then this function will map also A into , see [6]. ª Clearly axiom ( ª) implies that is the top element. Possibly effective, syntactical presentations of intersection type preorders can be given

using the notion of intersection . An intersection type theory always includes the

¼  basic set 5 for and possibly other special purpose axioms and rules.

DEFINITION 2.6 (Intersection type theories)

= Ì´Cµ 5

Let Ì be an intersection type language, and let be a set of axioms and rules

 B A; B ¾ Ì

for deriving judgments of the shape A , with .Theintersection type theory

¼

C; 5µ A  B 5 [5 ¦´ is the set of all judgments derivable from the axioms and rules in .

NOTATION 2.7

C; 5µ

When we consider the intersection type theory ¦´ , we will write:

5 5 5

C; Ì Ì´Cµ; ¦ ¦´C; 5µ:

C for for for

5

A  B ´A  B µ ¾ ¦ A B 5

Moreover 5 will be short for . Finally we will write for

A  B  A 5 5 .

Figure 1 shows a list of special purpose axioms which have been considered in the litera-

ture.

ª!ª Interpreting ª as the maximal element, i.e. the whole universe, then is the set of

functions which applied to an arbitrary element return again an arbitrary element. Thus, ax- 

iom ( ª- ) expresses the fact that all the objects in our domain of discourse are total functions,

ª!ª i.e. that ª is equal to [6].

Approximation Theorems for Intersection Type Systems 399

= fªg AÇ = f ª g

C ( -lazy)

BC D

C = fªg[ C BC D = f ª  g

½ ( - )

Ë c

= fª;!g Ë = BC D [f ! g C c ( -Scott)

È a

= fª;!g È = BC D [f ! g

C a ( -Park)

CDZ

C = fª;³;!g CDZ = BC D [f´!³µ; ´³!! µ; ´! !³µg

ÀÊ

C = fª;³;!g ÀÊ = BC D [f´!³µ; ´Á µ; ´³! ! µg

FIGURE 2. Type theories: atoms and axioms

If we want to capture only those terms which truly represent functions, as we do for ex-

ª  ample in the lazy -calculus, we cannot assume axiom ( - ). One may still postulate the

weaker property ( ª-lazy) to make all functions total [2]. This axiom simply says that an B element which is a function, because it maps A into , maps also the whole universe into itself.

The remaining axioms express particular properties of D½ -like inverse limit models, see [11, 10, 19, 17].

We introduce in Figure 2 a list of intersection type theories which are significant visavis ` 

for the model theory of untyped -calculus, because each one induces a filter -model. We

5 5 shall denote such theories as ¦ , with various different names corresponding to the initials

of the authors who have first considered the -model induced by such a theory [2, 6, 31, 23,

5

¦ =¦´C; 5µ

10, 19]. For each such 5 we specify in Figure 2 the type theory by giving

5

C 5 C

the set of constants and the set of extra axioms taken from Figure 1. Here ½ is an ;³;! infinite set of fresh atoms, i.e. different from ª . Now that we have introduced intersection type theories we have to explain how to capitalize effectively on their expressive power. This is achieved via the crucial notion of intersection type assignment system. This is a natural extension of Curry’s type assignment system to intersection types. First we need some preliminary definitions and notations.

DEFINITION 2.8

5

Ü: B B ¾ Ì 1. A 5-basis is a set of statements of the shape ,where , all of whose variables

are distinct.

;Ü:A [fÜ:Ag Ü ¾=

2. is short for when .

¼ ¼ ¼

¼ +

5  Ü: B ¾ Ü:B ¾

3. If , are -bases, we define iff for all there is such that

¼

B  B

5 .

DEFINITION 2.9 (Intersection type assignment system)

5

5 5

\ ¦

Let ¦ be a type theory. The intersection type assignment system relative to is a

5

` Å : A Å

formal system for deriving judgments of the form ,wherethesubject is an

5

A Ì 5 untyped -term, the predicate is in ,and is a -basis. Its axioms and rules are the

following:

Ü: A ¾

5

µ ´ ªµ ` Å :ª

´Ax Ax-

5

` Ü:A

400 Approximation Theorems for Intersection Type Systems

5 5 5

;Ü: A ` Å : B ` Å : A ! B ` Æ : A

´! µ µ !

I ´ E

5 5

` Ü:Å : A!B ` ÅÆ : B

5 5 5

` Å : A A  B ` Å : A ` Å : B

5

´ µ ´\ µ

I 5

5 5

` Å : A \ B ` Å : B « As usual, -terms are considered modulo -congruence. The meaning of the above rules is straightforward given the intended meaning of the inter- section types language discussed above.

EXAMPLE 2.10

5 \

Self-application can easily be typed in  , as follows.

5 5

Ü:´A! B µ \ A ` Ü:´A! B µ \ A Ü:´A! B µ \ A ` Ü:´A! B µ \ A

´ µ ´ µ

5 5

5 5

Ü:´A!B µ \ A ` Ü: A!B Ü:´A!B µ \ A ` Ü: A

! µ

´ E

5

Ü:´A! B µ \ A ` ÜÜ : B

µ !

´ I

5

` Ü:ÜÜ :´A!B µ \ A!B

5

\ A6 ª

Also non-strongly normalizing terms can be typed in  even with a type .Note

5

ªµ ¡  Ü:ÜÜ

the usage of the axiom ´Ax- .Let .

5

Ü: A; Ý :ª ` Ü:A

µ !

´ I

5

Ý :ª ` Ü:Ü : A! A

´!

I µ

5 5

` Ý Ü:Ü :ª!A!A ` ¡¡ : ª

´!

E µ

5

` ´Ý Ü:ܵ´¡¡µ : A!A

 f :´Ü:f ´Üܵµ

An interesting example is that the Fixedpoint Combinator Y

5

Ü:f ´Üܵµ \

´ can be typed in (without using intersection!) as follows.

5 5

f :ª ! A ` f :ª ! A f :ª ! A ` ÜÜ :ª

5

f :ª ! A ` f ´Üܵ:A

5 5

f :ª ! A ` Ü:f ´Üܵ:ª! A f :ª ! A ` Ü:f ´Üܵ:ª

5

f :ª ! A ` ´Ü:f ´Üܵµ´Ü:f ´Üܵµ : A

5

` f :´Ü:f ´Üܵµ´Ü:f ´Üܵµ : ´ª ! Aµ ! A

In the rest of this section we give a number of meta-theoretic properties of intersection type systems, which will be useful in the sequel.

First notice that intersection elimination rules

5 5

` Å : A \ B ` Å : A \ B

´\E µ

5 5

` Å : A ` Å : B

5

\ ´ µ can immediately be shown to be derivable in all using 5 . A first simple proposition, which can be proved straightforwardly by induction on the structure of derivations is the following. Approximation Theorems for Intersection Type Systems 401

PROPOSITION 2.11 5

For arbitrary intersection type theories ¦ the following rules are admissible in the intersec-

5 1 \

tion type assignment system  .

5

` Å : A Ü ¾=

´ÛeakeÒiÒg µ ;

5

;Ü: B ` Å : A

5

;Ü:B ` Å : A Ü ¾= FÎ ´Å µ

´×ØÖeÒgØheÒiÒg µ ;

5

` Å : A

5 5

;Ü:B ` Å : A ` Æ : B

; ´cÙØ µ

5

` Å [Ü := Æ ]:A

5

;Ü:B ` Å : A C  B

5

; ´ µ

5 L

5

;Ü: C ` Å : A

5 5

;Ý:B ` Å : A ` Æ : C Ü ¾=

´! ;

5

;Ü:C ! B ` Å [Ý := ÜÆ ]:A

5

;Ü: A ` Å : B

´\ :

5

;Ü:A \ C ` Å : B

5 \

As we shall see below the type assignment system  is very well-behaved when the 5 type theory ¦ is beta in the following sense.

DEFINITION 2.12

5 5

¦ Á A ;B ;C;D ¾ Ì i

A type theory is beta iff for all , i :

Ì

´A !B µ  C !D ² D 6 ª µ

i i 5

5

i¾Á

Ì Ì

9Â  Á C  A ² B  D

i i 5

, 5 .

i¾Â i¾Â The above property is best understood if we take the view of intersection types as compact

elements of ! -algebraic CPO models, i.e. the view advocated in [11] and fully expounded in

[1]. According to this view, \ represents join and arrow types represent step functions. Then the condition for a type theory being beta is exactly the relation which holds between sups of step functions [16].

A sufficient condition for a type theory to be beta is given below. We will use this condition to conclude that all the intersection type theories of Figure 2 are beta (Theorem 2.15).

DEFINITION 2.13 5

A type theory ¦ is strong beta iff: BC D

1. each axiom or rule of Ö either belongs to or it is of one of the following two shapes:

¼



¯ ,

Ì

´½µ ´¾µ

 ´ ! µ

¯ ,

i i

i¾Á

´½µ ´¾µ ´¾µ

¼ 5 ¼

; ; ¾ C ; ; 6 ª´i ¾ Á µ

where ; ,and ;

i i i

Ì

´½µ

5

6 ª ¾ C Ö  ´ !

2. for each , there is exactly one axiom in of the shape

i

i¾Á

´¾µ µ

;

i

¼

 3. 5 contains iff:

1 «

« µ ` ¬

We recall that a rule is said to be admissible if ` is true. ¬

402 Approximation Theorems for Intersection Type Systems

Ì

´½µ ´¾µ

 ´ ! µ ¾5;

(a)

i i

i¾Á

Ì

¼´½µ ¼´¾µ

¼

 ´ ! µ ¾5

(b) ,and

j j

j ¾Â

¼´½µ ´¾µ ´½µ ¼´¾µ

j ¾ Â i ¾ Á   ¾5

(c) for all there exists such that ¾5and .

j i i j

LEMMA 2.14

Each strong beta type theory is beta.

5 C

PROOF. We will denote by ;;; (possibly with indices) elements of . By assumption

5

¾ C

for each constant there is exactly one axiom stating that is equivalent to an inter-

Ì

´ µ ´ µ

µ ! ´

µ

section of arrow types. We denote by ´ such an intersection. Moreover

РРоÄ

notice that the most general form of an intersection type is a finite intersection of arrow types  and type constants. We can prove by simultaneous induction on the derivation of 5 two

statements, the first of which implies the beta condition:

Ì Ì Ì Ì

 µ ´C !D µµ \ ´ µ  ´ ´A !B µµ \ ´ ¯ ´

k j j h 5 i

if i ,

k ¾Ã j ¾Â h¾À i¾Á

¼

¼ ¼ ¼ ´ µ ´ µ

h h

D 6 ª Á  Á À  À h ¾ À Ä  Ä

and j , then there exist , and, for all , such

5

Ì Ì Ì

´ µ

h

¼

C  ´ A µ \ ´ ´  µµ

´ µ

¼ ¼

5 i

that j and

h

i¾Á h¾À Ð

оÄ

Ì Ì Ì

´ µ

h

¼

´ B µ \ ´ ´  µµ  D

´ µ

¼ ¼

i j

5 ;

h

i¾Á h¾À

Ð¾Ä Ð

Ì Ì Ì Ì

¯ ´ ´A !B µµ \ ´ µ  ´ ´C !D µµ \ ´  µ

i h 5 j j k

if i ,

i¾Á h¾À j ¾Â k ¾Ã

´ µ ¼ ¼

k

 6 ª Ñ ¾ Ä Á  Á À  À h ¾

and k , then for each there exist , and, for all

5

Ì Ì Ì

¼

´ µ ´ µ

h k

´ µ ´ µ ¼

h h

¼

 µµ Ä  Ä   ´ A µ \ ´ ´ À

´ µ

¼ ¼

Ñ i

, such that 5 and

h

Ð i¾Á h¾À оÄ

Ì Ì Ì

´ µ ´ µ

h k

¼

´ B µ \ ´ ´  µµ  

´ µ

¼ ¼

Ñ 5

i .

h

i¾Á h¾À Ð

оÄ

THEOREM 2.15

All the type theories of Figure 2 are beta.

5 ¾ fAÇ ; BC Dg 

PROOF.For we can prove by induction on the definition of 5 ,thatif

Ì Ì Ì Ì

¼

´ ´A !B µµ \ ´ µ  ´ ´C !D µµ \ ´  µ D 6 ª 9Á 

i h 5 j j k j

i and ,then

5

i¾Á h¾À j ¾Â k ¾Ã

Ì Ì

A B  D Á C 

¼ ¼

i i 5 j 5

such that j ,and .

i¾Á i¾Á

5

5¾ fË ; È ; CDZ ; ÀÊg The theories ¦ for c a are beta by Lemma 2.14. We are now ready to give a very important meta-theorem for reasoning on type derivations: the generation or inversion theorem. Notice the assumption that the theory is beta in clause 4 below.

THEOREM 2.16 (Generation theorem)

5 5

A6 ª ` Ü: A Ü:B ¾ B  A B ¾ Ì

1. Assume .Then iff and 5 for some .

5

5 5 5

6 ª ` ÅÆ : A ` Å : B !A ` Æ : B

2. Assume A .Then iff ,and for some

5

5

¾ Ì

B .

Ì

5 5

` Ü:Å : A ;Ü: B ` Å : C Á ´B !C µ  A

i i i 5

3. iff and i ,forsome and

i¾Á

5

B ;C ¾ Ì i

i .

5 5 5

` Ü:Å : B ! C ;Ü:B ` Å : C

4. Let ¦ be beta. Then iff . µ

PROOF. The proof of each (´) is easy. So we only treat ( ). ªµ

(1) Easy by induction on derivations, since only the axioms (Ax), ´Ax- , and the rules

5

´\ µ ´ µ A6 ª ` Ü : A

I , 5 can be applied. Notice that the condition implies that cannot 5

be obtained just using axiom (Ax- ª).

Approximation Theorems for Intersection Type Systems 403

A  A \ A ¾ (2) By induction on derivations. The only interesting case is when ½ and the

last applied rule is ( \I):

5 5

` ÅÆ : A ` ÅÆ : A

½ ¾

: \ µ

´ I

5

` ÅÆ : A \ A

½ ¾

A6 ª A  A  ª

5 ¾ 5

The condition implies that we cannot have ½ . We do the proof for

5

A 6 ª A 6 ª ¾

½ and , the other cases can be treated similarly. By induction there are

5 5

B; C; D; E such that

5 5

` Å : B !C; ` Æ : B;

5 5

` Å : D !E; ` Æ : D;

C  A ² E  A :

5 ½ 5 ¾

´B !C µ \ ´D ! E µ  B \ D !C \ E  B \ D !A 5

So we are done being 5 by rules

´! \µ ´ µ C \ E  A

- and since 5 . (3) The proof is very similar to the proof of (2). It is again by induction on derivations and

again the only interesting case is when the last applied rule is (\I):

5 5

` Ü:Å : A ` Ü:Å : A

½ ¾

´\ µ

I :

5

` Ü:Å : A \ A

½ ¾

Á; B ;C ;Â;D ;E

i j j

By induction there are i such that

5 5

8i ¾ Á: ;Ü:B ` Å : C ; 8j ¾ Â: ;Ü: D ` Å : E ;

i i j j

Ì Ì

´B !C µ  A ² ´D !E µ  A :

i i 5 ½ j j 5 ¾

i¾Á j ¾Â

Ì Ì

´ ´B !C µµ \ ´ ´D !E µµ  A

i j j 5

So we are done since i .

i¾Á j ¾Â

C  ª Á; B ;C A  B !C

i i

(4) The case 5 is trivial. Otherwise let be as in (3), where .

Ì Ì

´B !C µ  B !C Â  Á B  B

i i 5 5

Then implies that there exists a such that i

i¾Á i¾Â

Ì

5 5 5

C  C ¦ ;Ü:B ` Å : C ;Ü:B `

5 i i

and i ,since is beta. From we can derive

i¾Â

Ì

5

´ µ ´\ µ ;Ü: B ` Å : C Å : C

5 i

i using rule L ,soby I we have . Finally applying

i¾Â

5

´ µ ;Ü:B ` Å : C rule 5 we can conclude . We end this section by showing that if a type theory is beta then types are invariant under

¬ -conversion.

THEOREM 2.17 (Subject conversion)

5 5 5

¦ Å = Æ ` Å : A ` Æ : A

Let be a beta type theory and ¬ ,then iff .

5 5

` ´Ü:Å µÆ : A ` Å [Ü := Æ ]:A

PROOF. It suffices to show that iff .

5

µ A ª ` Ü:Å : B !C

i i

( ) The case 5 is trivial. Otherwise by Theorem 2.16(3) ,

Ì

5

C  A ` Æ : B Á B C

i 5 i i

i and ,forsome , and . By Theorem 2.16(4) we get

i¾Á

5 5

;Ü:B ` Å : C ` Å [Ü := Æ ]:C

i i

i .Then follows by an application of rule (cut),

5

` Å [Ü := Æ ]: A \ 

and so we can conclude using rules ( I)and( 5 ).

5 5

´ D ` Å [Ü := Æ ]:A ` Æ : B i ¾ Á i

( )Let be a deduction of and let i for be

Æ Ü all the statements in D whose subject is . Without loss of generality we can assume that

does not occur in .

Á   FÎ ´Æ µ=  FÎ ´Æ µ i If is non-empty, notice that i but (recall that (weak-

ening)and(strengthening) are not rules of the system, they are admissible rules, so 5-bases

404 Approximation Theorems for Intersection Type Systems

! µ ´\ µ

in a derivation can only be modified by rule ´ I ). So using rules (strengthening)and I ,

Ì

5

` Æ : B Å

we have that i . Moreover, one can easily see, by induction on ,that

i¾Á

Ì Ì

5 5

;Ü: ´! µ ` Ü:Å : B ` Å : A B !A i

i . Thus, by rule I ,wehave . Hence,

i¾Á i¾Á

5

! µ ` ´Ü:Å µÆ : A

by ´ E we can conclude .

5

D ` Å : A Æ Ü

If Á is empty, we get from a derivation of by replacing each by .By

5 5

` Æ : ª ;Ü:ª ` Å : A axiom (Ax- ª) .Byrule(weakening)weget and we can conclude as in the previous case. REMARK 2.18

There are intersection type theories for which subject reduction fails. As an example take

¼

5

=¦´fª;³;!g; BC D [f´!³!µgµ ´!³!µ ! !!  ³!!

¦ where the axiom is . We can

¼ ¼

5 5

¼

Ü:³ ` ÁÜ : ! Á  Ý :Ý Ü:³ ` Ü: ! ³ 6 !

derive (where ), but we cannot derive since 5 .

¼ 5

Notably ¦ is not a beta theory. From Theorems 2.15 and 2.17 we immediately get: COROLLARY 2.19 In all type assignment systems induced by the type theories of Figure 2 types are invariant under subject conversion.

3 Approximation theorems This is the crucial section of the paper. For all the type theories of Figure 2 we introduce

appropriate notions of approximants which agree with the -theories of different models and therefore also with the type theories describing these models. Then we will prove that all types of an approximant of a given term (with respect to the appropriate notion of approxi- mants) are also types of the given term. Finally we show the converse, namely that the types which can be assigned to a term can also be assigned to at least one approximant of that term. Hence a type can be derived for a term if and only if it can be derived for an approximant of that term.

3.1 Approximate normal forms

In this paper we consider two extensions of -calculus both obtained by adding one constant. ? The first one is the well-known language  [7]. The other extension is obtained by adding

¨ andisdiscussedin[19].

DEFINITION 3.1

? ? ? 1. The set £ of -terms is obtained by adding the constant to the formation rules of

terms.

¨ ¨ 2. The set £¨ of -terms is obtained by adding the constant to the formation rules of

terms.

¬  ? ­

We consider two mappings (« and ) from -terms to -terms and one mapping ( )

¨ ¬ from -terms to -terms. These mappings differ in the translation of -redexes. Clearly the

values of these mappings are ¬ -irreducible terms, i.e. normal forms for an extended language. As usual we call them approximate normal forms.

DEFINITION 3.2

:£!£?;¬ :£!£?;­ :£!£¨ The mappings « are inductively defined by:

Approximation Theorems for Intersection Type Systems 405

¯Ý´~Ü:Ý Å :::Å µ=~Ü:Ý Ý ´Å µ ::: Ý ´Å µ ݾf«; ¬ ; ­ g

Ñ ½ Ñ

½ for ;

¯ «´~Ü:´Ý :Ê µÆÅ :::Å µ=? Ñ

½ ;

¯ ¬ ´~Ü:´Ý :Ê µÆÅ :::Å µ=~Ü:? Ñ

½ ;

¯ ­ ´~Ü:´Ý :Ê µÆÅ :::Å µ=~Ü:¨­ ´Ý :Ê µ­ ´Æ µ­ ´Å µ :::­´Å µ

½ Ñ ½ Ñ

 ¼ where Ñ .

In order to give the appropriate approximation theorem we will use the mapping « for

Ë CDZ

BC D c

\ \ \ ¬

the type assignment systems  , , , the mapping for the type assignment

È ÀÊ

AÇ a

\ ­ \ \ system  , and the mapping for the type assignment systems , .

Each one of the above mappings associates a set of approximants to each -term in the standard way.

DEFINITION 3.3

5¾ fBC D; Ë ; CDZ; AÇ ; È ; ÀÊg A ´Å µ 5 Å

Let c a .Theset 5 of -approximants of is defined

by

¼ ¼ ¼

A ´Å µ=fÈ j9Å :Å !! Å È Ý´Å µg; ¬

5 and

= « 5¾ fBC D; Ë ; CDZg Ý = ¬ 5 = AÇ Ý = ­ 5¾ fÈ ; ÀÊg

where Ý for c , for ,and for a .

? ¨ ¨ We extend the typing to  -terms and to -terms by adding two different axioms for

and nothing for ?.

DEFINITION 3.4

5

\ 5¾ fBC D; Ë ; CDZ; AÇ g ? 1. We extend the type assignment  ,where c ,to -terms.

È a

\ ¨ 2. We extend the type assignment  to -terms by adding the axiom

È a

AÜ ¨ È µ ` ¨:!

´ - - a .

ÀÊ

\ ¨

3. We extend the type assignment  to -terms by adding the axiom

ÀÊ

AÜ ¨ ÀÊ µ ` ¨: ³ ´ - - . It is easy to verify that the appropriate generalization of the generation theorem (Theo- rem 2.16) holds also for these extensions of the type assignment systems. Therefore we do not introduce different notations for these extended type assignment systems and we will freely refer to the generation theorem 2.16 in discussing derivations in these extended sys- tems. We immediately get:

PROPOSITION 3.5

5

5¾ fBC D; Ë ; CDZ; AÇ g ` ? : A A ª

1. Let c .Then iff 5 .

È a

` ¨:A !  A

2. iff È a .

ÀÊ

` ¨: A ³  A

3. iff ÀÊ .

We introduce a partial order on the set of approximate normal forms which reflects the  ¬ -reduction on -terms in the following sense.

DEFINITION 3.6

¼ ¼

È Ú È  Å; Å

5 iff there are -terms such that:

¼

¯ Å !! Å

¬ ;

406 Approximation Theorems for Intersection Type Systems

È Ý´Å µ

¯ ;

¼ ¼

¯ È Ý´Å µ

where Ý is as in Definition 3.3.

As expected, the order on approximate normal forms agrees with typing.

LEMMA 3.7

5 ¼ 5 ¼

` È : A È Ú È ` È : A

1. If ,and 5 then .

¼ 5 5 ¼ ¼¼

È; È ¾A ´Å µ ` È : A ` È : B È ¾A ´Å µ 5

2. If 5 , ,and then there is such

5 ¼¼

` È : A \ B

that .

¼

Ý´´Ü:Å µÆ µ È Ý´Å [Ü := Æ ]µ

PROOF. (1) It suffices to consider the case È and .

BC D; Ë ; CDZ; AÇ g

For 5¾ f c the proof is easy using Proposition 3.5(1).

È ; ÀÊg ­ ´Å [Ü := Æ ]µ ­ ´Å µ Ü

For 5¾ f a notice that is equal to where the occurrences of

­ ´Æ µ Æ ­ ´Æ µ

have been replaced by ¨ if they are functional and is an abstraction, and by

´Å µ:£! £¨

otherwise. More formally if we define the mapping ­ :



¼

­ ´Å µ Å  Ü:Å

¨ if

­ ´Å µ=

´Å µ

­ otherwise

Ü

:£! £

and the mapping fg :

Ý

Ü

fÞ g = Þ

Ý



Ü

Å  Ü fÆ g

Ý if

Ý

Ü

fÅÆg =

Ü Ü

Ý

Å g fÆ g

f otherwise

Ý Ý

Ü Ü

fÞ :Å g = Þ :fÅ g

Ý Ý

Ü

­ ´Å [Ü := Æ ]µ  ­ ´fÅ g ­ ´Æ µ] Ü := ­ ´Æ µ][Ý :=

then it easy to check that µ[ (provided

Ý

6¾ FÎ ´Å µµ

that Ý .

5 5 5

` È : A ` ¨: B ! C ! A ` Ü:­ ´Å µ:

By Theorem 2.16(2) from we get ,

5

` ­ ´Æ µ:C B; C B , for some .

È a

= È !  B ! C ! A ` ¨ : B ! C ! A 5 a

For we get È a from by Propo-

B  ! C  ! !  A !  ! ! !

È È È

sition 3.5(2). This implies È a , a ,and a since a and È

È a a

¦  ` Ü:­ ´Å µ:!

is a beta theory by Theorem 2.15. We obtain by rule ( È a) and È

È a a

` ­ ´Æ µ:! ;Ü: ! ` ­ ´Å µ: !

. We can derive (by Theorem 2.16(4)), which implies

Ü È È

È a a a

;Ü:!; Ý:! ` ­ ´fÅ g µ:! ` ­ ´Æ µ:! ` ¨­ ´Æ µ: !

. Moreover from we get

Ý

AÜ ¨ È µ  ! µ !  ! ! !

´ a È

using axiom - - and rules ( È a), ( E since a . So we conclude Ü

È a

` ­ ´fÅ g µ[Ü := ­ ´Æ µ][Ý := ­ ´Æ µ] : A 

by rules (cut)and( È ).

Ý a

ÀÊ

5 = ÀÊ ³  B ! C ! A ` ¨ : B ! C ! A

For we get ÀÊ from by

B  ³ ³  C ! A B  !

ÀÊ ÀÊ

Theorem 3.5. This implies either ( ÀÊ and )or( and

ÀÊ

!  C ! A ³  ´³ ! ³µ \ ´! ! ! µ ¦ ÀÊ

ÀÊ )since and isabetatheoryby

³ \ !  ! ³  C ! A ÀÊ

Theorem 2.15 (notice that ÀÊ ). Similarly in the first case from

C  ³ ³  A C  ! !  A

ÀÊ ÀÊ ÀÊ

we get either ÀÊ and or and . In the second case

!  C ! A C  ³ !  A !  ³ ! !

ÀÊ ÀÊ ÀÊ

from ÀÊ we get and since . To sum up

´ µ

using rule ÀÊ we have the following alternative cases:

ÀÊ ÀÊ

¯ ` Ü:­ ´Å µ:³ ` ­ ´Æ µ:³ ³  A

, ,and ÀÊ ;

ÀÊ ÀÊ

¯ ` Ü:­ ´Å µ:³ ` ­ ´Æ µ:! !  A

, ,and ÀÊ ;

Approximation Theorems for Intersection Type Systems 407

ÀÊ ÀÊ

¯ ` Ü:­ ´Å µ:! ` ­ ´Æ µ:³ !  A

, ,and ÀÊ .

Therefore we get alternatively:

ÀÊ ÀÊ

;Ü:³ ` ­ ´Å µ:³ ` ¨­ ´Æ µ:³

¯ ,and ;

ÀÊ ÀÊ

;Ü:! ` ­ ´Å µ:! ` ¨­ ´Æ µ: !

¯ ,and ;

ÀÊ ÀÊ

;Ü:³ ` ­ ´Å µ:! ` ¨­ ´Æ µ:³ ¯ ,and ,

so we can conclude as in previous case.

Å Å Å !! Å Å !! Å È  ­ ´Å µ

¾ ¬ ½ ¬ ¾ ½

(2) By hypotheses there are ½ , such that , and ,

¼

È  ­ ´Å µ ! Å Å !! Å

¬ ¿ ½ ¬ ¿

¾ . By the ChurchÐRosser property of we can find such that

¼¼

Å !! Å È  ­ ´Å µ

¬ ¿ ¿ and ¾ . By (1) we can choose .

3.2 Approximation theorem — part 1

5

` È : A È ¾ A ´Å µ

In this subsection we prove that if and 5 then we can build a

5

` Å : A derivation of .

THEOREM 3.8 (Approximation theorem — part 1)

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg

Let 5¾ f c a .

5 5

9È ¾A ´Å µ: ` È : A µ ` Å : A:

5

¼ ¼ ¼

È ¾A ´Å µ Å Å !! Å È = Ý´Å µ ¬

PROOF.If 5 then by Definition 3.3 there is such that ,

5 ¼

` Å : A

where Ý is as in Definition 3.3. It suffices to show that since this implies

5

` Å : A

by Corollary 2.19.

5 5 ¼

¾ fBC D; Ë ; CDZ; AÇ g ` È : A ` Å : A

For 5 c from we get by Proposi- ¬

tion 3.5(1) and the definition of the mappings « and .

5 ¼

È ; ÀÊ g ` Å : A È

For 5¾ f a we show by induction on .

 Ü

The case È is trivial.

¼ ¼ ¼¼ ¼ ¼¼

 Ü:È Å  Ü:Å È  ­ ´Å µ

If È ,then where . By Theorem 2.16(3) from

Ì

5 5 ¼

` È : A ;Ü: B ` È : C ´B ! C µ  A Á; B ;C

i i i 5 i i

we get i and for some .We

i¾Á

5 ¼¼ 5 ¼

;Ü: B ` Å : C ` Å : A ! i

get by induction i and so we conclude using rules ( I),

\ ´

( I)and 5 ).

¼

È  È È Å  Å Å È  ­ ´Å µ È  ­ ´Å µ

¾ ½ ¾ ½ ½ ¾ ¾

If ½ ,then where and . By Theo-

5 5 5

` È : A ` È : B ! A ` È : B B ¾

rem 2.16(2) from we get ½ , for some .By

5 5 5 ¼

` Å : B ! A ` Å : B ` Å : A ¾ induction this implies ½ and , so we conclude

using rule (!E).

¼

È  ¨È È Å  Å Å È  ­ ´Å µ È  ­ ´Å µ

¾ ½ ¾ ½ ½ ¾ ¾

If ½ ,then where and . By Theo-

5 5 5 5

` È : A ` ¨:B ! C ! A ` È : B ` È : C ¾

rem 2.16(2) from we get , ½ ,

5 5

B; C ` Å : B ` Å : C ¾

for some . By induction this implies ½ and . È

È a a

5 = È ` Å : ! ` Å : ! ¾

For a as in the proof of Lemma 3.7(1) we get ½ and .

5 ¼

Å : A `  ! µ !  ! ! ! È

We can conclude using rules ( È a)and( E since a .

= ÀÊ

For 5 as in the proof of Lemma 3.7(1) we have the following alternative cases:

ÀÊ ÀÊ

¯ ` Å : ³ ` Å : ³ ³  A

½ ¾

, ,and ÀÊ ;

ÀÊ ÀÊ

¯ ` Å : ³ ` Å : ! !  A

½ ¾

, ,and ÀÊ ;

ÀÊ ÀÊ

¯ ` Å : ! ` Å : ³ !  A

½ ¾

, ,and ÀÊ .

5 ¼

` Å : A ´ µ

It is easy to verify that in all cases we can derive using rules ÀÊ and µ ( !E . 408 Approximation Theorems for Intersection Type Systems 3.3 Approximation theorem — part 2 In order to prove the converse of Theorem 3.8 we will use a Kripke-like version of stable sets [22]. It is useful to introduce the following definition.

DEFINITION 3.9

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg

Let 5¾ f c a . We write

5

5

[A] = fÅ j9È ¾A ´Å µ: ` È : Ag:

5

5 5

+ ¼

Å ¾ [A] Æ !! Å Æ ¾ [A] 

By definition we get that and ¬ imply . Moreover

5 5

5

[A]  [A] A ¾ Ì

implies ¼ for all types .

The following definition is crucial, albeit a little involved. It amounts essentially to the definition of the natural set-theoretic semantics of intersection types over a suitable Kripke applicative structure (as defined in [22]), where bases play the role of worlds. In order to keep the treatment elementary we don’t develop the full theory of the natural semantics of intersection types in Kripke applicative structures.

The definition below is rather long, since we have different cases for the type ! and for arrow types according to the different type theories under consideration.

DEFINITION 3.10 (Kripke type interpretation)

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg

Let 5¾ f c a .

5 5

[[ ]] ¾ C [fª;³g = ! 5 = È =[ ]

1. for ½ or and a;

5 5 5

¼ ~

+ ~

[[! ]] = fÅ j8  ; 8Æ ¾ [³] :Å Æ ¾ [! ] g 5¾ fCDZ; ÀÊg ¼

2. ¼ for ;

Ë Ë ~

c ~ c

= fÅ j8Æ:Å Æ ¾ [! ] g [! ]]

3. [ ;

5 5 5

¼ +

[[A! B ]] = fÅ j8  ; 8Æ ¾ [[A]] :Å Æ ¾ [[B ]] g 5 6= AÇ B 6 ª ¼

4. ¼ ,if or ;

AÇ AÇ

[[A! B ]] B  ª =[A! B ]

5. if AÇ ;

5 5 5

[A \ B ]] =[[A]] \ [[B ]]

6. [ .

5 5

Å ¾ [A] Æ !! Å Æ ¾ [A]

Notice that, since and ¬ imply , the same property holds

5 5 5 5

+ ¼

[[A]]  [[A]]  [[A]] A ¾ Ì

for . Moreover implies ¼ for all types .

Lemmas 3.11, 3.13, Definition 3.12 and the final theorem are standard. The proofs of these 5

lemmas are done in the Appendix, since they require some subtle properties of the sets []

5

[]]

and [ .

LEMMA 3.11

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg

Let 5¾ f c a .

5 5

~ ~

Å ¾ [A] ÜÅ ¾ [[A]]

1. Ü implies ;

5 5

[A]]  [A]

2. [ .

DEFINITION 3.12 (Semantic satisfiability)

[[Å ]] = Å [~Ü := ´~Ü µ]

Let  be a mapping from term variables to terms and . Then we write:



5

;; j= Å : A [[Å ]] ¾ [[A]]

1. 5 iff ;



Approximation Theorems for Intersection Type Systems 409

¼ ¼

;; j= 5;; j= Ü : B Ü:B ¾

2. 5 iff for all ;

5 ¼ ¼

j= Å : A 5;; j= 5;; j= Å : A 

3. iff implies for all mappings and all

¼

5-basis . In line with the previous remarks, the following result can be construed also as the sound- ness of the natural semantics of intersection types over a particular Kripke applicative struc- ture, where bases play the role of worlds.

LEMMA 3.13 (Soundness)

5 5

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg ` Å : A j= Å : A Let 5¾ f c a then implies . Finally we give the crucial result.

THEOREM 3.14 (Approximation theorem — part 2)

BC D; Ë ; CDZ ; AÇ ; È ; ÀÊg

Let 5¾ f c a .

5 5

` Å : A µ9È ¾A ´Å µ: ` È : A:

5

5

 ´Üµ = Ü 5; ; j= ` Å : A ¼

PROOF.Let ¼ . By Lemma 3.11(1) .Then implies

5 5

=[[Å ]] ¾ [[A]] Å ¾ [A]

Å by Lemma 3.13. So we conclude by Lemma 3.11(2).



¼

= BC D 5 = Ë

Theorems 3.8 and 3.14 were first proved for 5 in [6], for c in [30], for

= CDZ 5 = AÇ 5 = È 5 = ÀÊ 5 in [10], for in [2], for a and in [19].

4 Some applications of the approximation theorems

The approximation theorems, as phased in the present paper, can be fruitfully used to study

   the -theory of a given -model once we describe such a -model as a filter -model. Filter models can be introduced concisely by the following definition (see [4] for more details).

DEFINITION 4.1

5

X  Ì

1. A 5-filter is a set such that:

¾ X

(a) ª ;

A  B A ¾ X B ¾ X

(b) if 5 and ,then ;

¾ X A \ B ¾ X

(c) if A; B ,then .

5 5

5 Ì

2. F denotes the set of -filters over .

5 5 5

: F ¢F !F

3. Application ¡ is defined as

X ¡ Y = fB j9A ¾ Y:A ! B ¾ X g:

5

EÒÚ F

4. 5 is the set of all mappings from the set of term variables to .

5 5

[[]] :£¢ EÒÚ !F

5. The interpretation function: 5 is defined by

5 5 5

= fA ¾ Ì j9 j= : ` Å : Ag; [[Å ]]



 EÒÚ j=  ´Ü:B µ ¾ B ¾ ´Üµ

where ranges over 5 and iff implies .

5 5

; ¡; [[]] i 5 6. The triple hF is called the (filter) model . Most of the applications of approximation theorems to the study of the fine structure of a

filter -model follow a similar pattern. One usually starts out by focusing on a semidecidable 410 Approximation Theorems for Intersection Type Systems property of lambda terms, which is decidable on approximate normal forms, e.g. having

a head normal form, being reducible to an Ò-fold abstraction, being reducible to a closed

term, :::. Then, by induction on the structure of approximate normal forms, repeatedly using the generation theorem (Theorem 2.16), one proves a completeness result, namely that an approximate normal form satisfies such a property if and only if it has a type of a given shape, possibly in a given basis.

Since the model is a filter -model, this completeness result has a semantical counterpart at the level of compact elements. Finally, being the property under consideration continuous, and so true for an arbitrary lambda term whenever it is true for an approximant of it, by the approximation theorem, the completeness result can be used to characterize the interpretation of an arbitrary lambda term.

By way of example in the present section we will discuss some interesting properties of

; Ë ; CDZ; AÇ ; È ; ÀÊ

the models BC D c a . More precisely we will show that:

BC D; CDZ ; Ë

¯ the models c are sensible (according to [7, Definition 4.1.7]);

AÇ ½

¯ the top element in the model is the interpretation of the terms of order ; È

¯ the model a characterizes the terms reducible to closed terms;

ÀÊ Á ¯ the model characterizes the terms reducible to -terms. The rest of this section is devoted to the proof of these properties. Other uses of the approxi- mation theorem can be found in the corresponding relevant papers, i.e. [6, 10, 30, 2, 19, 4].

THEOREM 4.2

; CDZ ; Ë The models BC D c are sensible, i.e. they equate all unsolvable terms. Moreover the bottom element of the model is the interpretation of all unsolvable terms.

PROOF. It follows immediately from the approximation theorem and the fact that ? is the

only approximant of an unsolvable term for the mapping «. Notice that by Proposition 3.5(1)

the interpretation of unsolvable terms is the set of types equivalent to ª, i.e. the bottom element of the model.

Let us recall the definition of term of order ½ [20].

DEFINITION 4.3

¼

½ Ò Å

Aterm Å is of order iff for all integers there is such that

¼

Å !! Ü :::Ü :Å :

¬ ½ Ò

THEOREM 4.4

AÇ AÇ

Å ½ [[Å ]] = Ì  ¾ EÒÚ

Aterm is of order iff for all AÇ . 

PROOF. It is easy to check by structural induction on types that

AÇ Ò

A ¾ Ì Ò ª ! ª  A

for all there is such that AÇ .

¾ £? So by the approximation theorem it suffices to show that if È is an approximate normal

form:

AÇ Ò ¼ ¼

` È :ª ! ª È  Ü :::Ü :È È Ò

iff ½ for some .

¼ AÇ Ò

È  Ü :::Ü :È ` È :ª ! ª AÜ ª ! Ò

If ½ we can derive using axiom ( - )andrule( I).

¼ ¼

È  Ü :::Ü :È Ñ < Ò È Ñ

Vice versa if we assume by contradiction that ½ for and

AÇ Ò

~ ~

ÜÈ Ü È ` È : ª ! ª

is either ? or for some , , then by Theorem 2.16(4) implies

AÇ ¼ Ò Ñ

fÜ :ª;:::;Ü :ªg ` È : ª ! ª Ñ

½ . But this latter judgment cannot be derived by

¼ ¼

~

? È  ÜÈ Proposition 3.5(1) if È and by Theorem 2.16(2) and (1) if . Approximation Theorems for Intersection Type Systems 411

THEOREM 4.5

È a

" ! Å [[Å ]]  ¾ EÒÚ

Aterm reduces to a closed term iff for all È .

 a

¾ £¨ Î PROOF. By the approximation theorem it suffices to check that if È and is a set of term variables:

È a

Ü:! j Ü ¾Îg` È : ! FÎ ´È µ Î:

f iff

È = fÜ:! j Ü ¾Îg

The proof is by structural induction on .Let ! . The key property is that

!  ! ! !

È a .

¼

 Ý :È

The case È follows by Theorem 2.16(4) and using the induction hypothesis.

~

 Ý È Ý ¾ Î È

If È then by Theorem 2.16(2) and (1) we need .Since a is a beta theory È

a ~

` È : !~ we get as the proof of Lemma 3.7(1) ! , so we conclude using the induction

hypothesis.

¼ È

~ a

È  ¨È È `

Similarly if then by Theorem 2.16(2) and Proposition 3.5(2) we have !

¼ È

a ~

È : ! ` È : ~!

and ! . Á Lastly we work out the characterization of terms reducible to  -terms. We define the set of terms we want to characterize and the set obtained by adding the

constant ¨ to it.

DEFINITION 4.6

Á¬ Á¬ £ Å ¾ £Á¬ Å

1. The set £ of -terms is the subset of such that iff reduces to a term

in which all abstracted variables occur at least once (i.e. Å reduces to a -term).

Á¬ ¨ Á¬ ¨ ¨

2. The set £ of -terms is obtained by adding the constant to the formation rules

Á¬

of  -terms.

¾ £Á¬ ¨

In the following key lemma we show that each approximate normal form È in

ÀÊ ³ typable with ³ from the -basis all whose predicates are . To deal properly with the

structural induction on approximate normal forms in the case of abstractions we also show

¾ È È ! ÀÊ Ü: !

that if Ü then is typable with from the -basis containing and all whose other

³ ³  ´³!³µ \ ´! !! µ

predicates are .Thisisusefulsince ÀÊ .

LEMMA 4.7

¾ £¨

Let È be an approximate normal form, then:

ÀÊ

È ¾ £Á¬ ¨ ` È : ³

1. iff ³ ;

Ü ÀÊ

È ¾ £Á¬ ¨ Ü ¾ È È : !

2. if and then ` ;

³

Ü ÀÊ

` È : ! Ü ¾ È

3. if then ,

³

Ü

= fÝ :³ j8Ý g = fÜ:! g[ fÝ :³ j8Ý 6= Üg

where ³ ,and . ³

PROOF. (1), (2) and (3) can be simultaneously proved by induction on È .

 Ý

The case È is trivial.

¼ ¼ ¼

 Þ :È µ È ¾ £Á¬ ¨ È ¾ £Á¬ ¨ Þ ¾ È

Let È . For (1)( ) notice that implies and .Then

ÀÊ ¼ Ü ÀÊ ¼

` È : ³ ` È : ! ! ´\ µ

we have by induction ³ and ,sobyrules( I), I and

³

ÀÊ ÀÊ ÀÊ ¼

´ µ ` È : ³ ´ ` È : ³ ` È : ³

³ ³ ³

ÀÊ we get . For (1)( ) implies and

Þ ÀÊ ¼ ÀÊ

` È : ! ³  ´³! ³µ \ ´! !! µ ¦

by Theorem 2.16(4) since ÀÊ and is beta. By

³

¼ ¼ ¼

¾ £Á¬ ¨ Þ ¾ È È ¾ £Á¬ ¨ Ü ¾ È Ü ¾ È

induction È and so we get .For(2)if then ,and

Ü ÀÊ ¼ Ü ÀÊ

` È : ! ! ´ µ ` È : !

by induction ,sobyrules( I)and ÀÊ we get .For(3)

³ ³

Ü ÀÊ Ü ÀÊ ¼ ¼

` È : ! ` È : ! Ü ¾ È Ü ¾ È

implies so we get by induction ,i.e. .

³ ³

412 Approximation Theorems for Intersection Type Systems

¼ ¼

~

 È È ¾f¨;Þg µ È ¾ £Á¬ ¨ È ¾ £Á¬ ¨

Let È where . For (1)( ) notice that implies

ÀÊ ¼ ÀÊ

~

È ¾ £Á¬ ¨ ` È : ³ ` È : ³

³ i

and . Then we have by induction ³ and for all

ÀÊ

i ´ µ ´AÜ ¨ Àʵ ! ´ µ ` È : ³ ³

, so by axiom either Ax or - - and rules ( E), ÀÊ we get .

ÀÊ

´ ` : A ³  A  Þ ³

For (1)( ) notice that implies ÀÊ by Theorem 2.16(1) when

ÀÊ ÀÊ ¼

 ¨ ` È : ³ ` È : ³ ³

or by Proposition 3.5(3) when .So ³ implies

ÀÊ

` È : ³ i ³  ´³! ³µ \ ´! !! µ

³ i

and for all by Theorem 2.16(2) since ÀÊ .By

¼

È ¾ £Á¬ ¨ È ¾ £Á¬ ¨ i È ¾ £Á¬ ¨ Ü ¾ È

induction and i for all ,soweget .For(2)if then

¼ ÀÊ

~

 Ü Ü ¾ È È Ü:! ` Ü:! !

either or . In the first case so by rules (weakening), ( E),

Ü ÀÊ Ü ÀÊ ¼

´ µ ` È : ! ` È : !

ÀÊ we get . In the second case by induction either

³ ³

Ü ÀÊ

` È : ! i ´ µ ´AÜ ¨ ÀÊ µ !

or i for some , so by axiom either Ax or - - and rules ( E),

³

Ü ÀÊ

´ µ ` È : ! ´

ÀÊ we get . For (3) by an argument similar to that showing (1)( )

³

Ü ÀÊ Ü ÀÊ ¼ Ü ÀÊ

` È : ! 6 Ü ` È : ! ` È : ! i

and imply either or i for some ,so

³ ³ ³

¼

Ü ¾ È Ü ¾ È i Ü ¾ È we get by induction either or i for some ,i.e. .

Now we can prove the final result:

THEOREM 4.8

ÀÊ

 ´Üµ=" ³ Ü Å ¾ £Á¬ [[Å ]] " ³

Let ³ for all variables .Aterm iff .



³

¾ £Á¬

PROOF. Easy from Theorems 3.8, 3.14 and Lemma 4.7(1) observing that Å iff

A ´Å µ  £Á¬ ¨

ÀÊ .

Theorem 4.8 was first proved in [19] by purely semantic means.

Directions for future work

Intersection types theory is necessary for the approximation theorem, because types have to ¬ be invariant under ¬ -conversion. The property of -invariance holds neither for Simple types

nor for System F. Moreover intersection types don’t preserve ¬ -expansion if we omit the

universal type ª [27, 17]. It is interesting to remark that the present proof method does not easily extend to strict

intersection types as defined in [5]. Actually for strict intersection types Lemma A.1 (see the

: ! ;Þ: \  ` ÜÞ :

Appendix) fails, since for example we can derive Ü but we cannot

: ! ` Ü: \ ! derive Ü . It would be interesting to develop in full the natural semantics of intersection types in Kripke applicative structures and more generally in pre-sheaf models.

In this paper we have considered only approximation theorems for ordinary -calculus.

It would be worthwhile exploring the techniques developed in this paper for establishing

  corresponding approximation theorems for restricted -calculi, such as Plotkin’s Ú -calculus [25].

Acknowledgements The authors are very grateful to F. Alessi for very stimulating discussion on the subject of the present paper, and they thank the referees for their useful suggestions. This research has been partially supported by MURST Cofin ’99 TOSCA Project, FGV ’99 and CNR-GNSAGA. Approximation Theorems for Intersection Type Systems 413 References [1] S. Abramsky. Domain theory in logical form. Annals of Pure and Applied Logic, 51, 1Ð77, 1991. [2] S. Abramsky and C.-H. L. Ong. Full abstraction in the lazy lambda calculus. Information and Computation, 105, 159Ð267, 1993. [3] F. Alessi. Strutture di tipi, teoria dei domini e modelli del lambda calcolo. PhD thesis, Torino University, 1991.

[4] F. Alessi, M. Dezani-Ciancaglini, and F. Honsell. Intersection types. In Typed -calculus and applications. H.P. Barendregt, ed. North-Holland, Amsterdam, submitted. [5] S. van Bakel. Complete restrictions of the intersection type discipline. Theoretical Computer Science, 102, 135Ð163, 1992. [6] H. Barendregt, M. Coppo, and M. Dezani-Ciancaglini. A filter lambda model and the completeness of type assignment. Journal of Symbolic Logic, 48, 931Ð940, 1983. [7] H.P. Barendregt. The Lambda Calculus: its Syntax and Semantics. North-Holland, Amsterdam, revised edition, 1984.

[8] M. Coppo and M. Dezani-Ciancaglini. An extension of the basic functionality theory for the -calculus. Notre Dame Journal of Formal Logic, 21, 685Ð693, 1980.

[9] M. Coppo, M. Dezani-Ciancaglini, and B. Venneri. Principal type schemes and -calculus semantics. In To H. B. Curry: Essays on Combinatory Logic, Lambda Calculus and Formalism, pp. 535Ð560. Academic Press,

London, 1980. D

[10] M. Coppo, M. Dezani-Ciancaglini, and M. Zacchi. Type theories, normal forms, and ½ -lambda-models. Information and Computation, 72, 85Ð116, 1987. [11] M. Coppo, F. Honsell, M. Dezani-Ciancaglini, and G. Longo. Extended type structures and filter lambda models. In Logic Colloquium ’82, pp. 241Ð262. North-Holland, Amsterdam, 1984. [12] M. Dezani-Ciancaglini, F. Honsell, and F. Alessi. A complete characterization of the complete intersection-type theories. In Proceedings in Informatics, volume 8, J. P. Rolim et al., eds. pp. 287Ð301. ITRS’00 Workshop, Carleton-Scientific, 2000.

[13] M. Dezani-Ciancaglini, F. Honsell, and Y. Motohama. Compositional characterization of -terms using inter- section types. In Mathematical Foundations of Computer Science 2000, M. Nielsen and B. Rovan, eds. pp. 304Ð313. Volume 1893 of Lecture Notes in Computer Science, Springer, 2000. [14] P. Di Gianantonio and F. Honsell. An abstract notion of application. In Typed Lambda Calculi and Applications, M. Bezem and J.F. Groote, eds. pp. 124Ð138. Volume 664 of Lecture Notes in Computer Science, Springer, Berlin, 1993. [15] L. Egidi, F. Honsell, and S. Ronchi della Rocca. Operational, denotational and logical descriptions: a case study. Fundamenta Informatica, 16, 149Ð169, 1992. [16] G.K. Gierz, K.H. Hoffmann, K. Keimel, J.D. Mislove, and D.S. Scott. A Compendium of Continuous Lattices. Springer-Verlag, Berlin, 1980. [17] F. Honsell and M. Lenisa. Some results on the full abstraction problem for restricted lambda calculi. In Mathematical Foundations of Computer Science 1993, Brookes et al., eds. pp. 84Ð104. Volume 802 of Lecture Notes in Computer Science, Springer, Berlin, 1993.

[18] F. Honsell and M. Lenisa. Semantical analysis of perpetual strategies in -calculus. Theoretical Computer Science, 212, 183Ð209, 1999. [19] F. Honsell and S. Ronchi della Rocca. An approximation theorem for topological lambda models and the topological incompleteness of lambda calculus. Journal of Computational System Scince, 45, 49Ð75, 1992.

[20] G. Longo. Set-theoretical models of -calculus: theories, expansions, isomorphisms. Annals of Pure and Applied Logic, 24, 153Ð188, 1983. [21] G. Longo. On Church’s formal theory of functions and functionals. Technical Report 9, Department of Com- puting Science, Pisa University, 1987.

[22] J. Mitchell. Foundation for Programmimg Languages. MIT Press, 1996.  [23] D. Park. The Y -combinator in Scott’s -calculus models (revised version). Theory of Computation Report 13, Department of Computer Science, University of Warick, 1976. [24] A.M. Pitts. Computational adequacy via ‘mixed’ inductive definitions. In Mathematical foundations of com- puter science 1993, Brookes et al., eds. pp. 72Ð82. Volume 802 of Lecture Notes in Computer Science, Springer, Berlin, 1993.

[25] G. D. Plotkin. Call-by-name, call-by-value and the -calculus. Theoretical Computer Science, 1, 125Ð159, 1975. 414 Approximation Theorems for Intersection Type Systems

[26] G. D. Plotkin. Set-theoretical and other elementary models of the -calculus. Theoretical Computer Science, 121, 351Ð409, 1993.

[27] G. Pottinger. A type assignment for the strongly normalizable -terms. In To H. B. Curry: Essays on Combina- tory Logic, Lambda Calculus and Formalism, J.R. Hindley and J.P. Seldin, eds. pp. 561Ð577. Academic Press, London, 1980. [28] A. Pravato, S. Ronchi della Rocca, and L. Roversi. The call-by-value lambda calculus: a semantic investigation. Mathematical Structures in Computer Science, 9, 617Ð650, 1999. [29] S. Ronchi della Rocca. Characterization theorems for a filter lambda model. Information and Control, 54, 201Ð216, 1982. [30] S. Ronchi della Rocca. Lecture notes on semantics and types. Internal Report, Torino University, 1998. [31] D. Scott. Continuous lattices. In Toposes, Algebraic Geometry and Logic, F.W. Lawvere, ed. pp. 97Ð136. Volume 274 of Lecture Notes in Mathematics, Springer, Berlin, 1972. [32] D.S. Scott. Open problem. In Lambda Calculus and Computer Science Theory,C.B¬ohm, ed. p. 369. Volume 37

of Lecture Notes in Computer Science, Springer, Berlin, 1975. D

[33] C. P. Wadsworth. The relation between computational and denotational properties for Scott’s ½ -models of the lambda-calculus. SIAM Journal of Computing, 5, 488Ð521, 1976.

Appendix First we need a technical result.

LEMMA A.1

¼

; Ë ; CDZ ; AÇ ; È ; ÀÊ g = ;Þ:B Þ ¾= FÎ ´Å µ A6 ª 5 = AÇ

Let 5¾ fBCD c a .If , ,and for ,then

5

5 5

ÅÞ ¾ [A] Å ¾ [B ! A]

¼ implies .

¼ 5

^

È ¾A ´Å µ ¾A ´ÅÞµ ` È : A È Å

ROOF È 5

P .Let 5 and . We show by cases on and that there is such

5

^

` È : B ! A È ¾A ´ÅÞµ

that .If 5 then we are in one of the following cases:

È ? 5¾ fBCD; Ë ; CDZ ; AÇ g

¯ and c ;

¼ ¼

¯ Å !! Ü:Å È ¾A ´Å [Ü := Þ ]µ 5

¬ and ;

¼ ¼

¯ È  È É È ¾A ´Å µ É ¾A ´Þ µ 5

, 5 and ;

¼ ¼

¯ È  ¨È É È ¾A ´Å µ É ¾A ´Þ µ 5¾ fÈ ; ÀÊ g 5

, 5 , and a .

? 5¾ fBCD; Ë ; CDZg 5 = AÇ

The case È is trivial for c and impossible for by Proposition 3.5(1).

¼ ¼

^

È  Þ :È Å !! Ü:Å È ¾A ´Å [Ü := Þ ]µ 5

If ¬ and we can choose .

¼ ¼ ¼

^

È  È È  È É È ¾A ´Å µ É ¾A ´Þ µ 5

If where 5 and , then we can choose . In fact by Theorem 2.16(2)

¼ 5 ¼ 5 ¼ ¼ 5 ¼ 5

` È : A ` È : C ! A ` É : C C ` É : C

from we get , for some . By Theorem 3.8

¼ 5

` Þ :C B  C  5

implies ,soweget 5 by Theorem 2.16(1) and we conclude using ( )and(strengthening)

5 ¼

` È : B ! A

.

¼ ¼ ¼

^

È  ¨È É È ¾A ´Å µ É ¾A ´Þ µ 5¾ fÈ ; ÀÊg È  È 5

If where 5 and ,then a , and we can choose .In

¼ 5 ¼ 5 ¼ 5 ¼ ¼ 5

` È : A ` ¨:C ! D ! A ` È : C ` É : D

fact by Theorem 2.16(2) from we get , ,

C; D B  D 5 = È

for some . As in the previous case we get 5 .For a using Proposition 3.5(2) as in the proof of

 ! D  ! !  A 5 = ÀÊ

Lemma 3.7(1), we get C , ,and . Similarly for using Proposition 3.5(3), we

È È

È a a a

 ³ D  ³ ³  A C  ³ D  ! !  A C  !

get either C , ,and ,or , ,and ,or ,

ÀÊ È ÀÊ ÀÊ ÀÊ È

ÀÊ a a

D  ³ !  A C  D ! A  B ! A 

5 5

,and . In all cases we can conclude 5 and therefore by ( ) È

ÀÊ a

5 ¼

` È : B ! A and (strengthening) .

Proof of Lemma 3.11.

PROOF. (1) and (2) can be proved simultaneously by induction on A. We consider only some interesting cases.

CDZ CDZ

¼ +

A  ! 5 = CDZ  [[³]] =[³] ¼

(1) Case and .Let . ¼ (*) by Definition 3.10(1).

CDZ CDZ

~ ~

ÜÅ ¾ [! ] µ ÜÅÆ ¾ [! ] ´ µ ´! µ

and (*) ¼ by rules and E

CDZ

 ³ ! !

since !

CDZ

CDZ

~

: ÜÅ ¾ [[! ]]

µ by Definition 3.10(2)

Approximation Theorems for Intersection Type Systems 415

5 5

¼ +

A  B ! C  5 6= AÇ C 6 ª [[B ]]  [B ] ¼

Case .Let and or . ¼ (**) by induction on (2).

5 5

~ ~

ÜÅ ¾ [A] µ ÜÅÆ ¾ [C ] ´! µ

and (**) ¼ by rule E

5

~

µ ÜÅÆ ¾ [[C ]]

¼ by induction on (1)

5

~

ÜÅ ¾ [[B ! C ]] :

µ by Definition 3.10(4)

¼

 B !C 5 6= AÇ C 6 ª = ;Þ: B Þ

(2) Case A and either or .Let where is fresh, and suppose

5 5

¾ [[B ! C ]] Þ ¾ [[B ]]

Å ; then, since by induction on (1), we have

fÞ :B g

5 5 5

Å ¾ [[B ! C ]] Þ ¾ [[B ]] µ ÅÞ ¾ [[C ]]

and ¼ by Definition 3.10(4)

fÞ :B g

5

µ ÅÞ ¾ [C ]

¼ by induction on (2)

5

µ Å ¾ [B !C ] :

¼ by Lemma A.1

 B \ C Case A . It follows by induction and Lemma 3.7(2).

The following lemma essentially states that Kripke type interpretations agree with the corresponding type theo- ries.

LEMMA A.2

CDZ CDZ CDZ

¾ [A] Æ ¾ [[! ]] Å [Þ := Æ ] ¾ [A]

1. Let Å and then .

;Þ :!

5 5

5

5¾ fBCD; Ë ; CDZ; AÇ ; È ; ÀÊg A  B [[A]]  [[B ]] A; B ¾ Ì

2. Let c a .Then 5 implies for all .

CDZ CDZ

¾ [A] È ¾A ´Å µ ;Þ:! ` È : A

PROOF.(1)IfÅ then there is such that . The proof is by

;Þ :! CDZ

induction on È .

¼ ¼ ¼ ¼

È ? A  ª È  Ü:È Å !! Ü:Å È ¾A ´Å µ

The cases or are trivial. If then ¬ and .

CDZ CDZ

Ì

CDZ CDZ ¼

´B !C µ  A ;Þ:! ` È : A ;Þ:!; Ü:B ` È : C

i i i

From we get i and for some

i¾Á

CDZ

CDZ ¼

Á B ;C ¾ Ì È ¾ A ´Å [Þ := Æ ]µ

i i

and i by Theorem 2.16(3). By induction there are such that

CDZ

CDZ ¼¼ ¼

;Ü:B ` È : C i ¾ Á È ¾A ´Å [Þ := Æ ]µ

i i

i for all . Then by Lemma 3.7(2) there is such that

CDZ

Ì

CDZ ¼¼ CDZ ¼¼

;Ü:B ` È : ` Ü:È : A ´! µ ´\ µ ´ µ C i

i . We can derive using I , I and . Since the

i¾Á

CDZ

« 

-abstraction of reduction pairs preserves the reduction relation and the mapping is closed under the -abstraction,

¼¼

¾A ´Å [Þ := Æ ]µ

we get Ü:È .

CDZ

CDZ CDZ

~ ~ ~ ~

È ¾A ´Å µ È  ÜÈ Å !! ÜÅ ;Þ:! ` È : A ;Þ:! `

If then ¬ and .From we get

CDZ

CDZ

¼

~

~ ~ ~ ~

È ¾A ´Å [Þ := Æ ]µ È : B ;Þ:! ` : B ! A

Ü and by Theorem 2.16(2). By induction there are

CDZ

CDZ

¼ ¼

~ ~

~

` Ü 6= Þ ÜÈ ¾ A ´Å [Þ := Æ ]µ : B

such that È .If we are done since and we can derive

CDZ

CDZ CDZ

¼

~

~ ~

B ! A ` ÜÈ : A ´! µ ;Þ:! ` Þ :B ! A ! 

using E .Otherwise implies by Theo-

CDZ

CDZ

~

B  ³~ !  ³~ ! !

rem 2.16(1). Being ¦ a beta theory by Theorem 2.15 from we obtain and

CDZ CDZ

CDZ CDZ CDZ

¼

~

~

!  A ` Å [Þ := Æ ] ¾ [³] Æ ¾ [[! ]] : ³~

.Soweget È ,i.e. . By Definition 3.10(2)

CDZ

CDZ CDZ

~

[Þ := Æ ] ¾ [³] Å [Þ := Æ ] ¾ [! ] !  A

and Å imply .Since , by Lemma 3.11(2) we get

CDZ

CDZ

[Þ := Æ ] ¾ [A]

Å .

(2) We consider only the most interesting cases.

CDZ CDZ CDZ CDZ

[! !³]]  [[³]] [[! !³]]  [! !³]

Proof of [ . By Lemma 3.11(2) and by Definition 3.9

CDZ CDZ CDZ CDZ

=[³] =[[³]] ! !³] ! !³  ³ [³]

[ since . Hence we are done since by Defini-

CDZ

tion 3.10(1).

CDZ CDZ CDZ CDZ CDZ

 [[! !³]] =[³] [³]] [[³]] Å ¾ [³]

Proof of [ . By Definition 3.10(1) .If then there

CDZ

¾A ´Å µ ` È : ³ È

is È such that . The proof is by cases on .

CDZ ?

The case È is impossible by Proposition 3.5(1).

¼ ¼ ¼ ¼ CDZ CDZ ¼

È  Þ :È Å !! Þ :Å È ¾A ´Å µ ` È : ³ ;Þ:! ` È :

If then ¬ and .From we get

CDZ

CDZ ¼ CDZ ¼

¼ +

³ Å ¾ [³] Å ¾ [³] 

by Theorem 2.16(3). This implies and also ¼ for an arbitrary ,sowegetby

;Þ :!

;Þ :!

¼ CDZ CDZ ¼

Å [Þ := Æ ] ¾ [³] Æ ¾ [[! ]] ÅÆ !! Å [Þ := Æ ]

¬ ¼

(1) ¼ for an arbitrary . We conclude observing that .

CDZ CDZ

~

 ÜÈ ` È : ³ ` È : ! !³ ³  ! !³

If È notice that implies since . Take an arbitrary

CDZ

¼ CDZ CDZ ¼

+ CDZ

 Æ ¾ [[! ]] [[! ]] È ¾A ´Æ µ  [! ]

¼ ¼

and an arbitrary . By Lemma 3.11(2) ¼ , then there is

CDZ

416 Approximation Theorems for Intersection Type Systems

¼ CDZ ¼ ¼ CDZ ¼ CDZ ¼ CDZ ¼

` È : ! ` ÈÈ : ³ ` È : ! !³ ` È : !

such that . We can derive from and

¼

! µ ÈÈ ¾A ´ÅƵ

using ´ E and (weakening). We conclude by observing that .

CDZ

CDZ CDZ CDZ CDZ

[³!! ]]  [[! ]] [[³!! ]]  [³!! ]

Proof of [ . By Lemma 3.11(2) and by Definition 3.9

CDZ CDZ

³!! ] =[! ] ³!!  !

[ since . Moreover

CDZ

CDZ ¼ CDZ

+ CDZ

[[³!! ]] = fÅ j8  ; 8Æ ¾ [[³]] :Å Æ ¾ [[! ]] g ¼

¼ by Definition 3.10(4)

CDZ CDZ

¼ +

= fÅ j8  ; 8Æ ¾ [³] :Å Æ ¾ [[! ]] g ¼

¼ by Definition 3.10(1)

¼ CDZ CDZ ~

+ ~

 fÅ j8  ; 8Æ; Æ ¾ [³] :Å Æ Æ ¾ [! ] g : ¼

¼ by Definition 3.10(2)

CDZ CDZ CDZ ¼ CDZ CDZ ~

+ ~

[[³!! ]]  [! ] [[³!! ]] fÅ j8  ; 8Æ; Æ ¾ [³] :Å Æ Æ ¾ [! ] g ¼

From and ¼

CDZ ¼ CDZ CDZ CDZ ~

+ ~

[[³!! ]] fÅ j8  ; Æ ¾ [³] :Å Æ ¾ [! ] g =[[! ]] ¼

we can conclude ¼ .

CDZ CDZ

[! ]]  [[³!! ]]

Proof of [ .

CDZ ¼ CDZ CDZ ~

+ ~

Å ¾ [[! ]] µ 8  ; 8Æ; Æ ¾ [³] :Å Æ Æ ¾ [! ] ¼

¼ by Definition 3.10(2)

CDZ CDZ

¼ +

µ 8  ; 8Æ ¾ [³] :Å Æ ¾ [[! ]] ¼

¼ by Definition 3.10(1), (2)

CDZ

Å ¾ [[³!! ]] :

µ by Definition 3.10(4)

ÀÊ ÀÊ ÀÊ

[´³!³µ \ ´! !! µ]]  [[³]] [[´³!³µ \ ´! !! µ]]  [´³!³µ \

Proof of [ . By Lemma 3.11(2)

ÀÊ ÀÊ ÀÊ

! !! µ] [´³!³µ \ ´! !! µ] =[³] ´³!³µ \ ´! ! ! µ  ³

´ and by Definition 3.9 since . Hence

ÀÊ

ÀÊ ÀÊ

³] =[[³]]

we are done since [ by Definition 3.10(1).

ÀÊ ¼

ÀÊ +

 [[´³!³µ \ ´! ! ! µ]]  [³]]

Proof of [ .Let .

ÀÊ ÀÊ

Å ¾ [[³]] Å ¾ [³]

µ by Definition 3.10(1)

ÀÊ

9È ¾A ´Å µ ` È : ³

µ (*) by Definition 3.9

ÀÊ

ÀÊ ÀÊ

Æ ¾ [[³]] µ Æ ¾ [³] ¼

¼ by Definition 3.10(1)

¼ ¼ ÀÊ ¼

9È ¾A ´Æ µ ` È : ³

µ (**) by Definition 3.9

ÀÊ

¼ ¼

^ ^

 ¨ÈÈ È  È  ÈÈ

Let È if is a -abstraction and otherwise.

¼ È

a ^

` È : ³ ´AÜ ¨ Àʵ ´ µ ´! µ

(*) and (**) µ by - - , , E

ÀÊ

ÀÊ

^

µ ÅÆ ¾ [³] È ¾A ´ÅƵ

¼ since

ÀÊ

ÀÊ

µ ÅÆ ¾ [[³]]

¼ by Definition 3.10(1)

ÀÊ

Å ¾ [[³ ! ³]] :

µ by Definition 3.10(4)

ÀÊ ÀÊ

Æ ¾ [[! ]] µ Æ ¾ [! ] ¼

¼ by Definition 3.10(2)

¼ ¼ ÀÊ ¼

9È ¾A ´Æ µ ` È : !

µ (***) by Definition 3.9

ÀÊ

ÀÊ ÀÊ

~ ~

Æ ¾ [[³]] µ Æ ¾ [³] ¼

¼ by Definition 3.10(2)

¼ ÀÊ

¼

~

~ ~

µ 9È ¾A ´Æ µ ` : ³~

È (****) by Definition 3.9

ÀÊ

¼ ¼

^ ~ ^ ~

 ¨ÈÈ È È  È  ÈÈ È

Let È if is a -abstraction and otherwise.

¼ È

a ^

µ ` È : ! ´AÜ ¨ Àʵ ´ µ ´! µ

(*) ; (***) and (****) by - - , , E

ÀÊ

ÀÊ

^ ~ ~

È ¾A ´ÅÆÆ µ µ ÅÆÆ ¾ [! ]

¼ since

ÀÊ

ÀÊ

µ ÅÆ ¾ [[! ]]

¼ by Definition 3.10(2)

ÀÊ

Å ¾ [[! ! ! ]] :

µ by Definition 3.10(4)

È È ¼

a È a a

[[! !! ]] Å ¾ [[! !! ]] = ;Þ : ! Þ=¾ FÎ ´Å µ [[! ]]

Proof of  .Let and ,where .

È

a È a

Þ ¾ [! ] Þ ¾ [[! ]]

µ by Definition 3.10(1)

fÞ :! g fÞ :! g

È a

µ ÅÞ ¾ [[! ]]

¼ by Definition 3.10(4)

È a

µ ÅÞ ¾ [! ]

¼ by Definition 3.10(1)

È a

Å ¾ [! ]

µ by Lemma A.1

 µ !  ! ! !

and rule ´ being È È a a

È a

µ Å ¾ [[! ]]

by Definition 3.10(1) :

Approximation Theorems for Intersection Type Systems 417

È ¼

È a a +

[! ]]  [[! !! ]] 

Proof of [ .Let .

È

È a a

¾ [[! ]] µ Å ¾ [! ]

Å by Definition 3.10(1)

È a

9È ¾A ´Å µ ` È : ! µ (*) by Definition 3.9

È a È

È a a

Æ ¾ [[! ]] µ Æ ¾ [! ] ¼

¼ by Definition 3.10(1)

¼ È ¼

¼ a

9È ¾A ´Æ µ ` È : ! µ (**) by Definition 3.9

È a

¼ ¼

^ ^

È  ¨ÈÈ È  ÈÈ 

Let if È is a -abstraction and otherwise.

¼ È

a ^

È : ! ` ´AÜ ¨ È µ ´ µ ´! µ (*) and (**) µ by - - a , , E

È a È

a ^

µ ÅÆ ¾ [! ] È ¾A ´ÅƵ

¼ since È a

È a

µ ÅÆ ¾ [[! ]]

¼ by Definition 3.10(1)

È a

Å ¾ [[! ! ! ]] :

µ by Definition 3.10(4)

Proof of Lemma 3.13.

5

` Å : A ´ µ ´ ªµ

PROOF. The proof is by induction on the derivation of . Cases Ax ,and Ax- are immediate.

´! µ ´\ µ ´ µ ´! µ

Cases E and I follow by induction. Case 5 is ok by Lemma A.2(2). In the case I , suppose that

5

 Ý :Ê A  B !C ;Ý : B ` Ê : C

Å , and has been derived. 5

¼ +

5 6= AÇ C 6 ª [[Ì ]] ¾ [[B ]] 

Let or .Now,if ¼ where , from the induction hypothesis



5

[[Ê]] ¾ [[C ]] :

¼

[Ý :=[[Ì ]] ]



5

[]] ¬

By the invariance of [ under -expansion we get

5

[[´Ý :ÊµÌ ]] =[[Ý :Ê]] [[Ì ]] ¾ [[C ]] ;

¼

  

hence by Definition 3.10(4)

5

; [[Ý :Ê]] ¾ [[B !C ]]



the term Ì being arbitrary.

= AÇ C  ª Ý :È ¾ A ´[[Ý :Ê]] µ È ¾

The case 5 and follows easily observing that for all



AÇ AÇ

 ´Ý µ=Ý ` ´ ªµ ´! µ ´ µ A ´[[Ê]] µ : B !C

and all such that . We can derive Ý :È using Ax- , I and .



AÇ AÇ ª

5 5

[Å ]] ¾ [A] [[Å ]] ¾ [[A]]

Hence we conclude [ which implies by Definition 3.10(5).

 

Received 4 October 2000