Approximation Theorems for Intersection Type Systems
Total Page:16
File Type:pdf, Size:1020Kb
Approximation Theorems for Intersection Type Systems MARIANGIOLA DEZANI-CIANCAGLINI, Dipartimento di Informatica, Universita` di Torino, Corso Svizzera 185, 10149 Torino, Italy. E-Mail: [email protected] FURIO HONSELL, Dipartimento di Matematica ed Informatica, Universita` di Udine, Via delle Scienze 208, 33100 Udine, Italy. E-Mail: [email protected] YOKO MOTOHAMA, Dipartimento di Informatica, Universita` di Torino, Corso Svizzera 185, 10149 Torino, Italy. E-Mail: [email protected] Abstract In this paper we prove that many intersection type theories of interest (including those which induce as filter models, D Scott’s and Park’s ½ models, the models studied in Barendregt Coppo Dezani, Abramsky Ong, and Honsell Ronchi) satisfy an Approximation Theorem with respect to a suitable notion of approximant. This theorem implies that a -term has a type if and only if there exists an approximant of that term which has that type. We prove this result uniformly for all the intersection type theories under consideration using a Kripke version of stable sets where bases correspond to worlds. Keywords: -calculus, intersection types, approximation theorem, set-theoretical semantics of types. 1 Introduction Intersection types were introduced in the late 1970s by Dezani and Coppo [8, 9, 6], to over- come the limitations of Curry’s type discipline. They are a very expressive type language which allows one to describe and capture various properties of -terms. For instance, they have been used in [27] to give the first type theoretic characterization of strongly normaliz- able terms and in [10] to capture persistently normalizing terms and normalizing terms.See [13] for a more complete account of this line of research concerning intersection types. Intersection types have also a very significant realizability semantics with respect to ap- plicative structures. This is a generalization of Scott’s natural semantics [31] of simple types. According to this interpretation, types denote subsets of the applicative structure, arrow types ! B A A denoting the sets of terms which map all terms belonging to the interpretation of A \ B into terms belonging to the interpretation of B , and intersection types denoting the B intersections of the interpretation of A and the interpretation of . Building on this, intersec- tion types have been used in [6] to give a proof of the completeness of the natural semantics of Curry’s simple type assignment system in applicative structures, introduced in [31]. See [12] for a more complete treatment of the completeness problem of intersection type assignment systems. J. Logic Computat., Vol. 11 No. 3, pp. 395–417 2001 c Oxford University Press 396 Approximation Theorems for Intersection Type Systems But intersection types have also an alternative semantics, based on duality, which is related to Abramsky’s ‘domain theory in logical form’ [1]. This semantics amounts to the application of that paradigm to the special case of ! -algebraic complete lattice models of pure lambda calculus, [11]. Namely, types correspond to compact elements: the type ª denoting the least element, intersections denoting joins of compact elements, and arrow types denoting step functions of compact elements. According to this semantics, a typing judgment can be interpreted as saying that a given term belongs to a pointed compact open set in a ! - algebraic complete lattice model of -calculus. Hence, by duality, type theories give rise to filter -models. Intersection type assignment systems can then be viewed as finitary logical definitions of the interpretation of -terms in such models, hence the meaning of a -term is the set of types which are deducible for it. This duality lies at the heart of the success of intersection types as a powerful tool both for the analysis and the synthesis of -models [2, 6, 11, 10, 3, 15, 19, 14, 26, 18, 28]. As proved in [3, 11, 4] there is a very large class of ! -algebraic models which have natural D readings as filter models. This class includes for example all the ½ inverse limit models, such as Scott’s [31] and Park’s models [23], the model in [2] which has been studied in connection with the lazy -calculus, and the model [6] which realizes equality of B¨ohm trees [29]. It is often the case that the very nature of the syntactical properties of -terms that one is interested in might suggest a particular intersection types theory, which induces a filter model D which captures semantically such properties. Important examples in this respect are the ½ Á limit models characterizing normalizing terms [10] and terms reducible to - -calculus [19], respectively. ! A crucial result in the study of the fine structure, and hence the -theory, of -algebraic -models is the, so called, approximation theorem, [33, 21, 7, 30, 19]. An approximation theorem allows one to express the interpretation of any -term, even a non terminating one, as the supremum of the interpretations of suitable normal forms, called the approximants of the term, in an appropriate extended language. Approximation theorems are very useful in proving, for instance, computational adequacy of models with respect to operational se- mantics [7, 19]. There are other possible methods of showing computational adequacy, both semantical and syntactical [2, 33, 19, 24], but the method based on approximation theorems is usually the most straightforward. However, proving an approximation theorem for a given model theory is usually rather difficult. Most of the proofs in the literature are based on the technique of indexed reduction [33, 19]. However, when the model in question is a filter model, by applying duality, the approxi- mation theorem can be rephrased as follows: the types of a given term are all and only the types of its approximants. This change in perspective opens the way to proving approxima- tion theorems using the syntactical machinery of proof theory, such as logical predicates and computability techniques. The aim of the present paper is to show in a uniform way that all the type assignment systems which induce filter models isomorphic to the models in [2, 6, 30, 19, 10] satisfy the Approximation Theorem. To this end we use a technique which can be construed as a version of stable sets over a Kripke applicative structure [22]. The present paper is organized as follows. In Section 2 we present type assignment sys- tems for intersection types and we prove some meta-theoretic properties including a genera- tion theorem and subject conversion. In Section 3 we introduce approximants and we prove the approximation theorem using a Kripke interpretation of intersection types in which the Approximation Theorems for Intersection Type Systems 397 bases play the role of worlds. In Section 4 we give some applications of the approximation theorems. Finally we mention directions for future work. 2 Intersection type theories and type assignment systems Intersection types are syntactical objects built inductively by closing a given set C of type atoms (constants) under the function type constructor ! and the intersection type constructor ª C \. We always assume that the universal type is a member of . DEFINITION 2.1 (Intersection type languages) Ì = Ì´Cµ The intersection type language over C, denoted by , is defined by the following abstract syntax: Ì = C j Ì!Ì j Ì \ Ì: NOTATION 2.2 Upper case Roman letters, i.e. A; B ; : : : , will denote arbitrary types. In writing intersection- types we shall use the following convention: the constructor \ takes precedence over Ò A ! B the constructor ! and both associate to the right. Moreover abbreviates ! B !¡¡¡!A A . ßÞ } | Ò Much of the expressive power of intersection type disciplines comes from the fact that types can be endowed with a preorder relation , which induces the structure of a meet ª semi-lattice with respect to \, the top element being . DEFINITION 2.3 (Intersection type preorder) = Ì´Cµ Ì Let Ì be an intersection type language. An intersection type preorder over is a ¼ Ì 5 binary relation on satisfying the following set (‘nabla-zero’) of axioms and rules: A A A \ A (refl) A (idem) A \ B A A \ B B Ê (inclÄ ) (incl ) ¼ ¼ A B B A B B C (mon) A (trans) ¼ ¼ A \ B A \ B A C A ª ! \ ´A! B µ \ ´A! C µ A!B \ C ( ª) ( - ) ¼ ¼ A A B B ( ) ¼ ¼ A!B A !B NOTATION 2.4 B A B B A We will write A for and . Notice that associativity and commutativity of \ (modulo ) follow easily from the above axioms and rules. NOTATION 2.5 Ì \ A \ ::: \ A A ½ Ò Being commutative and associative, we will write i for . Similarly iÒ Ì Á; Â;à A we will write i . We convene that etc., when referred to as sets of indexes for i¾Á types, always denote finite non-empty sets. The meaning of the above axioms and rules can be grasped if we take types to denote ! subsets of a domain of discourse and we view \ as set-theoretic intersection and as the 398 Approximation Theorems for Intersection Type Systems ª ª!ª ( ª- ) A!B ª!ª ( ª-lazy) ª!! ! ( ! -Scott) ! !! ! ( ! -Park) ´!³µ ! ³ ´³! ! µ ³!! ! ´! !³µ ! !³ ³ ´Á µ ´³!³µ \ ´! !! µ ³ FIGURE 1. Some special purpose axioms concerning !B function space constructor in the light of Curry–Scott semantics [32]. Thus the type A B denotes the set of total functions which map each element of A into an element of . \ The intended interpretation of arrow types motivates axiom (!- ), which implies that if a B A C function maps A into , and the same function maps also into , then, actually, it maps B C B \ C the whole A into the intersection between and (i.e. into ), see [6]. µ Rule ´ is also very natural in view of the set-theoretic interpretation. It implies that the arrow constructor is contravariant in the first argument and covariant in the second one.