FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the...

34
Rend. Sem. Mat. Univ. Poi. Torino Fascicolo speciale 1987 Logic and Computer Sciences, (1986) Giuseppe Longo FROM NUMBERED SETS TO TYPE THEORIES Introduction The topic of this lecture concerns just one of the many interactions between Mathematical Logic and Computer Science, as it is now a common opinion that Mathematical Logic has found in Computer Science its field of applica- tion. Among the various aspects of Logic relevant to Computer Science, Type Theory and X-calculus, which are strictly related matters for the first is mostly intended, nowadays, as the theory oftypes of X-terms, play a major role for at least two reasons. Firstly, the depth and beauty of the Mathematics involved. This area has old roots in Logic, which go back to Russell's Theory of Types and to the work of Church, Kleene in the thirties. Moreover, that pionering work has been later pursued, in the specific area of X-calculus, by a very large scientific community which enriched the subject with a great number of relevant results. Probably, X-calculus, among the various formalisms for computability suggested in the thirties, is the only one with plenty of interesting "machine dependent" results: one should consult Barendregt [1984] in order to appre- ciate the variety and depth of the work carried on in that specific formai system. The point is that, more than a formalization of a "computing device" or a toy programming language, X-calculus is and has to be viewed as the forma- lization of the abstract notion of function for the purposes of the foundation of Mathematics. Indeed, this is what Shoenfinkel, Church and Curry aimed Work partially supported by Min. P.l. (Fondi 40 §)

Transcript of FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the...

Page 1: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

Rend. Sem. Mat. Univ. Poi. Torino Fascicolo speciale 1987 Logic and Computer Sciences, (1986)

Giuseppe Longo

FROM NUMBERED SETS TO TYPE THEORIES

Introduction

The topic of this lecture concerns just one of the many interactions between Mathematical Logic and Computer Science, as it is now a common opinion that Mathematical Logic has found in Computer Science its field of applica­tion. Among the various aspects of Logic relevant to Computer Science, Type Theory and X-calculus, which are strictly related matters for the first is mostly intended, nowadays, as the theory oftypes of X-terms, play a major role for at least two reasons.

Firstly, the depth and beauty of the Mathematics involved. This area has old roots in Logic, which go back to Russell's Theory of Types and to the work of Church, Kleene in the thirties. Moreover, that pionering work has been later pursued, in the specific area of X-calculus, by a very large scientific community which enriched the subject with a great number of relevant results. Probably, X-calculus, among the various formalisms for computability suggested in the thirties, is the only one with plenty of interesting "machine dependent" results: one should consult Barendregt [1984] in order to appre-ciate the variety and depth of the work carried on in that specific formai system.

The point is that, more than a formalization of a "computing device" or a toy programming language, X-calculus is and has to be viewed as the forma­lization of the abstract notion of function for the purposes of the foundation of Mathematics. Indeed, this is what Shoenfinkel, Church and Curry aimed

Work partially supported by Min. P.l. (Fondi 40 §)

Page 2: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

42

at. The connections which relate X-calculus to Proof Theory (from Godei [1958] to Troelstra [1973], Martin-lòf [1975], Girard [1972], where types are viewed as formulae), to Category Theory (see Lambek & Scott [1986]) and to higher type Recursion Theory (Godei [1958], Scott [1970]) confirm the program of the founders, even if, probalbly, from different perspectives.

Secondly, Functional Programming is one of the two or three major pro­gramming styles, today, and the practical success of functional languages is due to their suitability to solve or focus many of the concerns of actual computing. Indeed, X-calculus is the core of functional languages-, thus, the investigation of its theoretical extensions or its mathematical semantics sug-gested consistent enrichment of extant programming languages or the design of new ones. Edinburgh programming language ML , among others, was greatly influenced by the work in semantics initiated by Scott and Strachey (Milner [1978], Gordon & al [1979], Milner [1986]). Even compilers are nowadays built up with some use of model theoretic concepts of X-calculus (Jones [1980]). Moreover, its theories of types have served to organize the study of type disciplines in programming and are now implemented in several running languages. By this, they provide, say, effective and significant partial correctenes proofs, comparable to "dimension analyses" in Physics (Milner [1978], Nordstrom [1981], Burstall & Lampson [1984]Constable&al [1986]). These investigations and their applications lead to new insights into a poly-morphism, modularity and abstraction (MacQueen [1986], Reynolds [1983]).

Under the motto "types as formulae'' (see §4), Type Theory greatly in­fluenced automated theorem proving (de Bruijn [1980], Constable& al [1984], Miller [1984], Coquand & Huet [1985]) and it even serves as a knowledge representation language for AI (Turner [1984], Constable & al' [1986]). The other motto, "types as objects", summarizes instead several connections with Category Theory (see §3 and Lambek & Scott [1986]); surprisingly enough, even these very abstract studies influenced programming, since the equations mentioned in §3 have become the core of a running machine (Cousinau&al[1985]).

Our claim is that the practical relevance for computing of X-calculus and Type Theory, goes together with the variety and depth of the Mathematics involved, in particular with those results which relate this topic to other areas, as those mentioned, since the richness of the theory directly embeds into the expressiveness and the facilities of actual programming laguages.

As Mathematics is relevant when it is both beautiful and applicable, I think that the founders should be content with ali of this.

Page 3: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

43

This introductory lecture will stress a recursion theoretic and constructive perspective (in the sense of Intuitionistic Logic) as structures invented for the semantics of typed and type-free X-calculus will be looked at within a constructive frame. In particular, we will view at Scott's constructive domains as countable (and numbered) sets, in the sense of Malcev, §1; then "subcoun-table" and stili effective sets will be investigated, §2. The formalization of these structures, §3, will lead us to higher order type theories, §4, and, finally to their (constructive) models, § 5. Several issues sketched here will be revisited and expanded in Longo [1987].

1. Constructive Domains as Numbered Sets

There is a naturai generalization of classical -Recursion Theory: instead of taking just the set co of naturai numbers and the set R of the Recursive Functions on co, consider computability on arbitrary countable (and num­bered) sets and suitable transformations between them. The idea is that, in­stead of dealing only with numbers as data, one way may compute with various types of data by working with numerical codes for them. This is the core of Malcev's definition of the Category EN of Numbered Sets (or Enu-merations).

1,1 Definition. The Category EN hasas objectspairs A = (A, eA), where A is a set and eA : co -> A is an surjective map.

Morphisms are defmed by f€EN [à, B] if 3f E R / o eA = eÈ o f .

Clearly, EN is indeed a category and it has several interesting (closure) properties. For example, one can look at the product of two numbered sets as a numbered set itself : just enumerate the product by using some bijective coding of pairs of numbers. However, as we are interested in higher type computations, i.e. functionals with (codes for) functions as inputs, one may ask whether also other kinds of higher type objects, such as exponents, are available in the category. Unfortunately, there is no "acceptable" way to enumerate the set of morphisms of two arbitrary objects in it, if accepta­ble means that products and morphisms spaces commute in the sense of

Page 4: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

44

Cartesian Closed Categories. Consider, say, co = (co, id). as a (trivially) numbered set. Then, EN[OJ, co] = i?, the recursive functions. This is surely a countable set, but for no enumeration eR and R = (R, eR ), one has EN [co X co, co] = EN [co, R], as eR itself would be an effective enumeration of /?, which is impossible; or, if preferred, the "uncurrying" u of eRl

u (n, ni) = eR (n) (m), would be a computàble universal function for R .

One may think of two main ways to preserve the effective flavour of the category EN and obtain the required closure properties which guaranty the existence of higher type objects in the category: the first is to look inside EN ", the other is to extend EN in order to to get Cartesian Closure without loosing the simplicity of this category.

