Infinite A-calculus and types - Science Direct

2 downloads 0 Views 3MB Size Report
phenomena of the infinite lambda calculus make a full realization of this idea ... version of the infinite A-calculus played the same role that the unsolvable terms ...
The0retical Computer Science ELSEVIER

Theoretical

Computer

Science 212 (1999) 29-75

Infinite A-calculus and types’ Alessandro

Berarducci a, Mariangiola

Dezani-Ciancaglini

b,*

a Dipartimento di Matematica, Universitb di Piss, v.Buonarroti 2. 56127 Piss. Italy b Dipartimento do Informatica, Universitci di Torino, c.Svizzera 185, 10149 Torino, Italy

Abstract

Recent work on infinitary versions of the lambda calculus has shown that the infinite lambda calculus can be a useful tool to study the unsolvable terms of the classical lambda calculus. Working in the framework of the intersection type disciplines, we devise a type assignment system such that two terms are equal in the infinite lambda calculus iff they can be assigned the same types in any basis. A novel feature of the system is the presence of a type constant to denote the set of all terms of order zero, and the possibility of applying a type to another type. We prove a completeness and an approximation theorem for our system. Our results can be considered as a first step towards the goal of giving a denotational semantics for the lambda calculus which is suited for the study of the unsolvable terms. However, some noncontinuity phenomena of the infinite lambda calculus make a full realization of this idea (namely the construction of a filter model) a quite difficult task. @ 1999 Published by Elsevier Science B.V. All rights reserved Keywords:

Infinite I-calculus;

Intersection

types; I-algebras

1. Introduction An infinitary version of I-calculus was presented by Berarducci at the meeting “Common foundations of logic and functional programming” held in Torino, Feb. 1994, and at the conference in honor of Roberto Magari, Siena, April 1994 (published in [7]). An infinite I-calculus was independently developed at about the same time by Kennaway, Klop, Sleep, and de Vries (see [30]) with some differences reflecting the different motivations, as we will explain in the following. In October 1994, Berarducci met Klop in Pisa on occasion of a talk Klop gave on the infinite J.-calculus. Motivated by previous work with Intrigila [8], Berarducci was mainly interested in applications of infinite L-calculus to the study of the properties of unsolvable terms in the classical R-calculus. In particular he defined a special class of unsolvable terms which he called mute and * Corresponding author. E-mail: [email protected], [email protected]. ’ Partly supported by ESPRIT BRA 7232 GENTZEN and by NATO Grant HTECH.LG960875. 0304-3975/99/$ - see front matter PII: SO304-3975(98)00135-2

@ 1999 Published

by Elsevier Science B.V. All rights reserved

30

A. Berarducci,

h4. Dezani-Ckmcaylinil

Theoretical

Computer

argued that the mute terms should be considered of “completely is consistent

undefined

computation”.

to simultaneously

(not necessarily

mute).

identify

This property

Science 212 (1999) 29-75

the terms which represent

To substantiate

the notion

this claim he proved that it

all the mute terms to an arbitrarily

fixed term

is not shared by the class of unsolvable

terms,

and not even by the smaller class of easy terms as shown by [33]. Easy terms have been studied also in [4,24-28,32,54].

Berarducci

showed that the mute terms in his

version of the infinite A-calculus played the same role that the unsolvable terms played in the theory of Bijhm trees [5]. The main result of [7] is that if we equate all the mute terms, then the infinite A-calculus is Church-Rosser and every term has one and only one infinite normal form. It then follows that the infinite normal forms constitute a model of the A-calculus which is similar to the model of B&m trees but which does not equate all the unsolvable

terms. To understand

the idea behind

infinite

il-calculus

