A Comparison Between ITT and Coc Categorical Models of Type Theories
Total Page:16
File Type:pdf, Size:1020Kb
Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks A comparison between ITT and CoC Categorical models of type theories Category Theory 2015 · Aveiro, PORTUGAL Nino Guallart July of 2015 beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Index 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Index 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Index 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Index 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Índice 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Introduction What is a type theory? Formal system of elements (terms), each of one belonging to a certain type. Originally proposed as an alternative to naïve set theory (Russell's paradox), we will see type theories formulated in l calculus. Everything is a function Church's lC was intended to study computable functions. It is Turing-complete and can be seen as an abstract model of a functional programming language (Landin, 1965). Whereas lC is untyped, simply typed lambda calculus (STLC) is typed, and therefore can be seen as the basis of typed functional programming languages (Haskell, ML). beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Introduction What is a type theory? Formal system of elements (terms), each of one belonging to a certain type. Originally proposed as an alternative to naïve set theory (Russell's paradox), we will see type theories formulated in l calculus. Everything is a function Church's lC was intended to study computable functions. It is Turing-complete and can be seen as an abstract model of a functional programming language (Landin, 1965). Whereas lC is untyped, simply typed lambda calculus (STLC) is typed, and therefore can be seen as the basis of typed functional programming languages (Haskell, ML). beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Semantics of type theories In this talk we will focus on the categorial semantics of STLC, before moving on a discussion of the categorical interpretation of more complex type theories. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Índice 1 Introduction 2 Simply typed lambda calculus 3 Higher-order type systems 4 Concluding remarks beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus l! e;f := xjcjlxt :ejef j s;t := bjs ! t beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus ls t e;f := xjcjlx :ejef j(e;f )jp1ejp1e s;t := bjs ! tjs × t lC syntax: l! and !. Type constructors: !, ×,(+). Base types. Void type: 0, with no terms. Unit type: 1, with one term, *. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus ls t e;f := xjcjlx :ejef j(e;f )jp1ejp1e s;t := bjs ! tjs × t lC syntax: l! and !. Type constructors: !, ×,(+). Base types. Void type: 0, with no terms. Unit type: 1, with one term, *. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus ls t e;f := xjcjlx :ejef j(e;f )jp1ejp1e s;t := bjs ! tjs × t lC syntax: l! and !. Type constructors: !, ×,(+). Base types. Void type: 0, with no terms. Unit type: 1, with one term, *. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus ls t e;f := xjcjlx :ejef j(e;f )jp1ejp1e s;t := bjs ! tjs × t lC syntax: l! and !. Type constructors: !, ×,(+). Base types. Void type: 0, with no terms. Unit type: 1, with one term, *. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus There are well-formed (pre)terms which are not well-typed, giving error: (lx : s:x)(a : t). From the set of preterms, let's consider the set Λ of well-typed terms, or simply terms. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus Typing rules for ! (application and abstraction): Γ;x : s ` e : t ABS Γ ` (lx : s:e):(s ! t) e f Γ ` : s ! t Γ ` : s APP Γ ` ef : t beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus Typing rules for × (introduction and elimination): t A u B Γ ` : Γ ` : PROD-INT Γ ` (t;u): A × B Γ ` (t;u): A × B PROD-EL1 p1(t;u): A Γ ` (t;u): A × B PROD-EL2 p2(t;u): B beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Simply typed lambda calculus Unlike LC, is decidable and non Turing-complete -> its evaluation always halts. Normalising: the reduction of a preterm always terminates. If is a term, it ends giving the normal form of the term. If not, giving out some kind of error or unspecied behaviour. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Term evaluation Based on b−reduction: (lx : s:E)F E-APP E[x := F ] t t0 t t0 ! E-APP1 ! E-APP2 tu ! t0u ut ! ut0 beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Syntax and semantics A STLC for natural numbers: ` 0 : N x N Γ ` : SUCC Γ ` sx : N Γ ` x : N Γ ` y : N SUM Γ ` x + y : N ... beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Syntax and semantics A STLC for natural numbers: ` 0 : N x N Γ ` : SUCC Γ ` sx : N Γ ` x : N Γ ` y : N SUM Γ ` x + y : N ... beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Syntax and semantics A STLC for natural numbers: ` 0 : N x N Γ ` : SUCC Γ ` sx : N Γ ` x : N Γ ` y : N SUM Γ ` x + y : N ... beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Curry-Howard isomorphism Predicates-as-types, link between type theory and logical calculus: Intuitionistic interpretation. If a type A has at least a term a, a : A, a is a proof of A. Lambda abstraction: hypotheses introduction. Term application equates to modus ponens: e f Γ ` : s ! t Γ ` : s APP Γ ` ef : t Rules for introduction and elimination of pairs (product) are akin to those of conjunction of predicates. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Curry-Howard isomorphism s;t ::= bjs ! tjs × tjs + tj0j1 p;q ::= bjp ! qjp ^ qjp _ qj?j> Types can be seen as propositions. Terms can be interpreted intuitionistically (BHK) as proofs (algorithms) of their corresponding types. For example, lxa :x is a proof of a ! a, which is a tautology (taulologies equate to combinators). Given a set of basic proofs with their types/propositions, we can build a proof of the propositions derived from them. beamer-icsi-logo Category Theory 2015 · Aveiro, PORTUGAL A comparison between ITT and CoC Introduction Simply typed lambda calculus Higher-order type systems Concluding remarks Categorical model of STLC Syntax-semantics duality between STLC and CCC (Lambek, 1970). More precisely, type theories can be interpreted using category theory, and conversely, we can formalise categories in the language of type theories.