Scott and Ershov suggested a way to stay inside EN . Scott's motivation was the construction of mathematical structures where one could interpret languages for computer programming. Ershov, partly following earlier work of Scott, wanted to relate in a unified mathematical framework the ideas of Kleene and Kreisel for Higher Type Recursion Theory, a topic in turn

motivated by the semantics of Intuitionistic Logic (see Scott [1970 , 1972, 1976, 1982], Ershov [1976]; surveys may be found in Smith [1977], Longo [1979], Giannini & Longo [1984] and many others).

The interesting point is that both authors used, in some essential way, topologica! properties in their work. That is, some numbered sets are picked up according to some extra structure they can be given, based on a topo­logical notion of convergence (approximation). The idea is, given a poset X , to generalize first some key properties of finite sets to a subset X0 of X and use X0 in order to approximate arbitrary elements of X.

Given a poset (X, <) and x, y G X , write x ti y (x and y are compatible in X ) for: there is z E X such that x < z and y < z . Two subsets A and B of X are cofinal if VaGASbGB a^b and VbEB3aeA b<a.

1.2 Definition. Let {X, X0, < ) be a poset, with X D X0 . Then (X, X0, < ) is a fìnitary posed ( f-poset) if

(1) for directed subsets A, B of XQ

supA = supB =» A and B are cofinal

Page 5: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

45

(2) vxex3x0 e x0 XQ ^ X

(3) Vx,yeX(~(x<y)s*3z0eX0z0<x and ~ (z0 <y))

(4) Vx0,y0eX0 (x0$ y0=*3zQeX0 z0=sup {x0,y0}).