the reader can take a look at Definition 2.5 and Fig. 1 before continuing. Applications of the infinite ,?-calculus to the study of the easy terms of the classical L-calculus are given in [9]. Klop and his collaborators on the other hand were interested in generalizing their earlier work on transfinite reduction sequences in the context of term rewriting systems [29]. In [30] several versions of the infinite I-calculus are defined but it is shown that only three of them have good properties. These three calculi can be distinguished by the behavior of the element 1. In the version corresponding to the B&m trees we get I M =J_= 3x. J_ and i can be interpreted either as “lack of information” or as “unsolvable term”. In the version corresponding to the lazy L-calculus -L=_L M # LX. I and I can be interpreted either as lack of information or as unsolvable term “of order zero”, namely not reducible to an abstraction 3Jc.M. In the version corresponding to the one in [7] J_x. I, i M and I are pairwise distinct and i is interpreted as a “mute term”, namely an unsolvable term of order zero which cannot be further decomposed as the application of a term of order zero to some other term. In the latter version we cannot interpret I as lack of information, since this would obviously imply I A4 =I (where = is p-conversion). To denote lack of information we will use instead Sz. The consistency of the infinite i-calculus is guaranteed by a Church-Rosser theorem. In [30] this is proved for reduction sequences of every ordinal length, while in [7] one considers only reductions of length o and proves a Church-Rosser theorem for the system consisting of the terms arising from finite terms. An infinitary version of the A-calculus was also studied in [35] but without a related notion of infinite P-reduction. Salibra and Goldblatt [44] consider an equational treatment of A-calculus with an application to the infinite ;l-calculus. They also point out the fact that a rigorous definition of the substitution operator for the infinite A-calculus requires special care. In this paper we deal with the version of [7]. In particular Lx. I, J_ M and I are all distinct, so not only we do not identify all the unsolvable terms, but we do not even identify all the unsolvable terms of order zero. The price to pay is the presence of some non-constructive features: there is no algorithm to test whether a term has a “top normal form” (the mute terms are those without top normal form). An analogous

31

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

of mute terms for term rewriting

systems

(where no binding

of variables

is allowed)

is given in [31]. In July 1994, Mariangiola the “intersection information

systems

for solving

powerful tool for describing Abramsky’s

Dezani proposed to investigate

type disciplines”.

domain

equations.

the denotational

paper [l] is a mile-stone

type disciplines

languages

in this field, since the given formalism

use of Stone duality to synthesize

Intersection

of programming

are a simple

using

in [47] the

They have been recognized

semantics

prelocales) is quite powerful. In fact domain prelocales so in particular Plotkin’s powerdomain construction Abramsky’s

the infinite ;l-calculus

Fifteen years ago, Dana Scott introduced

as a [52].

