Polymorphic Intersection Type Assignment for Rewrite Systems with Abstraction and -Rule Extended Abstract

Polymorphic Intersection Type Assignment for Rewrite Systems with Abstraction and -Rule Extended Abstract

Polymorphic Intersection Type Assignment for Rewrite Systems with Abstraction and -rule Extended Abstract Steffen van Bakel , Franco Barbanera , and Maribel Fernandez´ Department of Computing, Imperial College, 180 Queen’s Gate, London SW7 2BZ. [email protected] Dipartimento di Matematica, Universita` degli Studi di Catania, Viale A. Doria 6, 95125 Catania, Italia. [email protected] LIENS (CNRS URA 8548), Ecole Normale Superieure,´ 45, rue d’Ulm, 75005 Paris, France. [email protected] Abstract. We define two type assignment systems for first-order rewriting ex- tended with application, -abstraction, and -reduction (TRS ). The types used in these systems are a combination of ( -free) intersection and polymorphic types. The first system is the general one, for which we prove a subject reduction theorem and show that all typeable terms are strongly normalisable. The second is a decidable subsystem of the first, by restricting types to Rank 2. For this sys- tem we define, using an extended notion of unification, a notion of principal type, and show that type assignment is decidable. Introduction The combination of -calculus (LC) and term rewriting systems (TRS) has attracted attention not only from the area of programming language design, but also from the rapidly evolving field of theorem provers. It is well-known by now that type disciplines provide an environment in which rewrite rules and -reduction can be combined with- out loss of their useful properties. This is supported by a number of results for a broad range of type systems [11, 12, 20, 7, 8, 5]. In this paper we study the combination of LC and TRS as a basis for the design of a programming language. The type systems a` la Curry, also called type inference or type assignment systems, are the most interesting ones from this point of view, since they save the programmer from specifying a type for each variable (no type annotations are required). Type assignment disciplines have been widely studied in the context of the LC, and some work has also been done for TRS, more precisely, for Curryfied TRS (CuTRS) [6] which are first-order TRS with application, that correspond to the TRS that underlie the programming language Clean [26]. The interactions between LC and TRS in the context of type assignment were first studied in [5], where CuTRS extended with -abstraction and -reduction were defined, together with a notion of intersection type assignment for both the LC and the TRS fragments. Partially supported by NATO Collaborative Research Grant CRG 970285 ‘Extended Rewriting and Types’. Other important features of a type system for a programming language are polymor- phism, that is, the possibility of using the same program with arguments of different types, and the existence of principal types, that is, a type from which all the other types of the term can be derived. The type system of ML has the three properties above, i.e., it is a polymorphic type inference system with principal types, but its polymorphism is limited (some programs that arise naturally cannot be typed). System F [18] pro- vides a much more general notion of polymorphism, but lacks principal types, and type inference is undecidable in general (although it is decidable for some subsystems, in particular if we consider types of rank 2 [21]). Intersection type systems [10] are some- where in the middle with respect to polymorphism (they provide less polymorphism than System F but more than ML) and principal types can be constructed for typeable terms. But type assignment is again undecidable; decidability is recovered if we restrict ourselves to the rank 2 types [4]. In view of the above results, two questions arise naturally: – Is the rank 2 combination of System F and the Intersection System also decidable? – Does it have principal types for all typeable terms? A system for the LC that combines intersection types and System F with principal types has been studied in [19, 24]. In this paper we extend that system to a combination of LC and CuTRS. In other words, we extend the type assignment system of [5] further, adding ‘ ’ as an extra type-constructor (i.e. explicit polymorphism). Although extend- ing the set of types by adding ‘ ’ does not extend the expressivity of the system in terms of typeable terms, the set types of assignable types increases, and types can better express the behaviour of terms (see [13]). The resulting system has the expected proper- ties: Subject Reduction, and Strong Normalization when the rewrite rules use a limited form of recursion (inspired by the General Schema of Jouannaud and Okada [20]). The proof of the latter follows the method of Tait-Girard’s reducibility candidates, extended in order to take the presence of (higher-order) algebraic rewriting into account. We also answer the first question in the affirmative. The restriction to types of rank 2 of the combined system of polymorphic and intersection types is decidable. This restricted system can be seen as a combination of the systems considered in [4] and [21]. The combination is twofold: not only the type systems of those two papers are combined (resp. intersection and polymorphic types of Rank 2), but also their calculi are combined (resp. CuTRS and LC). In our Rank 2 system each typeable term has a principal type such that every type derivable for the term can be seen as an instance (under suitable operations) of the type. This is the case also in the Rank 2 intersection system of [4], but not in the Rank 2 polymorphic system of [21]. For the latter, a type inference algorithm of the same complexity of that of ML was given in [22], where the problems that occur due to the lack of principal types are discussed in detail. This paper is organised as follows: In Section 1 we define TRS with application, -abstraction and -reduction (TRS ), and in Section 2 the type assignment system. Section 3 deals with the strong normalization property for typeable terms. In Section 4 we present the restriction of the general type assignment system to Rank 2. 1 Term Rewriting Systems with -reduction We present a combination of Lambda Calculus with Algebraic Rewriting, obtained by extending first-order TRS with notions of application and abstraction, and -reduction. We can look at such calculi also as extensions of the Curryfied Term Rewriting Systems (CuTRS) considered in [6], by adding -abstraction and a -reduction rule. We assume the reader to be familiar with LC [9] and refer to [23, 14] for rewrite systems. We consider terms built from a set of variables, a set of function symbols, application ( ) and -abstraction, modulo -conversion, as usual. A context is a term with a hole, and it is denoted, as usual, by C . A lambda term is a term not containing function symbols. An algebraic term is a term containing neither nor . The set of free variables of a term is defined as usual, and denoted by FV . To denote a term-substitution, we use capital characters like ‘R’, instead of Greek characters like ‘ ’, which will be used to denote types. Sometimes we use the notation . We write R for the result of applying the term-substitution R to . Reductions are defined through rewrite rules together with a -reduction rule. Definition 1 (Reduction). A rewrite rule is a pair of terms, written . Three conditions are imposed: , is an algebraic term, and . The -rule is defined by: . A rewrite rule determines a set of rewrite steps C R C R for all term-substitutions R and contexts C . Likewise, for any and , C C . Concatenating rewrite steps we have rewrite sequences . If ( ) we also write , and if in one step or more. A Term Rewriting System with -reduction rule (TRS ) is defined by a set R of rewrite rules. Note that, in contrast with CuTRS, the rewrite rules considered in this paper may con- tain -abstractions in the right-hand sides. We take the view that in a rewrite rule a cer- tain symbol is defined: is a defined symbol, if there is a rewrite rule . is called a constructor if is not a defined symbol. Notice that cannot be a defined symbol since it cannot appear in the left-hand side of a rewrite rule. A TRS is strongly normalizing, or terminating, if all the rewrite sequences are finite. It is confluent if for all such that and , there exists such that and . Example 2. The following is a set of rewrite rules that defines the functions append and map on lists and establishes the associativity of append. The function symbols nil and cons are constructors. append nil append cons cons append append append append append map nil nil map cons cons map Since variables in TRS can be substituted by -expressions, we obtain the usual functional programming paradigm, extended with definitions of operators and data structures. 2 A Polymorphic Intersection System for TRS We define a type assignment system for TRS , that can be seen as an extension (by adding ) of the intersection system presented in [5]. We use polymorphic strict inter- section types, defined over a set of type-variables and sorts (type constants). The -free, -free fragment of this system corresponds to the system studied in [6]. If sorts are not taken into account, the -free LC-fragment of our type assignment system corresponds to the system presented in [3], and the intersection-free LC-fragment to System F [18]. For LC, a type assignment system that combines intersection types with polymor- phic types has been defined in [19] and its principal type property has been studied in [24]. As far as types are concerned, the difference between our system and the latter is that we add constant types, and use strict intersection types [3] (i.e.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    16 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us