Integrating Linear and Dependent Types

Total Page:16

File Type:pdf, Size:1020Kb

Integrating Linear and Dependent Types rtifact Comple * A t * te n * te A is W s E * e n l l C o L D C o P * * c u e m s O E u e e P n R t v e o d t * y * s E a a l d u e a t Integrating Dependent and Linear Types Neelakantan R. Krishnaswami Pierre Pradic Nick Benton University of Birmingham ENS Lyon Microsoft Research <[email protected]> <[email protected]> <[email protected]> Abstract ative programs, and type dependency permits giving very In this paper, we show how to integrate linear types with precise types to describe the precise functional behavior of type dependency, by extending the linear/non-linear calcu- those programs. The primary difficulty we face is precisely lus of Benton to support type dependency. the interaction between type dependency and the structural Next, we give an application of this calculus by giving a rules. Since linear types ensure a variable occurs only once in proof-theoretic account of imperative programming, which a program, and dependent types permit variables to occur in requires extending the calculus with computationally irrele- both types and terms, how should we count occurrences of vant quantification, proof irrelevance, and a monad of com- variables in types? putations. We show the soundness of our theory by giving The key observation underpinning our approach is that a realizability model in the style of Nuprl, which permits us we do not have to answer this question! We build on the work of to validate not only the β-laws for each type, but also the Benton [7], which formulated models of intuitionistic linear F a G η-laws. logic in terms of a monoidal adjunction between a These extensions permit us to decompose Hoare triples monoidal closed category L and a cartesian closed category A into a collection of simpler type-theoretic connectives, yield- C. The exponential ! then decomposes as the composition G(F(A)) ing a rich equational theory for dependently-typed higher- of the . Syntactically, such a model then corresponds order imperative programs. Furthermore, both the type the- to a pair of lambda calculi, one intuitionistic, and one linear, F G ory and its model are relatively simple, even when all of the which are related by a pair of modal operators and . extensions are considered. In the linear/non-linear (LNL) calculus, we no longer have to view the intuitionistic function space P ! Q through Keywords Linear types, dependent types, intersection types, the lens of the Girard encoding !P ( Q. Instead, the intu- proof irrelevance, separation logic, Hoare triples itionistic arrow, !, is a connective in its own right, inde- pendent of the linear function space, (. Given such a sep- 1. Introduction aration, we can make the intuitionistic part of the language dependent, changing the type X ! Y to the pi-type Πx : X. Y, Two of the most influential research directions in language without altering the linear function space A ( B. We then design are substructural logic and dependent type theory. end up with a type theory in which linear types may depend Substructural logics like linear logic [18] and separation on intuitionistic terms in quite sophisticated ways, but we logic [38] offer fine-grained control over the structural rules never have to form a type dependent on an open linear term. of logic (i.e., contraction and weakening), which means types As an illustration, recall Girard’s [19] classic motivating control not only how a value of a given type is used, but also example of the resource reading of linear logic in which the how often it is used. This permits giving a logical account proposition A represents spending a dollar, B represents ob- resource of the notion of , and has been tremendously useful taining a pack of Camels, and C obtaining a pack of Marl- in giving modular and accurate specifications to stateful and boro. The formula A ( B&C then expresses that one may imperative programs. spend a dollar and receive the option of a pack of Camels On the other hand, dependent type theory extends simple and of a pack of Marlboro, but only of these options may be type theory by permitting terms to occur in types, permitting exercised. In LNLD, from that assumption one can type, for the expression of concepts like equality in types. This enables example, a machine M that takes n dollars and produces its giving types which give a very fine-grained specification of choice of something you can buy: the functional behaviour of their inhabitants. 0 0 We would like to fully integrate dependent and linear M : Πn : N. tuple n A ( Fm : N, m : N, p : m + m = n. type theory. Linear type theory would permit us to extend tuple m B ⊗ tuple m0 C the Curry-Howard correspondence to (for example) imper- where tuple n A is the (definable) n-fold linear tensor A⊗· · ·⊗ A. The return type of the linear function space in the type Permission to make digital or hard copies of all or part of this work for of M is a linear dependent pair, which generalizes LNL’s F personal or classroom use is granted without fee provided that copies are not modality for mapping intuitionistic values into linear ones. made or distributed for profit or commercial advantage and that copies bear So M yields two integers m and m0, a proof that their sum is this notice and the full citation on the first page. Copyrights for components 0 of this work owned by others than the author(s) must be honored. Abstracting n and an m-tuple of Bs together with an m -tuple of Cs. with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request Contributions. In this paper, we make the following contri- permissions from [email protected]. butions: POPL ’15, January 15–17, 2015, Mumbai, India. Copyright is held by the owner/author(s). Publication rights licensed to ACM. • First, we describe a core type theory LNLD that smoothly ACM 978-1-4503-3300-9/15/01. $15.00. integrates both linearity and full type dependency, by ex- http://dx.doi.org/10.1145/2676726.2676969 Γ ok Γ ` Ui : Ui+1 Γ ` Li : Ui+1 Γ ok Γ ` X type Γ ` X : Ui Γ, x : X ` Y : Ui Γ ` X : Ui Γ, x : X ` Y : Ui · ok Γ, x : X ok Γ ` Πx : X. Y : Ui Γ ` Σx : X. Y : Ui Γ ` ∆ ok Γ ` A : Li Γ ` 1 : Ui Γ ` G A : Ui Γ ` ∆ ok Γ ` A linear Γ ` X : U Γ ` e : XΓ ` e0 : X Γ ` · ok Γ ` ∆ a : A ok i , 0 Γ ` e =X e : Ui Γ ` X type Γ ` A linear Γ ` A : Li Γ ` B : Li Γ ` A : Li Γ ` B : Li Γ ` I : Li Γ ` A ⊗ B : Li Γ ` A ( B : Li Γ ` X : Ui Γ ` A : Li Γ ` X type Γ ` A linear Γ ` X : Ui Γ, x : X ` A : Li Γ ` X : Ui Γ, x : X ` A : Li Γ ` Πx : X. A : Li Γ ` Fx : X. A : Li Γ ` X ≡ Y type Γ ` A ≡ B linear Γ ` A : Li Γ ` B : Li Γ ` X ≡ Y : Ui Γ ` A ≡ B : Li Γ ` > : Li Γ ` A & B : Li Γ ` X ≡ Y type Γ ` A ≡ B linear Figure 2. Type Well-formedness Figure 1. Structural judgements Γ ` e : YΓ ` X ≡ Y type tending the linear/non-linear calculus [7, 8]. Our type 0 Γ, x : X, Γ ` x : X Γ ` e : X Γ ` () : 1 theory is an extensional type theory, which means that we consider the full βη-theory of the language, and further- Γ ` e : XΓ ` e0 :[e=x]Y Γ ` e : Σx : X. Y 0 more, it also has a universe hierarchy, meaning that we Γ ` (e, e ) : Σx : X. Y Γ ` π1 e : X support “full-spectrum” dependent types including large eliminations (i.e., computing types from terms). Γ ` e : Σx : X. Y Γ ` π e :[π e=x]Y Our approach to linear dependent type theory gives a 2 1 simple proof-theoretic explanation of how the ad-hoc Γ ` Πx : X. Y type Γ, x : X ` e : Y restrictions on the interaction of linearity in earlier ap- Γ ` λx. e : Πx : X. Y proaches (such as Linear LF [10]) arise, by showing how Γ ` e : Πx : X. YΓ ` e0 : X they can be modelled in LNLD. Γ ` e e0 :[e0=x]Y • Second, we show how to turn this calculus into a lan- guage for dependently-typed imperative programming Γ ` e ≡ e0 : X Γ; · ` e : A 0 (in the style of separation logic). The general idea is to Γ ` refl : e =X e Γ ` G e : G A combine linearity and type dependency to turn separation- logic style specifications into types, and to take impera- Figure 3. Intuitionistic Typing tive programs to be inhabitants of those types. Ensuring that programs have the appropriate operational behavior requires a number of extensions to the type sys- The basic structural judgements are given in Figure 1. The tem, including pointer types, implicit quantification (in judgement Γ ok is the judgement that a context Γ of intuition- the style of intersection and union types), and proof irrel- istic hypotheses is well-formed. As is standard, a well-formed evance for linear types. context is either empty, or a context Γ 0, x : X where Γ 0 is well-formed and X is an intuitionistic type well-formed in • Once this is done, we not only have a very expressive type Γ.
Recommended publications
  • Types Are Internal Infinity-Groupoids Antoine Allioux, Eric Finster, Matthieu Sozeau
    Types are internal infinity-groupoids Antoine Allioux, Eric Finster, Matthieu Sozeau To cite this version: Antoine Allioux, Eric Finster, Matthieu Sozeau. Types are internal infinity-groupoids. 2021. hal- 03133144 HAL Id: hal-03133144 https://hal.inria.fr/hal-03133144 Preprint submitted on 5 Feb 2021 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. Types are Internal 1-groupoids Antoine Allioux∗, Eric Finstery, Matthieu Sozeauz ∗Inria & University of Paris, France [email protected] yUniversity of Birmingham, United Kingdom ericfi[email protected] zInria, France [email protected] Abstract—By extending type theory with a universe of defini- attempts to import these ideas into plain homotopy type theory tionally associative and unital polynomial monads, we show how have, so far, failed. This appears to be a result of a kind of to arrive at a definition of opetopic type which is able to encode circularity: all of the known classical techniques at some point a number of fully coherent algebraic structures. In particular, our approach leads to a definition of 1-groupoid internal to rely on set-level algebraic structures themselves (presheaves, type theory and we prove that the type of such 1-groupoids is operads, or something similar) as a means of presenting or equivalent to the universe of types.
    [Show full text]
  • Sequent Calculus and Equational Programming (Work in Progress)
    Sequent Calculus and Equational Programming (work in progress) Nicolas Guenot and Daniel Gustafsson IT University of Copenhagen {ngue,dagu}@itu.dk Proof assistants and programming languages based on type theories usually come in two flavours: one is based on the standard natural deduction presentation of type theory and involves eliminators, while the other provides a syntax in equational style. We show here that the equational approach corresponds to the use of a focused presentation of a type theory expressed as a sequent calculus. A typed functional language is presented, based on a sequent calculus, that we relate to the syntax and internal language of Agda. In particular, we discuss the use of patterns and case splittings, as well as rules implementing inductive reasoning and dependent products and sums. 1 Programming with Equations Functional programming has proved extremely useful in making the task of writing correct software more abstract and thus less tied to the specific, and complex, architecture of modern computers. This, is in a large part, due to its extensive use of types as an abstraction mechanism, specifying in a crisp way the intended behaviour of a program, but it also relies on its declarative style, as a mathematical approach to functions and data structures. However, the vast gain in expressivity obtained through the development of dependent types makes the programming task more challenging, as it amounts to the question of proving complex theorems — as illustrated by the double nature of proof assistants such as Coq [11] and Agda [18]. Keeping this task as simple as possible is then of the highest importance, and it requires the use of a clear declarative style.
    [Show full text]
  • On Modeling Homotopy Type Theory in Higher Toposes
    Review: model categories for type theory Left exact localizations Injective fibrations On modeling homotopy type theory in higher toposes Mike Shulman1 1(University of San Diego) Midwest homotopy type theory seminar Indiana University Bloomington March 9, 2019 Review: model categories for type theory Left exact localizations Injective fibrations Here we go Theorem Every Grothendieck (1; 1)-topos can be presented by a model category that interprets \Book" Homotopy Type Theory with: • Σ-types, a unit type, Π-types with function extensionality, and identity types. • Strict universes, closed under all the above type formers, and satisfying univalence and the propositional resizing axiom. Review: model categories for type theory Left exact localizations Injective fibrations Here we go Theorem Every Grothendieck (1; 1)-topos can be presented by a model category that interprets \Book" Homotopy Type Theory with: • Σ-types, a unit type, Π-types with function extensionality, and identity types. • Strict universes, closed under all the above type formers, and satisfying univalence and the propositional resizing axiom. Review: model categories for type theory Left exact localizations Injective fibrations Some caveats 1 Classical metatheory: ZFC with inaccessible cardinals. 2 Classical homotopy theory: simplicial sets. (It's not clear which cubical sets can even model the (1; 1)-topos of 1-groupoids.) 3 Will not mention \elementary (1; 1)-toposes" (though we can deduce partial results about them by Yoneda embedding). 4 Not the full \internal language hypothesis" that some \homotopy theory of type theories" is equivalent to the homotopy theory of some kind of (1; 1)-category. Only a unidirectional interpretation | in the useful direction! 5 We assume the initiality hypothesis: a \model of type theory" means a CwF.
    [Show full text]
  • Proof-Assistants Using Dependent Type Systems
    CHAPTER 18 Proof-Assistants Using Dependent Type Systems Henk Barendregt Herman Geuvers Contents I Proof checking 1151 2 Type-theoretic notions for proof checking 1153 2.1 Proof checking mathematical statements 1153 2.2 Propositions as types 1156 2.3 Examples of proofs as terms 1157 2.4 Intermezzo: Logical frameworks. 1160 2.5 Functions: algorithms versus graphs 1164 2.6 Subject Reduction . 1166 2.7 Conversion and Computation 1166 2.8 Equality . 1168 2.9 Connection between logic and type theory 1175 3 Type systems for proof checking 1180 3. l Higher order predicate logic . 1181 3.2 Higher order typed A-calculus . 1185 3.3 Pure Type Systems 1196 3.4 Properties of P ure Type Systems . 1199 3.5 Extensions of Pure Type Systems 1202 3.6 Products and Sums 1202 3.7 E-typcs 1204 3.8 Inductive Types 1206 4 Proof-development in type systems 1211 4.1 Tactics 1212 4.2 Examples of Proof Development 1214 4.3 Autarkic Computations 1220 5 P roof assistants 1223 5.1 Comparing proof-assistants . 1224 5.2 Applications of proof-assistants 1228 Bibliography 1230 Index 1235 Name index 1238 HANDBOOK OF AUTOMAT8D REASONING Edited by Alan Robinson and Andrei Voronkov © 2001 Elsevier Science Publishers 8.V. All rights reserved PROOF-ASSISTANTS USING DEPENDENT TYPE SYSTEMS 1151 I. Proof checking Proof checking consists of the automated verification of mathematical theories by first fully formalizing the underlying primitive notions, the definitions, the axioms and the proofs. Then the definitions are checked for their well-formedness and the proofs for their correctness, all this within a given logic.
    [Show full text]
  • Proof Theory of Constructive Systems: Inductive Types and Univalence
    Proof Theory of Constructive Systems: Inductive Types and Univalence Michael Rathjen Department of Pure Mathematics University of Leeds Leeds LS2 9JT, England [email protected] Abstract In Feferman’s work, explicit mathematics and theories of generalized inductive definitions play a cen- tral role. One objective of this article is to describe the connections with Martin-L¨of type theory and constructive Zermelo-Fraenkel set theory. Proof theory has contributed to a deeper grasp of the rela- tionship between different frameworks for constructive mathematics. Some of the reductions are known only through ordinal-theoretic characterizations. The paper also addresses the strength of Voevodsky’s univalence axiom. A further goal is to investigate the strength of intuitionistic theories of generalized inductive definitions in the framework of intuitionistic explicit mathematics that lie beyond the reach of Martin-L¨of type theory. Key words: Explicit mathematics, constructive Zermelo-Fraenkel set theory, Martin-L¨of type theory, univalence axiom, proof-theoretic strength MSC 03F30 03F50 03C62 1 Introduction Intuitionistic systems of inductive definitions have figured prominently in Solomon Feferman’s program of reducing classical subsystems of analysis and theories of iterated inductive definitions to constructive theories of various kinds. In the special case of classical theories of finitely as well as transfinitely iterated inductive definitions, where the iteration occurs along a computable well-ordering, the program was mainly completed by Buchholz, Pohlers, and Sieg more than 30 years ago (see [13, 19]). For stronger theories of inductive 1 i definitions such as those based on Feferman’s intutitionic Explicit Mathematics (T0) some answers have been provided in the last 10 years while some questions are still open.
    [Show full text]
  • CS 6110 S18 Lecture 32 Dependent Types 1 Typing Lists with Lengths
    CS 6110 S18 Lecture 32 Dependent Types When we added kinding last time, part of the motivation was to complement the functions from types to terms that we had in System F with functions from types to types. Of course, all of these languages have plain functions from terms to terms. So it's natural to wonder what would happen if we added functions from values to types. The result is a language with \compile-time" types that can depend on \run-time" values. While this arrangement might seem paradoxical, it is a very powerful way to express the correctness of programs; and via the propositions-as-types principle, it also serves as the foundation for a modern crop of interactive theorem provers. The language feature is called dependent types (i.e., types depend on terms). Prominent dependently-typed languages include Coq, Nuprl, Agda, Lean, F*, and Idris. Some of these languages, like Coq and Nuprl, are more oriented toward proving things using propositions as types, and others, like F* and Idris, are more oriented toward writing \normal programs" with strong correctness guarantees. 1 Typing Lists with Lengths Dependent types can help avoid out-of-bounds errors by encoding the lengths of arrays as part of their type. Consider a plain recursive IList type that represents a list of any length. Using type operators, we might use a general type List that can be instantiated as List int, so its kind would be type ) type. But let's use a fixed element type for now. With dependent types, however, we can make IList a type constructor that takes a natural number as an argument, so IList n is a list of length n.
    [Show full text]
  • Reasoning in an ∞-Topos with Homotopy Type Theory
    Reasoning in an 1-topos with homotopy type theory Dan Christensen University of Western Ontario 1-Topos Institute, April 1, 2021 Outline: Introduction to homotopy type theory Examples of applications to 1-toposes 1 / 23 2 / 23 Motivation for Homotopy Type Theory People study type theory for many reasons. I'll highlight two: Its intrinsic homotopical/topological content. Things we prove in type theory are true in any 1-topos. Its suitability for computer formalization. This talk will focus on the first point. So, what is an 1-topos? 3 / 23 1-toposes An 1-category has objects, (1-)morphisms between objects, 2-morphisms between 1-morphisms, etc., with all k-morphisms invertible for k > 1. Alternatively: a category enriched over spaces. The prototypical example is the 1-category of spaces. An 1-topos is an 1-category C that shares many properties of the 1-category of spaces: C is presentable. In particular, C is cocomplete. C satisfies descent. In particular, C is locally cartesian closed. Examples include Spaces, slice categories such as Spaces/S1, and presheaves of Spaces, such as G-Spaces for a group G. If C is an 1-topos, so is every slice category C=X. 4 / 23 History of (Homotopy) Type Theory Dependent type theory was introduced in the 1970's by Per Martin-L¨of,building on work of Russell, Church and others. In 2006, Awodey, Warren, and Voevodsky discovered that dependent type theory has homotopical models, extending 1998 work of Hofmann and Streicher. At around this time, Voevodsky discovered his univalance axiom.
    [Show full text]
  • Dependent Types: Easy As PIE
    Dependent Types: Easy as PIE Work-In-Progress Project Description Dimitrios Vytiniotis and Stephanie Weirich University of Pennsylvania Abstract Dependent type systems allow for a rich set of program properties to be expressed and mechanically verified via type checking. However, despite their significant expres- sive power, dependent types have not yet advanced into mainstream programming languages. We believe the reason behind this omission is the large design space for dependently typed functional programming languages, and the consequent lack of ex- perience in dependently-typed programming and language implementations. In this newly-started project, we lay out the design considerations for a general-purpose, ef- fectful, functional, dependently-typed language, called PIE. The goal of this project is to promote dependently-typed programming to a mainstream practice. 1 INTRODUCTION The goal of static type systems is to identify programs that contain errors. The type systems of functional languages, such as ML and Haskell, have been very successful in this respect. However, these systems can ensure only relatively weak safety properties—there is a wide range of semantic errors that these systems can- not eliminate. As a result, there is growing consensus [13, 15, 28, 27, 26, 6, 7, 20, 21, 16, 11, 2, 25, 19, 1, 22] that the right way to make static type systems more expressive in this respect is to adopt ideas from dependent type theory [12]. Types in dependent type systems can carry significant information about program values. For example, a datatype for network packets may describe the internal byte align- ment of variable-length subfields. In such precise type systems, programmers can express many of complex properties about programs—e.g.
    [Show full text]
  • Constructive Set Theory July, 2008, Mathlogaps Workshop, Manchester
    Constructive Set Theory July, 2008, Mathlogaps workshop, Manchester . Peter Aczel [email protected] Manchester University Constructive Set Theory – p.1/88 Plan of lectures Lecture 1 1: Background to CST 2: The axiom system CZF Lecture 2 3: The number systems in CZF 4: The constructive notion of set Lectures 3,4 ? 5: Inductive definitions 6: Locales and/or 7: Coinductive definitions Constructive Set Theory – p.2/88 1: Background to CST Constructive Set Theory – p.3/88 Some brands of constructive mathematics B1: Intuitionism (Brouwer, Heyting, ..., Veldman) B2: ‘Russian’ constructivism (Markov,...) B3: ‘American’ constructivism (Bishop, Bridges,...) B4: ‘European’ constructivism (Martin-Löf, Sambin,...) B1,B2 contradict classical mathematics; e.g. B1 : All functions R → R are continuous, B2 : All functions N → N are recursive (i.e. CT). B3 is compatible with each of classical maths, B1,B2 and forms their common core. B4 is a more philosophical foundational approach to B3. All B1-B4 accept RDC and so DC and CC. Constructive Set Theory – p.4/88 Some liberal brands of mathematics using intuitionistic logic B5: Topos mathematics (Lawvere, Johnstone,...) B6: Liberal Intuitionism (Mayberry,...) B5 does not use any choice principles. B6 accepts Restricted EM. B7: A minimalist, non-ideological approach: The aim is to do as much mainstream constructive mathematics as possible in a weak framework that is common to all brands, and explore the variety of possible extensions. Constructive Set Theory – p.5/88 Some settings for constructive mathematics type theoretical category theoretical set theoretical Constructive Set Theory – p.6/88 Some contrasts classical logic versus intuitionistic logic impredicative versus predicative some choice versus no choice intensional versus extensional consistent with EM versus inconsistent with EM Constructive Set Theory – p.7/88 Mathematical Taboos A mathematical taboo is a statement that we may not want to assume false, but we definately do not want to be able to prove.
    [Show full text]
  • Collection Principles in Dependent Type Theory
    This is a repository copy of Collection Principles in Dependent Type Theory. White Rose Research Online URL for this paper: http://eprints.whiterose.ac.uk/113157/ Version: Accepted Version Proceedings Paper: Azcel, P and Gambino, N orcid.org/0000-0002-4257-3590 (2002) Collection Principles in Dependent Type Theory. In: Lecture Notes in Computer Science: TYPES 2000. International Workshop on Types for Proofs and Programs (TYPES) 2000, 08-12 Dec 2000, Durham, UK. Springer Verlag , pp. 1-23. ISBN 3-540-43287-6 © 2002, Springer-Verlag Berlin Heidelberg. This is an author produced version of a conference paper published in Lecture Notes in Computer Science: Types for Proofs and Programs. Uploaded in accordance with the publisher's self-archiving policy. Reuse Items deposited in White Rose Research Online are protected by copyright, with all rights reserved unless indicated otherwise. They may be downloaded and/or printed for private study, or other acts as permitted by national copyright laws. The publisher or other rights holders may allow further reproduction and re-use of the full text version. This is indicated by the licence information on the White Rose Research Online record for the item. Takedown If you consider content in White Rose Research Online to be in breach of UK law, please notify us by emailing [email protected] including the URL of the record and the reason for the withdrawal request. [email protected] https://eprints.whiterose.ac.uk/ Collection Principles in Dependent Type Theory⋆ Peter Aczel1 and Nicola Gambino2 1 Departments of Mathematics and Computer Science, University of Manchester, e-mail: [email protected] 2 Department of Computer Science, University of Manchester, e-mail: [email protected] Abstract.
    [Show full text]
  • A Dependently Typed Calculus with Polymorphic Subtyping
    A Dependently Typed Calculus with Polymorphic Subtyping Mingqi Xue, Bruno C. d. S. Oliveira The University of Hong Kong Abstract A polymorphic subtyping relation, which relates more general types to more specific ones, is at the core of many modern functional languages. As those lan- guages start moving towards dependently typed programming a natural question is how can polymorphic subtyping be adapted to such settings. ∀ This paper presents the dependent implicitly polymorphic calculus (λI ): a simple dependently typed calculus with polymorphic subtyping. The subtyp- ∀ ing relation in λI generalizes the well-known polymorphic subtyping relation ∀ by Odersky and Läufer (1996). Because λI is dependently typed, integrating subtyping in the calculus is non-trivial. To overcome many of the issues arising from integrating subtyping with dependent types, the calculus employs unified subtyping, which is a technique that unifies typing and subtyping into a single re- ∀ lation. Moreover, λI employs explicit casts instead of a conversion rule, allowing unrestricted recursion to be naturally supported. We prove various non-trivial ∀ results, including type soundness and transitivity of unified subtyping. λI and all corresponding proofs are mechanized in the Coq theorem prover. Keywords: Type Systems, Dependent Types, Subtyping, Polymorphism 1. Introduction A polymorphic subtyping relation, which relates more general types to more specific ones, is at the core of many modern functional languages. Polymor- phic subtyping enables a form of (implicit) parametric polymorphism, where type arguments to polymorphic functions are automatically instantiated and the programmer does not specify them. Traditionally, variants of polymorphic sub- typing (in the form of a more-general-than relation) have been used in functional languages based on the Hindley-Milner (Hindley, 1969; Milner, 1978; Damas and Milner, 1982) type system, which supports full type-inference without any type annotations.
    [Show full text]
  • Type Theory & Functional Programming
    Type Theory & Functional Programming Simon Thompson Computing Laboratory, University of Kent March 1999 c Simon Thompson, 1999 Not to be reproduced i ii To my parents Preface Constructive Type theory has been a topic of research interest to computer scientists, mathematicians, logicians and philosophers for a number of years. For computer scientists it provides a framework which brings together logic and programming languages in a most elegant and fertile way: program development and verification can proceed within a single system. Viewed in a different way, type theory is a functional programming language with some novel features, such as the totality of all its functions, its expressive type system allowing functions whose result type depends upon the value of its input, and sophisticated modules and abstract types whose interfaces can contain logical assertions as well as signature information. A third point of view emphasizes that programs (or functions) can be extracted from proofs in the logic. Up until now most of the material on type theory has only appeared in proceedings of conferences and in research papers, so it seems appropriate to try to set down the current state of development in a form accessible to interested final-year undergraduates, graduate students, research workers and teachers in computer science and related fields – hence this book. The book can be thought of as giving both a first and a second course in type theory. We begin with introductory material on logic and functional programming, and follow this by presenting the system of type theory itself, together with many examples. As well as this we go further, looking at the system from a mathematical perspective, thus elucidating a number of its important properties.
    [Show full text]