(domain

allow to represent SFP domains, [37]. The main contribution is

domain theory and logic of programs. case of information

systems.

They have

been used for describing I-models. The i-theory of the model described in [6] is just the equality of B&m trees 1411. In particular, every inverse limit construction can be very easily mimicked technique

by a suitable

has also allowed the construction

type assignment

system

of a Scott domain

[lo, 22,421.

This

where all and only the

terms with a normal form have an interpretation bigger than a given element [12], thus giving a denotational meaning to normal forms. Moreover, there are suitable filter models isomorphic to Plotkin’s and Engeler’s models, respectively [38]. Lastly, %models

whose

domain

is a qualitative

stable functions have corresponding models for the classical A-calculus,

or quantitative

domain

and the functions

are

filter models [23, 171. All previous models are but intersection type disciplines are also suitable

for describing models of the AI-calculus [5 1,211, of the lazy A-calculus [2], of the callby-value [IS, 401, of the lazy call-by-value I-calculus [39], and of extensions including some parallel features (concurrent A-calculus) [3, 14, 151. In this approach, a A-model is described, in a finitary way, by a system assigning types to terms, such that the interpretation of a term in the model is the set of types which can be deduced for it. This can be expressed through the slogan: “the meaning

of a program

Logical presentations

is the set of all the propositions

of domains

which are true of it”.

are very simple, and yet useful to study theories of

models. In fact, they are finitary descriptions, and this is essential to prove properties of the interpretations of terms. In particular, they allow standard techniques for proving approximation

theorems,

which are key steps in showing

semantic

equalities

between

terms, adequacy with respect to operational semantics, etc. A natural question is whether the denotational approach can be used to analyze the infinite il-calculus. To achieve this goal, our original idea was to extend the intersection type disciplines with a new feature: the application u/? between two types c1 and fi. In the intended interpretation a term has type c@ if it can be expressed as the application of two terms, the first of type a and the second of type B. One must also introduce a new type constant [ to be interpreted, in the closed term model, as the set of all terms of order zero (briefly zero terms). Note that the closed zero terms form a proper subset of the unsolvable terms. The resulting types are then rich enough to distinguish between various kinds of unsolvable terms of order zero in the closed term model. The

32

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

mute ones will only have type [ (besides

the universal

also have types of the form [a, [a/I etc., reflecting as an unsolvable

type o), while the others will

the fact that they can be expressed

term of order zero applied to some other term. We realized

order to simplify our treatment

it was better not to introduce

after all they are already characterized types can thus discriminate

that in

a type for the mute terms:

for not having other types besides i and w. Our

various classes of unsolvable

terms, and this gave us hope

to be able to find a filter model in which the model of [7] could be isomorphically embedded. We have partially succeeded in the sense that one of our results is that two terms have the same filter (i.e. they can be assigned the same types) iff they are equal in the infinite L-calculus

(Theorem

8.12). What is still lacking however is a good

notion of application which turns the set of filters into a I-model. Finding the correct definition of the set of types, their semantic

interpretation

and

also the type assignment system, was a much more difficult task than we expected. To see why, let us discuss in some detail the definition of the set of types and their interpretation. Usually, following [45], the type a + /.I is interpreted as the set of all terms which applied to a term of type a yield a term of type p. This is called the simple semantics of types [ 191. In this semantics the types deducible for an q-redex are also deducible

for its contracturn

[19], and this disagrees

with the fact that in the infinite

I-calculus they are in general unrelated. However, Scott in [46] proposes a second interpretation (the F-semantics according to [19]) where one requires in addition that a term of type CI--+ /3 must be reducible to a term beginning with a I-abstraction, i.e. it should not be a zero term. So we chose this second alternative. In the F-semantics the universal type o is different from o --t w : this is not exempt from complications. Indeed, since our system has a type [ to represent the set of all zero terms, we are now in presence of two types with empty intersection: the type [ itself, and the type w + o. Hence, the type [ A(o + w) is not inhabited (in any model) and the question arises whether we should consider it a legal type at all. We are thus lead to consider a set of “pretypes” and a smaller set of “types” where some obviously empty types like the one above are forbidden (Definition 3.6). The filter of a term will consist of types from the smaller

set. The definition of the set of types is not immediate since after excluding the obviously empty type C A (w 4 o) we must still decide whether a finite intersection like (ai -+ /3i ) A . . . A (a, + /?,,) is empty. The decisive idea comes from Scott theory of information systems [47]: consistent inputs should give consistent outputs. So, if we interpret the above intersection as the step function which gives an output in AiE, pi whenever the input is in AiE1 ai (where I is a subset of { 1,. . . , n}), then we must require that if A,,-[ pi is empty, so is /jiEr C(i. The definition of the types is thus obtained by pruning the set of pretypes according to Scott’s prescription. This excludes for instance (o + (w + 0)) A (w -+ c), because given an input in w we would get an output in (o + o) A [, which is impossible since the latter is empty. Scott’s idea however does not solve all the problems. A type like ((0 + w) + 0 A (c -+ (o + w)) is not forbidden by the above considerations, so we consider it a legitimate type, and yet a moment of reflection shows that this type cannot be inhabited by a closed term. Indeed if A4 were an inhabitant of this type, then M would

34

A. Berarducci, M, Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

We tried to keep the non-constructive

features to a minimum

by condensing

them in

a rule that permits to assign the type i to any unsolvable term of order zero and in a standard (Eqg) rule . Our type assignment that if a type CI is assigned any environment model (Definitions

system (Definition

5.4) is sound in the sense

to a term M, then M will have semantically

in the closed term model A[, and more generally (3.3)).

It is important

to stress that it would not be sound to assign

[ to a solvable zero term XMI . . .Mk, because of xM, . . . Mk is not a zero term. We had to abandon

that type in

in every “adequate”

in some environment

the interpretation

any claim to capture exactly the closed term model (Goal 2)

after we realized that At suffers from some non-continuity

phenomena

which are dif-

ficult to take into account unless one introduces some infinitary features in the type assignment system. (This would not be sensible since the point of this work is to analyze the infinitary notions of the infinite il-calculus in terms of finitary notions like type, approximant, and deduction.) To illustrate the lack of continuity of the closed term model consider

the fixed point combinator

Y. It is easy to see that YY is an

unsolvable term of order zero, however we cannot detect this fact by looking only at finitely many approximants of Y. In other words application is not continuous in the topology induced by the approximants (Theorem 4.1). Of course, the term YY itself does not bother us since we have audaciously any unsolvable term of order zero. However,

introduced a rule to assign the type c to a slight variation on this theme shatters

our hopes to reach Goal 2. Consider instead of YY the term J_x.xYY. This is not an unsolvable term, but it becomes an unsolvable term of order zero if we apply it to the identity. Now it turns out that our types are so expressive that there is a type aI which in the closed term model /1{ is inhabited only by the identity I (Lemma 4.3). In /it the term &.xYY has type of + [, but none of its approximants has this type. So there is little hope to detect the presence of this type in any reasonable proof system, and certainly not in a proof system satisfying an approximation theorem (Theorem 7.5). We therefore abandon Goal 2 and content ourselves with Goal 1, the characterization of equality in the infinite A-calculus (Theorem 8.12), and Goal 3, the soundness and completeness (Theorem Ronchi

of the type assignment

9.2 1). della Rocca

[41] proves

system with respect to the adequate

a result

similar

to our Goal

models

1; more precisely,

that two terms have the same Bijhm tree iff they have the same set of types in the standard intersection type discipline [6]. The proof of [41] is based on the notion of principal type of an approximate normal form, which is a type completely describing the approximate normal form. Principal types (as defined in [ 1 l] and used in [41]) need an infinity of type variables and this agrees with the type syntax of [6]. Another related paper is [ 161, which proves that two terms have the same Levy-Long0 tree [34] iff they have the same set of types in the type discipline with union and intersection of [ 151. Also [ 161 uses the notion of principal types, but it gets rid of type variables by replacing them with suitable constant types which depend on the involved terms. We follow a similar approach with one important difference: in order to prove that inclusion between sets of approximants corresponds to inclusion between deducible

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999)

types we have to consider example

illustrating

not just

To prove the completeness

theorem

of order zero can arise dynamically checking

is unlikely

to introduce

one, but two principal

the need for two different types (Example

to control

(Goal 3) one difficulty in rather unforeseeable

this behavior.

in the type assignment theorem

(Theorem

35

We will give an

8.23). is that unsolvable

terms

ways, and a static type

To settle this problem

we are forced

system a rule that says that /Lconvertible

have the same types. To prove the consistency approximation

types.

29-75

of the resulting

system

7.5) to show by a purely proof theoretical

terms

we use the argument

that from a given basis r we cannot deduce two incompatible types for the same term (Theorem 7.6). So the deducible types form a filter. (This would be a consequence of the soundness of the assignment system if we already knew that the types of the basis r are inhabited in some model, but this is part of the completeness theorem, so we cannot use it yet.) Having proved that the deducible

types form a filter, it would

be natural to endow the set of filters with an application which makes them a model in which a filter has (semantically) exactly the types which are contained in the filter. But as we said, we did not manage to do this. Our proof of the completeness theorem relies instead on a term model. The idea is to enlarge the closed term model A{ in such a way that every type is inhabited. We do this by introducing a new constant for each type, and modifying

the b-convertibility

relation

in such a way that the constant

corresponding to the type c1 will indeed have that type, according to our semantics. The proof is inspired by [52, 191. We have seen that two terms are equal in the infinite ,I-calculus if and only if they have the same filter of deducible types in the assignment system. A natural question is whether this remains true if we replace the filter of deducible types with the larger filter of semantically deducible types, namely with the set of types which a given term has in the closed term model /i{ according to the given semantics. As we already observed, there are types which cannot be assigned to closed terms, for example

([ + (o + w)) A ((w + w) + [). So we would like to investigate

decidability

of type inhabitation

that the inhabitation

of intersection

for intersection-zero

types. Urzyczyn

types with variables

the

proves in [50]

is undecidable.

It should be clear from this introduction that the present work leaves many questions unanswered or in wait for more satisfactory answers. We hope that this will stimulate huther research towards the challenging goal of finding a flexible theory of filter models able to take into account the inner behavior of unsolvable terms.

2. Infinite A-calculus and approximants We assume familiarity with the ,I-calculus: is the set of terms generated by the grammar M ::= x 1(l..xM) 1(MM),

a standard

reference

is [6]. As usual ,4

36

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

where x ranges over a denumerable

set Vur of variables.

_4 but adding the clause that the constant denotes the set of free variables terms modulo

cr-conversion

+p

exactly as FV(M)

= 0. We consider

of bound variables). equality

up to renaming

for (one step) &reduction,

As usual for pure &calculus,

We define /i(l)

is a term. For any M E /1(L),

of M. A term A4 is closed iff Z?‘(M)

(renaming

Notation. We use = for syntactical for /?-conversion,

I

and -I;

of bound variables,

for multistep

we assume that application

associates

=B

/?-reduction. to the left and

we write for instance MNP instead of ((MN)P). If l - Li . . .L, is any (possibly empty) vector of terms, then ML = ML1 . . . L,. The expression J.x~ . . .x,&f is short for (L.x,.(. . .(/kqJ4). . .)). We will abbreviate some terms as follows:

kaxx

1dxy.xy

Ks7.xy.x

Y~~y.(kx.y(xx))(kc.y(xx))

A2d.x.xx A&x.xxx Q2cA2A2 S&EA3A3. We introduce

some notions following

[7]. The following

definitions

apply both to n(l)

and to A.

Definition 2.1. A zero term is a term which cannot term, i.e. to a term of the form ILc.M. Examples of such terms are S& and as. called terms of order zero.

Definition 2.2. A top normal form (t.n.f.)

be P-reduced

In [6, Definition

to an abstraction

17.3.21 zero terms are

is a term of one of the following

three

kinds: (1) a variable; (2) an abstraction

term J_x.M;

(3) an application

term of the form MN where M is a zero term.

It is easy to see that any B-reduct of a t.n.f. is again a t.n.f., and moreover it is a t.n.f. of the same kind. To see this it suffices to observe that if M is a zero term, then any fi-reduct of MN has the form M’N’ with M -+i Mt and N -+i N’. We say that a term has a top normal form if it can be reduced to a term in top normal form.

Definition 2.3. A mute term is a term which has no top normal form. For instance fiz is mute. The /-I-reduction C&s--+F C&A3shows that the zero term 52s has a top normal form and therefore it is not mute. These notions are not constructive: there is no algorithm to test whether a term is a zero term.

A. Berarducci,

AI. Dezani-Ciancaglinil

Theoretical

Computer

Science 212 (1999) 29-75

31

Fig. 1.

Definition 2.4. A strong zero term is a zero term M such that every instance

substitution

of M is again a zero term.

Clearly, a closed term is a zero term iff it is a strong zero term. A variable term but not a strong one. More generally

is a zero

it can be shown that M is a strong zero

term iff M is a zero term and M cannot be P-reduced to a A-free head normal form, i.e. to a term of the form xM1 . . . M, where x is a variable [7, Definition 11.7, Lemma 11.81. Thus, M is a strong zero term iff M is a zero term and M is unsolvable. [34] strong zero terms are called terms of proper order zero. Definition 2.5. We identify tree with binary application

In

terms with their parsing trees. So a term is a finite rooted nodes ?jiJ”, unary abstraction nodes “AX” (where x is any

variable), and leaves labeled by a variable. An injinite term is defined in the same way except that trees are allowed to be finite or infinite, and leaves are labeled by a variable or by the constant 1. The infinite

terms include

as special

cases the finite ones. We will see that the

constant J_ plays the role of a generic mute term to which all the others will be identified. Unlike what happens in the theory of Bijhm trees, in the infinite ,?-calculus, h. _L and IM are not identified. Infinite terms arise in a natural way as “limits” of infinite sequences of B-reductions if we try to compute top normal forms hereditarily. So if we start with fis we obtain I,

the top normal form S&A3 and continuing in the same fashion we generate the infinite sequence of P-reductions Rs +i &A3 --+i;&A3A3 -i, etc. It is natural to take some kind of limit of this process and to set @ 4oo . . . A3A3A383 (infinitely many As’s). In tree-form, it is represented as shown in Fig. 1. The infinite term on the right is a normal form because it has no /I-redexes (i.e. subterms of the shape (J_x&QN). It is called the infinite normal form of Qs. Among infinite terms we have both a notion of finite P-reduction --+i (defined in exactly the same way as for finite terms), and a notion of infinite P-reduction +03 defined as follows. Given two infinite terms M and N, we say M ES,,N if the treerepresentations of M and N coincide up to height n. This notion is slightly ambiguous since it is not invariant under a-conversion, however it can be made precise by

38

A. Berarducci,

identifying

M. Dezani-Ciancaglinil

Theoretical

terms with their representation

be a sequence

of infinite

Computer

Science 212 (1999) 29-75

using de Brujin indexes [lo]. Let (/Vi Ii > 0)

terms. We say lim(k&) = M if A4 is an infinite

term, and

VnWm > i M, E, M.

Definition 2.6. Let s : ii40 +o Ml +p I& +p A43 +p . . . be an infinite sequence of We say that s converges to the infinite term A4 if

P-reductions.

(1) A4 = lim(Mi); (2) the depth of the redex reduced in Mi +b kIi+r tends to infinity with i. 2 We now define M +oo N (injinite B-reduction) if and only if either M -i there is an infinite sequence The next

example

of reductions

shows

starting from M and converging

that the Church-Rosser

property

fails

N or

to N.

for infinite

p-

reductions.

Example 2.7. (Berarducci ;;

I +B I> --+m WW(...)))) d* d* ? +B Ah -‘p A2A2 . . . +fi

* AA

[7]) Let Q E hz.I(xx). We have the reductions

but there is no reduction,

whether finite or infinite, from I(I(I(I(. . .)))) (infinitely

many

I’s) to A2A2. The term QQ responsible for the failure of the Church-Rosser property Mute terms are the only responsible for the failure of the Church-Rosser

is mute. property

in the sense that if we send all mute terms to I, then the Church-Rosser theorem is restored. To state this fact precisely, let us first observe that the notion of zero term, strong zero term and mute term extend to the infinite ;l-calculus with the same definitions. So, for instance, a zero term is an infinite term M such that there is no l.xP. Actually it does not matter whether in jinite p-reduction of the form M -i the definitions we use finite or infinite P-reductions. This depends on the fact that if M -+a N and N is a zero term, then M is also a zero term. (When N is a normal form this is proved in [7, Lemma 9.31. The general case follows easily.) According to the definitions I is a mute term, since it can be reduced neither to an abstraction term, nor to a zero term applied to another term. Following [S, Definition 3.1.11 we say that a reduction relation on the set of terms is a reflexive and transitive binary relation R which is compatible in the sense that (F,F’) E R implies (FG,F’G) E R, (GF, GF’) E R and (Ax.F, AxF’) E R.

Definition 2.8. Define a I-redex least reduction

relation on /i(l)

as a mute term different from 1. Define +I as the which sends all the mute terms different from I to 1.

2 The depth of an occurrence of a subterm P of M is the distance in the tree-representation of M.

from the root of P to the root of h4

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer

Define -+bI and +l.Now

Science212 (1999) 29-75

39

as the least reduction define -‘ml

relation on n(i) which contains -+B (/?-reduction) instead of --+b. exactly as -+03 but starting from +bl

We define -+~~* as the transitive

and reflexive closure of -PI,

lence relation generated by -+BI, =ml

as the equivalence

=bl

as the equiva-

relation generated by +m~r

etc.

Theorem 2.9. -+ml is transitive, it has the Church-Rosser property, and every term M has one and only one normal form with respect to do31 The above theorem

reductions.

was proved in [7] only for infinite terms M arising

ones (which is the form in which we need it). A proof for the general found in [30]. We also need:

Theorem 2.10. (Berarducci

from finite case can be

restricted to finite terms (i.e. to A(l))

[7]) +pl*

has

the Church-Rosser property.

Definition 2.11. The infinite normal form (ooI-normal normal

form) of the term M is the

form of M with respect to -+ool.

In [7] the infinite tree of M is the parsing tree of the infinite normal form of M. We modify this representation in case of variable applications, following the convention BGhm trees. since this simplifies our definition of the sets of approximants.

Definition 2.12. The infinite tree F(M)

of the term M is defined by cases as follows:

if M -+i xN1 . ..N.,, (M 2 0), then:

9-(N,) ifM+E

...

Jx.N, then: F(M)=

ifM+;

of

A.x

NP, where N is a strong zero term, then:

yW,n)

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

40

otherwise:

The fact that the infinite

tree of a term is well defined, namely

on the choice of the reductions of the infinite between

normal

-+i involved

in its definition,

form of a term (and the obvious

it does not depend

follows from the unicity

one to one correspondence

the infinite trees and the infinite normal forms).

Remark 2.13. A4 =ml or equivalently

N if and only if M and N have the same infinite normal form,

the same infinite tree.

Remark 2.14. From the equality

it does not follow that M -i

NP. However it does follow that we have a reduction

M -+i N’P’ with Y(N’)

= Y(N) and F(P’) = F(P). In fact, any reduction from M to a top normal form will work (by the unicity of the infinite normal form). A similar remark applies to the other cases in the definition of the infinite tree.

To study the infinite I-calculus we introduce a notion of “approximate normal form”. Approximate normal forms arise naturally by pruning infinite trees. Notice that the left son of a @-node must always be a tree representing a strong zero term, while in all other positions we can have trees representing arbitrary terms. So we add two constants to A, the constant Q which approximates all terms and the constant I which approximates

all strong zero terms.

Definition 2.15. The set ~2 of approximate normal forms is defined

inductively

as

follows: (1) QEd, (2) if A E LX!,then kx.A E d, (3) if A,,..., A,, E d, then xAl . .A, E d

and IA,..

.A, E d (~~20).

The definition of infinite tree easily extends to approximate terminal nodes labeled 52. Definition 2.16. The relation (1) (2) (3) (4)

5 is the least preorder

Q;2A; ..l 5 J-A; if A 5 A’, then ;Ix.A 5 Lx.A’; ifAi5Aifori=1 ,..., n,thenxA~...A,dxA{...A~

normal forms by allowing

on &, such that

andLAi...A,~IA’,...A~.

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

We want to consider

approximate

normal

forms obtained

by cutting infinite trees at

some level n. The first guess would be to replace all internal but this does not work because are not approximate arbitrary

normal

41

nodes at level n with 52

we may end up with objects of the form G?A, which

forms. Roughly

nodes. The exact definition

_L replaces

@-nodes,

while

Q replaces

is the following.

Definition 2.17. Let M be either an approximant or a term. The n-th upproximant (M)” of M is the approximate normal form defined as follows. (M)O = 52.

(M)n+’ = x(N1) . . . (N, )” (m 3 0), whenever:

(M)n+’ = h.(N)“,

whenever: 9-(M) =

(M)’ = I and (M)nf2 = (N)n+‘(P)“+‘,

Ax

whenever:

(M)n+r = I, whenever:

(A!)“+’ = s2, whenever:

We say that M and N coincide on the jirst n levels if (M)” s (N)“. It is easy to check that (AI)” E (N)” implies A4 --n N, while the vice versa is not true, since for example x11 ~1 yI1 (because in the parsing trees of x11 and yI1 the variables

x, y have depth 2) and (x11)’ E x5252,(~11)’ E yQ52.

42

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

Example 2.18. The n-approximants qA.X.Q)(LX.XQQ)

of Sk3 for 12= 0,. . . ,4 are: 52 3 I 3 I(,k

Q) 5

5 .L(kQ)(J..X.x~Q)(A.x.x).

The set of approximants

of A4 is the closure under 5 of the set of all terms of the

form (M)” for all n.

Definition 2.19. The set d(M) d(M)

of approximants of M E A is defined by

= {A E d 13n.A 5 (M)“}.

For example, the term x(C&I)(II) has the following x(l.I)I 5 x(.lA31)I 3 x(_LA3AsI)I 3 . . . .

Lemma 2.20. The set d(M)

approximants:

fl 3 XQQ 3

is an ideal, i.e. it is downward closed and directed with

respect to 5.

Proof. d(M) is downward closed by definition. Notice that (M)” 5 (M)n+’ for all iz. 0 The fact that &‘(M) is directed for all M follows easily. It is easy to verify that the sets of approximants

characterize

the mute, strong zero

and zero terms.

Lemma 2.21. (1) A term M is mute ifs d(M)

= {I, 52).

(2) A term M is strong zero zff I E d(M). (3) A term M is zero ifs 2~22 9 d(M).

Proof. Clearly Sz E d(M)

for all M. Now if M is a mute term, i.e. a term without

t.n.f., we have that its infinite iff its infinite

(M)’ E 1. ,4.x.52E d(M) term.

tree is just a root labeled

tree is just a root labeled

I

1. M is a strong zero term

or starts with a @-node.

iff the root of Y(M)

In both cases

is labeled AX, and so M is not a zero

0

Lemma 2.22. Let M E A. If A E d(M)

and A k (M)“, then (A)” s (M)“.

Proof. By induction

on n and by cases on Definition 2.16. The most interesting case is (M)” G I and A E IB. If IB E J&‘(M) then M =p PN for some P,N such that P is a strong zero term. (PN)” - I implies IZ= 1 and (LB)’ - 1. 0 It is clear that the sets of approximants terms.

characterize

the infinite

Theorem 2.23. M =co~ N if and only if &f’(M) = S@‘(N).

normal

forms of

A. Berarducci, M. Dezani-Ciancaglinil Theoretical Computer Science 212 (1999) 29-75

43

3. Intersection-zero types and models of the I-calculus By model of I-calculus

we mean a I-algebra

in the sense of [5]. We quote Barendregt

[5, pp. 86-871: “It took some time after Scott gave his model construction on the general

notion

history. Presently

of a model of the d-calculus.

one considers

for consensus

See Koymans

two kinds of models, viz. the l-algebras

models. The A-algebras satisfy all provable equations

to arise

[ 19821 for the and the 1-

of the A-calculus and form an

equational class (axiomatized by kxy = x, sxyz = XZ(JJZ) and the five combinatoty axioms of Curry). Therefore the J-algebras are closed under substructures and homomorphic images. The A-models on the other hand satisfy all provable equations and moreover the axiom of weak extensionality V.x(Mx = Nx) + 3x.M = J.x.N. It turns out that I-models can be described by first-order axioms, but not by equations. Indeed I-models are not closed under substructures nor under homomorphic images.” Then Barendregt

continues:

“In spite of not being weakly extensional, e.g. precomplete

numbered

So we feel justified

I-algebras

are worth studying;

they are

sets in the sense of Ershov, see [Visser [1980].”

to use A-algebras

rather

than i-models

in the proof

of the

completeness theorem (of course with a larger class of models it is easier to prove a completeness theorem). It should be remarked that the so called “closed term model of the @-calculus”, is a l-algebra and not a 12-model. The model that we will construct to prove the completeness theorem for our type assignment system is in fact very similar to the closed term model. We give now the precise definition interpretations”

of Hindley

of A-algebra using the approach of the “syntactical

and Longo (see [5, Definitions

5.3.1 and 5.3.21). 3

Definition 3.1. A l-algebra is a triple (A, ., [ I&) where &! is a non-empty the domain of the model, is an interpretation

. is a binary

operation

map which associates

on J

set called

called application and [ ]A

to every term M E A and every mapping

s : Var -+ J&‘, an element [Ml,” E A, called the interpretation of the term M in the environment s, in such a way that the following axioms are satisfied: (1) Irxn,” = s(x); (2) MN],” = IMII,“.

Wlf; (3) O[~Ml~ . a = lWll$ix~ where s(a/x) is the environment which coincides except that it associates the value a E JZ? to the variable X; (4) if s and s’ coincide on the free variables of M, then [M],” = EM],!; (5) if M =B N, then for every s we have [Ml,” = [NJ,“.

3 There is a very simple definition of I-model due to Meyer [36,20, Definition not adequate for our purposes since we are interested in I-algebras, not &models.

with s

11.221,which however is

44

A. Berarducci,

44. Dezani-Ciancaglinil

Theoretical

The first four axioms plus the invariance

Computer

Science 212 (1999) 29-75

of the interpretation

under a-conversion

are

the axioms of the syntactic interpretation, the last one is the characteristic

axiom of

the A-algebras. It expresses the fact that a A-algebra satisfies all the provable

equalities

of the @-calculus The notion

(for every interpretation

of l-model

is obtained

for every a E A,

of the free variables).

by adjoining

the axiom ([)

which says that if

In presence of the @%&) = ~Nl$,X) axiom (

Suggest Documents