(Notation: for x £ X, *x= {x0 G X0 Ix0 < x }, t# = {z £ X I # < z } ) .

1.3 Defìnition. Let X = (X, X0, <) fotf» f-poset. The Scott topology T$

on X isgiven by the base {t#0 l#o e ^o }•

1.3 is a good definition, by 1.2 (2) and 1.2 (4) which requires that elements of X0, compatible in X, have a least upper bound in X0. Thus, one also has that, for each xGX, *x is directed.

1.4 Proposition. Let X = (X, X0, <) be an f-poset and x G X . Then

(1) x = sup*x and r is a T0 topology,

(2) / / x E X0 then, for ali directed subset D of X, x < sup D =• =*3dGD x<d.

Property (2) in 1.4 is a "compactness" property for the elements in X0 . In generalizes a simple fact which characterizes the finite sets in any pòwerset, partially ordered by set inclusion. By this the elements of X0 are some-times called "finite". We prefer to refer to them as "compact" of "noetherian" (see Remark 1.9 below). The familiar Scott domains are exactly /-posets which contain ali sups of directed sets.

The point now is to obtain countable and, possibly, enomerated sets. This will be done by first enumerating X0 in such a way as to preserve the effectiveness properties one would expect from any canonical enumeration of finite sets.

1.5 Definition. Let (X, X0, e0, <) be an f-poset and e0 : co-^X0 (bijec-tive). Then (X, X0, e0, <) ìsan effectiveposet if

(1) e0 (n) ft e0 {ni) is a decidable predicate

(2) 3gGR Vn,m(e0(n)$e0(m)=>e0(g(n,m))=sup {e0 (n),e0 (w)}).

Page 6: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

46

1.5 (2) says that the least upper bound of finitely many compatible elements of X0 can be uniformly effectively found. Thus, one also has that, for *o> yo e Xo > x o ^JKo 1S decidable (in the indices).

The assumption in 1.5 that e0 is bijective, may be weakened to surjecti-vity and VxQGX0 {n/e0 (n) = x0} is recuisive (or e0:ù)'-*X0 is bijec­tive on an initial segment of co' of co). By this, also finite effective posets would be considered. The remaining properties similarly hold.

1.6 Definition (Constructive Domain). An effective poset X = (X, X0, e0, <) is a Constructive Domain iffor any directed subset D of X0 one has:

supD existsin X iff {n/e0(n)€.D} is a recursively enumerable set.

Observe then that any (constructive) domain X has a least element 1^ , say, as tf> is directed. A typical constructive domain (which is not a Scott domain) is the set RE of recursively enumerable sets, with the finite sets as compact elements. In general, constructive domains may be understood as "effectively complete" partial orders, for exactly the directed sets which can be recursively enumerated have a least upper bound. By this, one can easily and effectively enumerate the entire poset X , i.e. one may define canonically a suriective map e : co -+ X by using the properties of e0 in 1.5 (1-2) (see Giannini & Longo [1984], for details). Clearly, e doesn't need to be injective. Take for example the constructive domain (PR, PR0, <A>> ^) °f t n e partial recursive functions: in this case the compact elements, PR0 , are given by the functions with a finite graph, enumerated in some canonical way, <p0 > say. Then <p : co -• PR is just an (acceptable) gòdel-numbering. The same applies to the domain of r.e. sets.

Thus, from now on, we consider each constructive domain X also a num-bered set (X, e) , where e is derived from e0 as mentioned. However, any such numbered set X happens to have some "structure", the partial order and the topology, which nicely relate by

VxfyeX(x<sy^=^(yAeTs xEA=>yEA)).

Moreover, these "geometrical" tools define the usuai set of continuous functions; they tern out to be exactly the monotone functions which commute w.r.t. to sups of directed sets, when they exist.

Page 7: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

47

As usuai, the continuous functions can be partially ordered pontwise. Some continuous functions are more basic than others: considér, say, for x0 G X0

and y0 e Y0 ,

step#0 yo 0*0= if x0 <:X then y0 else l y

By taking the sups of finite collections of compatible "step" functions, one obtains a countable collection of continuous functions, Cont (X, Y)0

say. An enumeration e' of Cont (X, Y)0 can be easily (and canonically) given by using e0 : co -* X0 and ex :co -• YQ . Define then

Cont (X, Y)c = { / e Cont (X, K)/{»/*' (n) <f} is r.e.}.

It is not difficult then to check the following.

1.7 Lemma. / / X = (X, X0, e0, <) and Y = (Y, Y0, elt <) are costruttive domains, then (Cont (X, Y)c , Cont (X, Y)0, e', <) is a Constructive Domain.

1.8 Theorem. The categòry CD of Constructive Domains, where morphism are defined by CD [A, B] = Cont (A, B)c, is Cartesian Closed.

(Notation: BA is the exponent object, which internally represents CD [A,B], in accordance with the categorica! use.)

The lemma and the theorem essentially prove that the "compactness" and "effectiveness" properties of X0 , in a fixed constructive domain X , are inherited at higher types: this is obvious for cartesian products (and implicit in 1.8), hints were given for the construction of the compact elements in function spaces. As already mentioned, "compactness", as given in 1.4 (2), characterizes the finite elements in any powerset, another characterizing pro-perty of finite sets (or of functions with finite domains) is lost at higher types:

1.9 Remark. In any powerset (or subposet of it), exactly the finite sets have fìnitely many subsets. Nothing similar happens for the compact elements of an arbitrary effective poset. Indeed, take a constructive domain X1 with an infinite collection on incompatible elements or with an infinite ascending chain, and set X"+ 1 =CD [X", X"]; then, for any n>\ and * 0

G (**)o>

Page 8: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

48

*#0 is infinite. This can he easely understood, by observing that any step function stepab is antimonotone in a .

Recently, Girard [1985] suggested to consiier a subcategory of Scott's domains, the qualitative domains, made out ofsitbsets of powersets and where only some continuous functions are morphisms: the "stable" functions, which preserve also finite intersections of compatible elements As an elegant conse-quence, one then has that in any type each compact element x has a finite *x . Stable functions originated in Berry [1979] and bave some deep connec­tion with Girard's ideas in Proof Theory, as bis dilators similarly preserve pullbacks (see Girard [1986]); moreover, an insight is also given into sequen-tiality, as stable functions are strictly sequential

As already mentioned, every object in CD is a numbered set; thus CD is a subcategory of Malcev's EN . The point is to understand how the defini-tion of morphism in EN , which is so tidely efféctive and is only based on the recursive functions, and morphisms in CD , which are particular conti­nuous functions, relate.

In should be clear by now that the role of continuity comes in quite smoothly from considering a functional / to be computable when it computes with compact approximations (which are finitely coded) of its possibly infinite) input: f (x) = sup { f C x) }. Moreover, / itself is the limit of its compact approximants in its own type.

The next lemma clarifies how Geometry and Recursion Theory relate over constructive domains.

Given a numbered set (X, e), observe first that the set {A CX/e'1 (A) is r.e.} satisfies the requirements for a topological base. Cali the induced topo-logy the Malcev-Ershov topology.

1.10 Lemma (Generalized Rice-Shapiro Theorem). Let X = (X, X0, e0, <) be in CD . Then the Scott topology on X coincides with the Malcev-Ershov topology on (X, e) .

A proof of this fact may be found in Giannini & Longo [1984] or in Roso-lini [1986]. In the latter, the discussion is carried on in a sound categorical setting, by considering categorical models of Intuitionistic Logic. This exibits also the connections to the constructive aspects of the metamathematical frame: for example, the proof of 1.10 is intuitionistically acceptable provided that Markov principle is considered (see Beeson [1980]).

Page 9: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

49

From the lemma one may easily derive a precise connection between con-tinuity and effectiveness for functions. Namely, that the morphisms between (X, e) and (K, V ) as constructive domains, which are continuous maps, coincide with the morphisms between (X, e) and (K, e') as numbered sets, which are recursive functions over indices:

1.11 Theorem (Generalized Myhill-Shepherdson). CD is a full subCartesian Closed Category of EN. x

(Proof of the key point: Let X, Y G ObCD CObEN and fGEN [X, K]; then / is continuous by the lemma).

The relevance of these facts is based on the naturalness of the partial order on effective posets and, thus, of the topology: these are not defined "ad hoc" for the purposes of 1.10 or 1.11, but come out of obvious generaliza-tions of set inclusion.

CD has further interesting properties, which do not hold in EN : for example, CD is closed under inverse limits and limits are also preserved by the product and exponentiation functors. By this, say, one may easily construct countable models of the type-frée X-calculus, as there are objects in CD which satisfy equations such as X s Xx (see Kanda [1979], Smith & Plotkin [1982], Giannini & Longo [1984]).

2. From countable to subcountable sets

The basic idea in the definition of the subCategory CD of EN was the choice of some structured objects in EN which could form a sufficiently rich category, with enough closure properties as for the purposes of higher type computations.

As pointed out in §1, there are many countable sets which cannot be soun-dly enumerated in the category EN\ as an example we mentioned the set R of the total recursive functions. In a sense though, one may say that R , even if not (effectively) countable, is "subcountable", i.e. it can be (effectively) enumerated by a subset of co .

The second idea one may think of, then, is to enlarge the category EN

Page 10: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

50

as to include this sorts of eponents (function spaces). Observe first that any numbered set defines an equivalence relation on

co (and, thus, a quotient of co ) and, conversely, any equivalence relation on co uniquely determines a numbered set: just set to be equivalent any two numbers which code the same element and viceversa. Indeed, from now on, any numbered set A = (A, eA ) will be equivalently referred to as a quotient A of co , where

n A m iff eA (n) = eA (m).

Clearly, given numbered sets A and B , not any / ' G R induces an /€E EN [A, B] , as / ' must preserve v4-equivalences: that is one must have n A m =* f (n) Bf ' (m) . This suggests a way to introduce higher type objects and thus to define a cartesian closed extension of EN.

Let { ^ } | e a , be an acceptable goedel-numbering of PR . Define then

(Quot.) pBAq iff nAm=*y (n)B<p (m). (ipp,<pq defined on n s.t. nArì).

AB is a partial equivalence relation on co , as it is defined on a subset of co . Indeed, for A, B non trivial, dom (BA) = {p/pBAp}¥= co , and a partial numbering (i.e. a partial surijective map) irA B : dom (BA ) -*• BA

is given by TTA B (W) = {m/nBA m}. Of course, dom (71̂ ) = dom (A). In general, each partial surijective ir : co -> C uniquely defines a partial

equivalence relation (and conversely). It may be fair to cali these new objects "modest", as suggested by Scott, as they are just and simply (quotient) subsets of co .

2.1 Definition. The category M of partial equivalence relations on co (the modest sets) has as objects the subsets of co modulo an equivalence relation. Given objects A = (A, nA ) and B = (B, nB ), where irA, irB are partial numberings, the morphisms are defined by

fEM[A,B] iff f'EPR dom( / ' ) ! ) dom 04) and / o rrA = irB o / ' .

Note that the representative BA of M [A, B] is partially enumerated by the quotient subset of co determined by the partial relations BA (see

Page 11: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

51

(Quot.) above). That is,

«AB W = / i ff f°nA= *B°*Ì •

By this, one obtains, for example, a partial, but effective, enumeration of R = cow by a surijective map defined on a subset of co .

2.2 Theorem. M is a CCC and includes En asafullsubCartesian Category.

Indeed, on may prove, by using also 1.11, that the full and faithful embed-dig from CD into EN and, then, into M is such as to preserve products and exponentiations from CD into M.

M is a naturai generalization of the Hereditary Extensional Operations (HEO) in Troelstra [1973], where they are introduced for the purposes of Intuitionistic Logic and its Proof Theory (see also Girard [1972]).

In Computer Science, M is also known as the quotient set semantics of types over co , following the ideas in Scott [1976] on X-models (see also Hindley [1983], Coppo [1984], Longo & Moggi [1986] for details and further work on arbitrary (partial) combinatory algebras).

Remark. Observe that PR and R are enumerated in M in entirely different ways. As mentioned in several placès, R does not live in CD, while PR cannot he enumerated as an object of M by similar tricks as hinted for R : the maps in PR are partial, while we are looking at catego-ries with total maps as morphisms, as usuai (see 2.1). The idea is to extend co to co1 in CD by adding a least, undefined, element 1 and enumera­te co1 following the procedure sketched for constructive domains (see after 1.5; 1 , say, turns out to be coded by the complement of an r.e. non recursive set (see Asperti Se Longo [1986] for details)). This is required, quite generally, for the sake of 1.10 and also given the functorial embedding of CD into M which preserves products and exponents. More on this may befound in Longo [1987].

Page 12: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

52

3. The formai theory of functions

In §1 and 2 we have been looking at mathematical generalizations to higher types of the notion of function on a ground type of data. This was done on contable sets, because of the foundational motivations for constructive aspects of Logic and for Computer Science we assumed. Moreover, that work has some mathematical relevance in view of the new structures and the general frame proposed. It may be then the case to formalize in a theory of functions the key properties we deal with.

Functions may be bases on three main notions: application, abstraction and tupling (in order to handle several arguments functions). That is,

(App) - apply a function / to an argument a: write f(a)

(Abs) - abstract a function from an expression f(x), possibly depending on a variable x : write \x. f(x) ,

(Pair) - construct a pair from elements a, b : write (a, b).

These notions need now to be formalized and typed. Let then At be a set of atomic type symbols and let Type be the least set containihg At and such that:

or , r € Type => o-^r, aX T € Type .

3.1 Definition (Typed \-terms). xa (variable of type a)

(Ma~*T N°)T

(hca.MT)o-*T

(Ma,Nr)aXT

fst(MaXT)a

snd(MaXTV

Page 13: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

53

3.2 Defìnition (Typed \-calculus with surjective pairing). The axioms of

mspt : (p) (\x° .MT)N° = [Na/xa] M'­

ir^) XK° . Mr xa =Af

(fst)fst(Ma, A T ^ A T

(snd) snd(Ma,NT) = Nr

(SP)(fst(MaXT)isnd(MaXT))=MaXT .

The inference rules for X/3T?5Pf are exactly what is needed to turn " = " into a congruence relation. The next theorem sets some mathematical base to the claim concerning the relevance of Xj3r?5Pt as a theory of functions.

Category Theory is often considered the alternative functional foundation for Mathematics, w.r.t. Set Theory, as functions are first described and sets, if needed, are a derived concept. In particular, the theory of Cartesian Closed Categories, which deals with function spaces, seems a sound setting for func-tionality. The next theorem proves that we may view types as objects, in the sense of Categories.

3.3 Theorem iTypesras-objects). The models of \firiSPt are exactly the (concrete) CCC's.

This result may be found in Lambek [1980], Scott [1980] (see also Lambek & P. Scott [1986], Curien [1986]).

Thus, we started with particular structures for higher type functions, for-malized functionality and got to a formai Theory of (typed) Functions, ìfirìSP; . Similarly, mathematicians had first in mind particular structures (rotations of a cube, relative numbers...) and then invented Group Theory. Of course, Group Theory has many more models than those; in the same way, there are many more CCC's than CD or M. However, these specific models have some futher relations to the theory, as they are defined by using the class of (partial) recursive number-theoretic functions, which are exactly the formally definable functions in the type-free X-calculus, \$r\.

Indeed, when first formalizing the intuitive notion of computation and suggesting a language for the foundation of Mathematics, Church did not consider types. That is, XJ3T?SP is defined just by erasing type constraints

Page 14: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

54

in terni formation rules (X/fy in Church [1941] does not have (fst), (snd) and (SP) either). The ambition was to live in a type-free Fregean paradise and preserve as much expressiveness of Mathematics as possible.

Shoenfinkel and Curry had an other idea on how to describe functions (and Mathematics), in a typeless way:

3.4 Definition (Combinatory Logic, CL) . Terms of CL are variables x, y...

S,K

(MN) .

The axioms are:

(KM)N=M

((SP) Q) R = (PR) (QR).

When adding

(ext) Mx = Nx=>M = N

to the obvious inference rules for " = " ,CL (ext) turns out to be equivalent to Xj3i7 (see Hindley & Seldin [1986]). For the key step write

[x]x = (SK)K

[x]y = Ky for y^x

[x] (MN) = S ([x] M) ([x] N).

Then [x] M translates he. M and conversely (note that [x]M does not contain x , or, equivalently, x is not free in 7<x. M). But now comes the rub. In Logic (and in Computer Science) types help to avoid paradoxes or inconsistencies and Church originai system was proved inconsistent by Rosser. Rosser's remark was concerned with the handling of implication in X-calculus ; we may understand it in terms of Curry's paradoxical combinator Y, the fixed point operator, and formai negation. As xx is well formed in Xj3i7 and CL, so is V, where

Y = \y . (he. y (xx)) (he. y (xx))

Page 15: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

55

is such that YM = Ai (YM) . Thus the originai system of Church, which in-cluded a term representing negation, led to a paradox.

Once this excess in expressiveness was eliminated, the consistency of Xj3r? could be proved by purely syntactic toóls (Church & Rosser [1936]). However, even though these calculi were designed in order to formalize meaningful notions from Mathematics, formalization and syntax went beyond Mathema-tics-, that is, no mathematical model was known till Scott's construction (Scott [1972]).

Let's understand it in the following way. Clearly, any model of CL , the weakest theory (see below), is an applicati­

ve structure (A, • ) , as it must intepret formai application of type-free terms. Indeed, one may use any model 04, • ) of CL , instead of Kleene's (co, • ) , and perform the same construction of the CCC M in 2.1 (see Longo & Moggi [1986]). Write M^ for this relativized construction. Observe finally that in a CCC D any fED[A,AA] turns A into (A, • ) by setting, informally, a • b =f(a) (b).

3.5 Definition. Given objects A and B in a category C , a retraction pair from B into A is a pair (i, j) such that i E. C [B, A], j E C fc4, B] and joi — idB (we write B<A via (i,j)). Let also p G C [A, B] be principal if Vf€ C [A, B] 3gEC [A, A]f=p o g. . Isomorphisms " = " are well known.

3.6 Theorem. Let C be a CCC and A an object of C. Then

(1) AA =A =»4 isamodelof \fir}

(2) AA <A =M is a model of XjS

(3) 3pGC[A,AA] principal and AXA<A=>A is a model of CL .

Conversely,

(1) A isamodelof ) ^ = ^ ^ = A in MA

(2) A isamodelof \f$=>AA <A in MA

(3) A is a model of CL => 3pEMA [A, AA ] principal and A X A <A in MA .

Page 16: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

56

Since AA < A implies 3p G C [A, AA ] principal and A X A < A , but not conversely, then CL is a weaker system than X0 .

The core of (1) and (2) in 3.6 may be found in Berry [1979], Koymans [1982] and Obtulowicz [1982] (as usuai, the main reference for the type-free calculi is Barendregt [1984]). (3) is in Longo & Moggi [1986]. In Scott [1972] a CCC was given, essentially a subcategory of Scott's domains, and an object A such that A = AA .

In conclusion, Categories fit nicely with X-calculus both in the typed and untyped case, as one may look at type free models as at a special case of typed ones: namely, those CCC's which have a "reflexive" object A such that A = AA or the weaker properties in 3.6 (2-3) hold. Conversely, frorn any type-free structure (A, • ) one may recover the type structure MA , say.

This correspondence has a nice syntactic counterpart: type-free terms may be given a type, if any. More precisely, there is an algorithm which decides whether a type-free term possesses a type and, if any, assigns it to the term (Hindley [1969]). The inference system for types to terms, due to Curry, is both sound and complete w.r.t the semantics of types over type-free structures given by the MA construction (Hindley [1983]).

3.7 Remark (Some philosophy). As the reader may have noticed, we gave priority here to a model-the orette view point, as we went from structures to theories. This may be considered as the usuai and historical path in Mathe-matics, for functions were known before Church and Curry's formalizations of the Theory of Functionality. Even if the latter authors had a computatio-nal, algorithmic approach in mind, the formalization in Geometry ofmathe-matical structures was the paradigm they refered in their foundational activity (Church [1932]). However, purely formai descriptions and results added plenty of informatìon to Mathematics (a beautiful unified framework, from that alternative view point, may be found in Huet [1985]). For example the originai ideas contained in \-calculus required the construction of new structures: the A = AA models, say, which are non trivial Mathematics. In turn, models suggested "extensions" of the extant theories. . Xj3r?SP is the simplest example and it has, so far, only model-the ore tic consistency proofs (see Barendregt [1984]); a richer extensìon of Xj8r? , olso inspired by semantics, is given in Amadio Se Longo [1986], say. Besides extensions, structures sometimes suggest modifications of formai systems: a most relevant

Page 17: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

57

example is given by Girard's Linear Logic, where the meaning of " - • " in qualitative domains (see 1.9) guided a rewriting of inference (Girard [1985/ 1987]).

The formai behaviour of computers raised syntactic descriptions into a prominent place. However, the blending and interaction of denotation and meaning is a matter ofriches of human thought: this is why both perspectives and, in particular, their interplay are relevant.

4. From higher types to higher order

The working mathematicians often makes assertions concerning arbitrary functions in a given collection (when describing integration, say) or arbitrary subsets of a given set (when dealing with ali the directed subset of a c.p.o., sya) or even with arbitrary sets within a given category or class of sets (ali c.p.o.'s have a least element...). In view of the analogy "types-as-objects" given by theorem 3.3, the latter quantification would formally correspond to the possibility of quantifying over arbitrary types.

In the previous section we have been dealing with a language for higher type functions. Functional abstraction (i.e. \x ...) was defined w.r.t. to variables ranging over ground elements, functions, functionals and so on, in any finite higher type. Note that functional abstraction may be under-stood as a form of quantification; thus, as each boolean valued function determines a set, abstracting w.r.t. a variable which ranges over boolean valued functions is like quantifying over sets of a given type.

However, we were not allowed to quantify explicitly over types. Indeed, there is some implicit quantification over types in the systems mentioned at the end of §3. Church-Curry types are defined as type schemata: e.g. the identity "he . x has type schema a -* a , i.e. "he.. x has type a -> a for any type a , or the collection of its possible types is obtained by con-sistently instantiating a -+• oc, by every type.

Mathematical practice and this implicit use of quantification suggest a language where one could discuss explicitly ali types at once: tus, a higher order language.

The language (X2) described below is due to Girard [1972] and was invented for the purposes of second order Arithmetic, as its (inhabited) types correspond to (provable) formulas of a second order logie language

Page 18: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

58

(see the rules below). The point with X2 *s t n a t o n e c a n quantify over type variables. We first define the terms of the language, in a rather broad fashion: the formation rules for types and terms will teli us which are the legai types and terms and, at one, what are the types of the terms. Tp is the symbol for the (collection of) types.

Terms: a'.:=Tp \ var I (aa) I (X var : a . a) I (V var : a . a)

We write capital letters for terms which are types or Tp itself, i.e. for terms A such that A = Tp or, for some assignment T, T \-A : Tp .

Well formed assignments: T (x : A) stands for r U {(x : A)} ; T is an ordered list.

ass.l <t> ok (the empty assignment is well formed)

r ok, T I- A : Tp , x G dom (T) ass.2

ass.3

T ( ^ : y 4 ) o k

T ok , x G dom (T)

T (x : Tp) ok

From now on, we agree that T I— ... implies that T is ok.

Typing rules:

C I —-: (assumption)

1 I X \ A

T(X :A)\-B:Tp ' , .r. . x

C.2 ; (types quantification) r \~(Vx: A. B): Tp / F M

T(x :A) V-a : B C. 3 ;—r (abstraction)

ri-- (VX : A . B):Tp

r(x :A) 1--a : B

n--(Xx-.A.a) iVx.A.B

ri--a:T/X:A.B,T\-b:A r | - (ab) : [b/x] B

ri--a. A | - A=B

C.4 ——-——-— (application)

C.5 ; (conversion for types) T\-a.B yv

Page 19: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

59

The congruence relation " = " above is derived by the following conver sion rules.

r |-(X*r :A.a)b:B '

|— (he : A . a) b = [b/x] a

r | - ( X x : A. ax):B , x$FV(a) W T~v ~A

|— AX : A . ax = a .

4.1 Notation. If x$FV(B), set A-+B=Vx : A .B .

As already mentioned, Girard invented second order X-calculus as a tool for the proof theoretic investigation of second order Arithmetic: this language, though, which we present in an extended version (following Coquand & Huet [1985], see also Amadio & Longo [1986]), turned out to be relevant in itself, mostly since the work donc in Computer Science by Reynolds [1974].

The main features are the following. Assignements rules and C I are self explanatory: they formalize assumptions made on the types of variables.

C.2 is the key point. If A is a type (i.e. A : Tp), then C.4 is a first order rule, as quantification is over variable ranging within a given type: Otherwise (i.e. if A = Tp) , Vx : Tp is clearly a second order quantification. Now, there are (at least) two possibilities: Girard suggested the following. As we want Vx : Tp . B to be a type (i.e. ( Vx : Tp. B) : Tp), types are defi­ned in an impredicative way: their collection (Tp) , which is being defined, includes elements, such as (V x : Tp . B) , which are defined by ref ering (quantifying) over the collection itself.

Alternatively, Martin^Lòf [1984] gives a higher order predicative approach by stratifying the universe of types into several layers, Tpx, Tp2 .... In short, for Tpx =Tp, if A : Tpx and B : Tpx , then (Vx : A . B) : Tpx , while (Vx : Tpx . B) : Tp2 and so on.

C.3 and C.4 teli uso which terms live in the universally quantified types and how they behave. In short, terms in (Vx : A . B) are functions (C.3) such that, when fed with a terni b in A , they give as output a term of type [b/x] B (C.4) .Thus both the output and the type of the ouptut both depend on the input. This is the core of dependent types and the main problem for the mathematical semantics of II-order, jointly to impredicativity. It will be discussed in the next section.

Page 20: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

60

We conclude this section by recalling that terms of this calculus strongly normalize, i.e. any reduction strategy takes to a normal form (Girard [1972], Coquant [1985]). Girard applied this property to the proof theory of Il-order Arithmetic, as normalization of terms corresponds to normalization of proofs. By this, Takeuti conjecture on the normalizability of Il-order proof was settled, as well as its consequences: consistency, interpolation.

Interestingly enough, the normalization theorem implies the consistency of Peano Arithmetic (PA), within PA. Thus, it is not provable in PA.

5. Constructive Domains and Modest Sets as models for X2 .

Recali that our originai motivation referred to the desire of representing higher type computations. for the purposes of Logic and of Computer Science. We defined Constructive Domains (CD ; §1) and Modests Sets (Ai -,§.2) as a very naturai framework for this; their naturality was clearly suggested by their relation to the category of enumerarated sets (EN). We then forma-lized the intended calculus and characterized the class of models of that cal­culus (the CCC's ; §.3). The latter in turn suggested an extended language and Type Theory suitable for the description of higher order constructs, which are very common in Mathematics (\2 ; §-4).

In this section, we see how those structures, CD and Ai , yield alsq models for X2 .

As already mentioned, the cruciai mathematical point is due to the impre-dicativity of X2 and the way types and terms mix up (rules C.2, C.3, C.4). In both models types will be interpreted as objects and terms as morphisms. In particulàr, one has to give a mathematical meaning to (Vx : Tp . B) : Tp , i.e. one has find an object with interprets (Vx: Tp . B) , where Tp is interpreted by a collection of objects, including the interpretation of (Vx : Tp . B) itself. This requires non trivial closure properties for the un-derlying structure. In particulàr, the interpretation of Tp must be closed under products indexed over Tp , i.e. under dependent or indexed products, since elements (of the interpretation) of (Vx : Tp . B) interpret terms such as (Kx : Tp. a), which are functions taking each element b of Tp to [b/x]a of type [b/x] B (see Bruce & Meyer [1984]).

The first model, over CD , will be given by turning the collection of ali (interpretations of ) types into a object of CD . Thus Tp itself will be inter-

Page 21: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

61

preted as a type. This strong closure property will greatly simplify the inter-pretation of ( Vx : Tp . B) : Tp.

The construction is given over a model in CD for the classical type-free X-calculus (Xj3) , that is, by theorem 3.5.2, over an object U of CD such that Uu < U . The existence of such an U will be guarantied by, say, a constructive version of Scott's D^ construction (see Barendregt [1984], Hindley & Seldin [1986] and, for the effective counterpart, Kanda [1979], Giannini & Longo [1984]). To be precise, something more is required; this motivates the following definitions.

The Constructive Finitary Projection Model

As defined, the morphisms in CD are continuous and computable maps, partially ordered pointwise. The following definition is a constructive version of the model in Amadio & Bruce & Longo [1986] (which was inspired by MacCracken [1984] and Scott [1980]). As usuai, we identify a morphism space CD [A, B] with its representative BA , when needed and unambi-guous.

5.1 Definition. Let A , B be constructive domains. (6, è) is a projection pah on A,B iff d e CD [A, B], 0 ECD[B,A] and

¢0 0 = 17/./¾ 0 o 0 <idAB.

Write A<B iff there is a projection pair of A into B.

Note that a projection pair is more than a retraction pair in the sense of§.3.5.

5.2 Definition. Let A, B be constructive domains such that A CB and <A = < B /"A X A . &GCD [B, A] isa projection iff for ali bGB,

0 (b) ^Bb , and for ali a £ range (¢), <ft(a) = a .

We write A < B if 0 is onto.

Page 22: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

62

Thus a projection is a retraction less or equal to the identity. It is easy to show that < and < are felexive and transitive (although

< is not antisymmetric). Moreover, if A < B then there is an A' = A sudi that A'<B.

Newt we show how to define a constructive domain which represents a collection of constructive domains. This will be done by taking as constructive domains the ranges of a particular class of projections.

5.3 Definition. A projection 0 in CD is said to be finitary if the range of 0 is a domain (and thus a constructive domain).

We note here that essentially ali projection pairs which normally arise are finitary. We are now ready to define the constructive domain which will re-present the type of ali types, that is the domain of the Constructive Finitary Projections.

5.4 Definition. Let U be a constructive domain such that Uu< U. Then let CFPV = {0GCD [U, U]/¢ is finirary projection}.

U as in 5.4 exists by the effective D^ construction recalled above, which actually gives Uu = U . One may also find an object U which strictly satisfies Uv< U : take, say, the constructive part of the "filter model" in Barendregt & Coppo & Dezani [1983] and its variant in Coppo & Dezani & Honsell & Longo [1984].

If U is obvious from the context then we write simply CFP . Fix U as in the definition above.

5.5 Theorem. (7) CFP is a constructive domain. (ii) (\p G CFP =» range (<p) <U) and (A<U=> 3 <pG CFP range (<p) = 4 ) .

The constructive domains we will be interested in are the subdomains of U . Notive that, by 5.5 (ii), there is a one-to-one correspondence between elements of CFP and constructive domains A < U . Thus CFP repre­sents the collection of subdomains of U . Somewhat surprisingly, CFP can be isomorphically embedded as a subdomain of U.

Page 23: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

63

5.6 Lemma. CFP < Uu and hence CFP < U. .

Proof hint: Define ¢eCD[U,U] by

0 te) = suPt/ if<g\f£CFP}.

Clearly <j)(gXg and if gG CFP then 0(g)=g. Thus range (¢)^ CFP. Gonversely, CFP D range (0 ) since CFP is consistently complete w.r.t. CD[U, U]. Therefore CFP <UU <U and CFP < U by transitivity. A

Let now V e CD [Uu, U] , $ E CD [U, Uu] be the projection pair of Uv into U . Set CFP = {^ ( / ) / / £ CFP} : these are the canonical representative of CFP within U . When there is no ambiguity we will identify CFP and CFP.

5.7 Corollary. There exists p G CFP such that range (p) = CFP.

Types will be interpreted by finitary projections. More precisely, types are ranges of finitary projections. Note first that finitary projections are parti-cular retractions, and that, if r is a retraction, then range (r) = { « G U/u = = ru } , the set of its fixed points. Moreover, finitary projections and their ranges tidily relate, by the following fact.

5.8 Proposition. Let f,g€ CFP . Then f<*g iff range (/) C range (g).

We are now ready to define our second order model. We sketch how to interpret types: details about the interpretation of terms may be found in Amadio & Bruce & Longo [1986] or a simpler syntactic translation, suffi-cient for the guidelines of the interpretation, may be seen in Amadio & Longo [1986].

Recali that we interpret Tp by CFP or, equivalently, by p . Ground types (integer, booleans..., if given in the theory) are interpreted as subdomains of U , which is rich enough for this purposes, since it is a model of Xj3 . In order to give first an informai explaination on how to interpret higher types, we mix up syntax and semantics; "Kx . f (x) is the informai lambda notation for functions. The key points is that, in ali interpretations of types as retractions, a : A is interpreted by a E range (A) or, equivalently, by a = Aa , where the retraction A interprets type A . The definitions

Page 24: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

64

of " - * " and "V" originate from elementary notions in Category Theory (see Scott [1976]).

Recali that " -• " is just a special case of " Vf\ by 4.1. We discuss this simple case first. In a category C , if an object A is a retract of B via (i, / ) , then A , as a "subtype" of B , may be identified with (/, /) or, by some abuse of language, since categories do not need to have points or elements, it may be identified with the fixed points of i © / (the range of i © / , which is a retraction).

If C is a CCC, let CA be the exponent of C and A in C; then, if A is a retract of B via (/', / ') and C is a retract of D via (i, j), one has

CA is a retract of DB via (he. i © x © / ' , he. j © x © i').

Indeed, (he. io x ©/') o (he. jo x © i') is a retraction and itsfixed points may be identified with CA as a subtype of DB . In other words, if one writes r = i©; and s = i' ©; r ,then C4 coincides with { /̂v = r© A; © s}= = range (he. r © x o s) , where r , s and XA: . r © # © s are ali retractions.

In our case, over the type-free universe U , if (i, /) and (*',/') are projection pairs, then also (he . io x o / ' , he. j© x © /') is so, and thus r, s and A#. r o x o s are ali finitary projections, whose ranges are subdomains of U.

Thus, if types A and C are interpreted as finitary projections A and C, one has:

(-> Interpret.) A -> C is interpreted as A#. C © # © A (or its range).

As for "V" , consider first rule C.3. This is a formation rule for terms; its meaning is that terms which have an applicative behaviour (X-abstractions) can be only applied to terms of the intended imput type ( A in the rule). The idea, in models where types are retractions, is to interpret those terms as functions which coerce each input to be of the right type. That is, he : A . a wil be interpreted as /© A , where / depends on a .

As for rule C.4, the intuition is that a has type Vx : A . B iff a is a function which takes any b in (the range of) A into an element ab of (the range of) [b/x] B . Since types are particular retractions, this means ab is a fixed point of [b/x] B :

ab = ([b/x] B) (ab).

Page 25: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

65

Thus, ab = (he. B)b (ab). Since b=Ab , then

ab = (he. B) (Ab) (a (Ab)).

Observe now that a must be a X-abstraction, by C.3, i.e. it is interpreted by / o A , for some / ; therefore

*ft = (f o A) b = (A*. B) (Ab) (fo A (Ab)).

That is, a coerces any argument b to be in (the range of) the retraction A. Thus one may abstract (generalize) w.r.t. b :

a = kt. (he . B) (At) (a (At)).

Equivalently:

a = (kzt. (he. B) (At) (z (At))) a .

Indeed, (kzt. (he . B) (At) (z (At))) turns out to be a retraction, when A and B are retractions. Thus, a : ( Vx : A . B) gives, in the model, that a is a fixed point of the retraction kzt. (he. B) (At) (z (At)).

The informai argument above shows that kzt. (he . B) (At) (z (At)) soundly interprets V x : A . B , as we derived it exactly from the intended meaning of universal quantification as dependent product in categories. This may be summarized as follows:

5.9 Theorem. CFP is a CCC, whicb is closed under pròduets indexed over its objects. Inparticular, for A,BECFP, range (kzt. (he. B)(At)(z (At ))) = = IlA([b/x}B).

In conclusioni

(VInterpret.) Vx.A.B is interpreted as kzt-(he. B)(At)(z(At)) (or its range)

If B does not depend on x, then (-• Interpret.) is a special case of (V In­terprete, as one may easily check by j3-reduction (cf. 3.1). As a sideremark, for range (p) = CFP and p-pp, observe that the CFP model also interprets an extension of the given language by Tp : Tp, i.e. the collection of types is a type (see Amadio & Longo [1986] for a discussion).

Page 26: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

66

The Modest or HEO2 Model

The cartesian closed extension Ai of the category EN of numbered sets has been defìned in §.2. In that category, types are interpreted as quotient subsets of oj . In particular, A -»• B is interpreted as BA , where BA

is the partial equivalence relation

pBA q iff nAm=*v (n) B<p (m).

In order to interpret the core of Girard's X2 o n e has to give meaning to

Vx : Tp . B . This is the strong, impredicative, second order type construct of that language.

Girard [1972] and Troelstra [1973] suggested an interpretàtion, called the HEO2 model, where

p[Vx : Tp.B\q iff forali R G O ^ p[[R/x]B]q

([[R/x] B] is the interpretàtion of B where x is assigned value R ). [ x : Tp. B] is an object of Ai, as it is an intersec.tion of partial equiva­lence relations. Recently Moggi [1986Tp] hinted that this is a sound inter­pretàtion, i.e. that in the right category theoretic environment [Vx : Tp . B] is a product indexed over the interpretàtion of Tp, the objects of M. A detailed treatment may be found in Longo & Moggi [1988].

The category theoretic frame is given by a model of IZF, the Effective Topos Effof Hyland [1982]. In that frame one has:

5.10 Lemma. M is a full subCCC ofEff.

M is an internai category ofEff.

An internai category is a pair of objects of the "larger" category: one representing the objects, the other representing the morphisms of the "smaller" one (see Johnstone [1977]). By this, it is possible to view at the transforma-fio n R |— [[•/?/#] B] as an internai fuhctor (a pair of morphisms) in Eff.

5.11 Theorem. (Moggi) [Vx :Tp.B]=*IiM [[R/x] B] in Eff.

Page 27: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

67

This relevant fact uses the strong features of Eff, such as the Uniformity Principle (or Kònig's lemma) for Intuitionistic Logic. It is surprising for at least two reasons: first, it shows that the originai intuition of Girard (and Troelstra) on how to interpret second order types was sound, namely that one could interpret terms in the HEO2 without loosing type information (this is what the interpretation of Vx : Tp . B as dependent product says, see Bruce & Meyer [1984]). Second, it proves a very strong closure property for an elegant category of sets, such as M .

More on this may be found in forthcoming papers by Hyland, Rosolini, Freyd, Scedrov, Carboni, Robinson or in Longo [1987]. Longo & Moggi [1987] will present an elementary account.

REFERENCES

S.F. Alien [1987] "The Semantics of Type Theoretic Languages" Doctoral Dissertation, Computer Science Department, Cornell University March 1987, (expected).

R. Amadio, K.B. Bruce, G. Longo [1986] "The finitary projections model and the solution of higher order domain equations" IEEE Conference on Logic in Computer Science (LICS 86), Boston.

R. Amadio, G. Longo [ 1986] "Type-free compiling of parametric types" IFIP Conferen­ce Formai description of Programming Concepts Ebberup (DK), North Holland, 1987, North Holland (Wirning ed.).

À. Asperti, G. Longo [l986]"Gàtegories of partial morphisms and the relation between type-structures" Lecture delivered at the Semester on theory of Computation, Banach Mathematical Center, Warsaw, December 1985, to appear (preliminary version: CAAP '86, LNCS 214, Springer-Verlag).

H. Barendregt [1984], The lambda calculus; its syntax and semantics, Rcvised and expan-ded edition, North Holland.

H. Barendregt, M. Coppo, M. Dezani [1983] "A filter lambda model and the completeness of type assignment", J. Symb. Logic 48, (931-940).

M. Beeson [1980] Foundatkms of Constructive Mathematics, Springer-Verlag.

G. Berry [1979] "Some Syntactic and Categorial Constructions oflambda-calculus models" INRIA, Valbonne.

Page 28: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

68

G. Berry [1979] "Modèles complètament adequats et stables des lambda-calculus types", Thèse de Doctorat, Université Paris VII.

R.M. Burstall, B. Lampson [1984] "A kernel language for abstract data types and modules", Symposium on Semantics of Data Types (Kahn, MacQueen, Ploktin eds.), LNCS 173, Springer-Verlag.

K. Bruce, A. Meyer [1984] " The semantics ofsecond order polymorphic lambda-calculus", Symposium on Semantics of Data Types (Kahn, MacQueen, Plotkin eds), LNCS 173,Springer-Verlag (pp. 131 -144).

A. Church [1932] "A set of partulates for the Foundation of Logic" Annals of Matti. XXXIII, (348-349).

A. Church [1941] The Calculi of Lambda Conversion, Princeton Univ. Press.

A. Church, J. Rosser [1936] "Some properties of conversion", Trans. A.M.S. 39 (472-482).

R. L. Constable et al. [1986] Implementing Mathematics with the Nuprl Proof Develop-ment System. Prentice-Hall.

M. Coppo [1984] "Completeness oftype assignment in continuous lambda-models,"Theor. Comp. Sci. 29 (309^324).

M. Coppo, M. Dezani, F. Honsell, G. Longo [1984] "Extented Type structures and fìlters lambda models" Logic Colloquium 82 (Lolli, Longo, Marcja eds.), North-Holland, Studies in Logic 112, (241-262).

T. Coquand [1985] "Une théorie des constructions", Thèse de 3eme cycle, Université Paris VII.

T. Coquand, G. Huet [1985] "Constructions: a higher order proof system for mechanizing mathematics" Report 401 INRIA, presented at EUROCAL 85.

G. Cousineau, P.L. Curein, M. Mauny [1985] "The categorical Abstract Machine" LITP, CNRS-Paris7.

P.L. Curien [1986] Categorical Combinators and Functional Programming, Pitman.

H.B. Curry, R. Feys [1958] Combinatory Logic, North-Holland.

H.B. Curry, R. Hindley, J. Seldin [1972] Combinatory Logic voi. II, North-Holland.

N. De Bruijn, [1980], "A survey of the project AUTOMATH," in Hindley & Seldin [1980].

Page 29: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

69

P. Giannini, G. Longo [1984] "Effectively given domains and lambda calculus semantics," Information and Control 62, 1 (36-63).

J.Y. Girard [1971] "Une extension de l'interpretation de Godei al'analyse, etson applica­tion a Velimination des courpures dans l'analyse et la theorie des types". In 2nd Scandinavian Logic Simposium, J.E. Festand, ed. North-Holland, Amsterdam, 1971, pages 63-92.

J. Girard [1972] "Interpretation fonctionelle et elimination des coupure dans Varithmetic d'ordre superieur, " These de Doctorat d'Etat, Paris.

J.Y. Girard [1985] "The system F ofvariable types, ftfteen years later" TCS, to appear

J.Y. Girard [1986] Book on Proof Theory in preparation for Bibliopolis.

J.Y. Girard [1987] "Linear Logic", TCS, to appear.

K. Godei [1958] "Ueber eine bicher noch nicht benuetze Erweiterung des finiten Standpuntes, " Dialectica, voi. 12, pp. 280-287.

M. Gordon, R. Milner, C. Wadsworth [1979] Edindurgh LCF, LNCS 78, Springer-Verlag.

P. Henderson [1980] Functional Programming. Prentice-Hall.

R. Hindley [1969] "The principal type-scheme of an object in Combinatory Logic," Trans. A.M.S., 146 (22-60).

R. Hindley [1983] "The completeness theorem for typing lambda-terms," Theor. Comp. Sci. 22 (1-18).

R. Hindley, G. Longo [1980] "Lambda-calculus models and extensionality " Zeit. Math. Logik Grund. Math. n. 2, voi. 26 (289^310).

R. HindleyJ. Seldin (eds.) [1980] To H.B. Curry: Essays in Combinatory Logic, Lambda calculus and formalism, Academic Press.

R. Hindley, J. Seldin [1986] Introduction to Combinators and Lambda-Calculus, London Mathematical Society.

M. Hyland [1982] "The effective Topos" in The Brouwer Symposium, (Troelstra, Van Dalen eds.) North-Holland.

G. Huet [1986] "Formai Structures for Computation and Deduction" Lecture Notes, C.M.U.

Page 30: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

70

N. Jones [1980] (ed.) Semantics-Directed Compiler Generation, LNCS 94, Springer-Verlag.

P. Johnstone [1977] Topos Theory. Academic Press.

A. Kanda [1979] "Fully effective solutìons of recursive domain equations" Proc. of MFCS'79, LNCS 74, Springer-Verlag.

S.C. Kleene [1936] "Lambda definability and recursiveness," Duke Math. J., 2, (pp. 340-353).

K. Koymans [1982] "Models of the lambda calculus", Information and Control, 52, pp. 306-332.

J. Lambek [1980] "From lambda-calculus to cartesian closed categories," in Hindley & Seldin [1980].

J. Lambek, P.J. Scott [1986] Introduction to higher order Categorial Logic, Cambridge University Press.

G. Longo [1979] "Ricorsività nei tipi superiori: un'introduzione alle caratterizzazioni di Ershov ed Hyland," Rendiconti del Seminario Matematico di Torino n. 2, voi. 37 (pp. 1-29).

G. Longo [1983] "Set-Theoretical Models of Lambda-calculus: Theories, Expansions, Isomorphisms, " Annals Pure Applied Logic voi. 24, ( 15 3-188).

G. Longo [1984] "Continuous structures and analytic methods in Computer Science" Lecture delivered at the Coli, on Trees in Algebra and Programming, Bordeaux (Courcelle ed.) Cambridge University Press, 1984 (pp. 1-22).

G. Longo [1984p] "Limits, higher computability and type free languages," Lecture delivered at MFCS'84, Prague (Chytil, Koubek eds.), LNCS 176, Springer-Verlag, 1984 (pp. 96-114).

G. Longo [1987] "On Church's Formai Theory of Functions and Functionals" Lecture delivered at the Church Thesis Conference, Zeiss (NL), Ann. Pure App. Logic, to appear.

G. Longo, E. Moggi [1984] "The Hereditary Partial Recursive Functionals and Recursion Theory in higher types," J. Symb. Logic, voi. 49, 4 (pp. 1319-1332).

G. Longo, E. Moggi [1986] "Type-structures, principal morphisms, Combinatory Algebras: a category-theoretic characterization of functional completeness", Theor. Comp.

Page 31: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

71

Sci., to appear (prelim. version in Math. Found. Comp. Sci., Prague 1984 (Chytil, Koubek eds.) LNCS 176, Springer-Verlag, 1984 (pp. 397-406).

G. Longo, E.Moggi [1988] "Constructive Naturai Deduetion andits Modest Interpretation" To appear in an M.I.T. Press volume edited by Mesegner et al.

D.B. MacQueen, R. Sethi, G.D. Plotkin [1984] "An ideal model for recursive polymorphyc types, " Proc. POPL 84, Info & C. (to appear).

P. Martin-Lòf [1975] "An intuitionistic theory of types" Logic Colloquium 73, Rose Shepherdson (Eds.), North-Holland (73-118).

P. Martin-Lòf [1984] Intuitionistic Type-Theory Bibliopolis, Napoli.

D. McCarthy [1984] "Realizability and Recursive mathematics" Ph. D. Thesis, Merton College, Oxford.

N. McCracken [1984] "A finitary retract model for the polymorphic lambda-calculus", Information and Control (to appear).

D. Miller [1984] "Automating Higher Order Logic". PhD Thesis, Canergie-Mellon University.

R. Milner [1978] "A theory of type polymprphism in programming, " Journal of Computer and Systems Sci., 3 (348-375).

R. Milner, [1986] "Is computing an experimental Science?" Inaugurai lecture for the LFCS, Edinburgh.

J.C. Mitchell [1984] "Type inference and type containment", Symposium on Semantics of Data Types (Kahn, MacQuen, Plotkin eds.), LNCS 173, Springer-Verlag (257-278).

J. Mitchell, E. Moggi [1987] "Kripke-style models for typed lambda calculus" LICS 87, Cornell.

J.C. Mitchell, G. Plotkin [1985] "Abstract types bave exixtential types" Proc. Popi 85, ACM.

E. Moggi [1986Tp] Message of Jan. on Type electronic-mailing List.

E. Moggi [1986] "Partial Morphisms in Categories of effective objects," Info & Conti*., to appear.

E. Moggi [1987] Ph. D. Thesis, Edinburgh, in preparation.

Page 32: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

72

B. Nordstrom [1981] "Programming in constructive set theory: some examples", In Pro-ceedings 1981 Conference on Functional Programming Languages and Computer Architecture. Portsmouth, England, pages 141-153.

J. Reynolds [1974], "Towards a theory oftype structures," Colloque sur la Programmation, LNCS 19, Springer-Verlag (pp. 408-425).

J. Reynolds [1984], "Polymorphism is not set-the ore tic," Symposium on Semantics of Data Types, (Kahn, MacQueen, Plotkin, eds.) LNCS 173, Springer-Verlag.

G. Rosolini [1986] "Continuity and effectiveness in Topoi" D. Phil. Thesis, Oxford Univ.

iti D. Scott [1970] "Outline of a mathematical theory of computation" 4 Ann. Princeton

Conf. on Info. Syst. Sci. (pp. 169-176).

D. Scott [1970] "Constructive validity". In Symposium on Automatic Demonstration, Lecture Notes in Mathematics, Voi. 125. Springer-Verlag, New Yord, 1970, pages 237-275.

D. Scott [1972] "Continuous lattices" Toposes, algebraic Geometry and Logic, (Lawere ed.), LNM 274, Springer-Verlag.

D. Scott [1976] "Data types as lattices," SIAM Journal of Computing, 5 (pp. 522-587).

D. Scott [1980] "Relating theories of the lambda-calculus," in Hindley & Seldin [1980].

D. Scott [1980b] "A space ofretracts" Manuscript, Breme.

D. Scott [1982] "Some ordered sets in Computer Science", in Ordered Sets (Rivai Ed.), Reided.

D. Scott [1982] "Domains for denotational semantincs," (preliminary version), Procee-dings ICALP 82, LNCS 140, Springer-Verlag).

R.A.G. Seely [1984] "Locally Cartesian closed Categories and type theory" Math. proc. Cambridge Phil. Soc, 95, 33, pp. 33-48.

R.A.G. Seely [1986] "Categorical semantics for higher order polymorphic lambda calcu-lus", JSL (to appear).

M. Smyth [1977] "Effectively Given Domains", Theoret. Comput. Sci. 5, pp. 255-272.

M. Smyth, G. Plotkin [1982] "The category-theoretic solution of recursive domain equa-tions" SIAM Journal of Computing 11, (pp. 761-783).

Page 33: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

73

R. Statman [1983] "Lambda-definable functionals and beta-conversion," Arch. Math. Logik, 23 (pp. 21-26).

A. Troelstra [1973] Metamathematical investigation of Intuitìonistic Arìthmetic and Analysis. LNM 344, Springer-Verlag, Berlin.

R. Turner il984/ Logics for Artificial Intelligence. Halsted Press (John Wiley & Sons), New York, 1984.

GIUSEPPE LONGO - Dipartimento di Informatica, Università di Pisa - C.so Italia, 40 -56100 Pisa, (Italia).

Page 34: FROM NUMBERED SETS TO TYPE THEORIES · FROM NUMBERED SETS TO TYPE THEORIES Introduction ... the specifi c are oaf X-calculus b, y a very large scientific ... investigation of its

•"*••<».