# nLab relation between type theory and category theory

under construction

category theory

# Contents

## Idea

Type theory and certain kinds of category theory are closely related. By a syntax-semantics duality one may view type theory as a formal syntactic language or calculus for category theory, and conversely one may think of category theory as providing semantics for type theory. The flavor of category theory used depends on the flavor of type theory; this also extends to homotopy type theory and certain kinds of (∞,1)-category theory.

## Overview

flavor of type theory$\phantom{\rule{thickmathspace}{0ex}}$equivalent to$\phantom{\rule{thickmathspace}{0ex}}$flavor of category theory
intuitionistic propositional logic?/simply-typed lambda calculus?cartesian closed category
multiplicative intuitionistic linear logic?symmetric closed monoidal category
classical linear logic?star-autonomous category
first-order logichyperdoctrine(Seely 1984a)
Martin-Löf dependent type theorylocally cartesian closed category(Seely 1984b)
homotopy type theorylocally cartesian closed (∞,1)-category(conjectural)
homotopy type theory with higher inductive types and univalenceelementary (∞,1)-topos(conjectural)

## Theorems

We discuss here formalizations and proofs of the relation/equivalence between various flavors of type theories and the corresponding flavors of categories.

### First-order logic and hyperdoctrines

###### Theorem

The functors

constitute an equivalence of categories

$\mathrm{FirstOrderTheories}\stackrel{\stackrel{\mathrm{Lang}}{←}}{\underset{\mathrm{Cont}}{\to }}\mathrm{Hyperdoctrines}\phantom{\rule{thinmathspace}{0ex}}.$FirstOrderTheories \stackrel{\overset{Lang}{\leftarrow}}{\underset{Cont}{\to}} Hyperdoctrines \,.

### Martin-Löf dependent type theory and locally cartesian closed categories

###### Theorem

There are 2-functors

that constitute an equivalence of 2-categories

$\mathrm{MLDependentTypeTheories}\stackrel{\stackrel{\mathrm{Lang}}{←}}{\underset{\mathrm{Cont}}{\to }}\mathrm{LocallyCartesianClosedCategories}\phantom{\rule{thinmathspace}{0ex}}.$MLDependentTypeTheories \stackrel{\overset{Lang}{\leftarrow}}{\underset{Cont}{\to}} LocallyCartesianClosedCategories \,.

This was originally claimed as an equivalence of categories (Seely, theorem 6.3). However, that argument did not properly treat a subtlety central to the whole subject: that substitution of terms for variables composes strictly, while its categorical semantics by pullback is by the very nature of pullbacks only defined up to isomorphism. This problem was pointed out and ways to fix it were given in (Curien) and (Hofmann); see categorical model of dependent types for the latter. However, the full equivalence of categories was not recovered until (Clairambault-Dybjer) solved both problems by promoting the statement to an equivalence of 2-categories.

We now indicate some of the details.

#### Type theories

For definiteness, self-containedness and for references below, we say what a dependent type theory is, following (Seely, def. 1.1).

###### Definition

A Martin-Löf dependent type theory $T$ is a theory with some signature of dependent function symbols with values in types and in terms (…) subject to the following rules

1. type formation rules

1. $1$ is a type (the unit type);

2. if $a,b$ are terms of type $A$, then $\left(a=b\right)$ is a type (the equality type);

3. if $A$ and $B\left[x\right]$ are types, $B$ depending on a free variable of type $A$, then the following symbols are types

1. ${\prod }_{a:A}B\left[a\right]$ (dependent product), written also $\left(A\to B\right)$ if $B\left[x\right]$ in fact does not depend on $x$;

2. ${\sum }_{a:A}B\left[a\right]$ (dependent sum), written also $A×B$ if $B\left[x\right]$ in fact does not depend on $x$;

2. term formation rules

1. $*\in 1$ is a term of the unit type;

2. (…)

3. equality rules

1. (…)

#### Category of contexts

###### Definition

Given a dependent type theory $T$, its category of contexts $\mathrm{Con}\left(T\right)$ is the category whose

• objects are the types of $T$;

• morphisms $f:A\to B$ are the terms $f$ of function type $A\to B$.

Composition is given in the evident way.

###### Proposition

$\mathrm{Con}\left(T\right)$ has finite limits and is a cartesian closed category.

###### Proof

Constructions are straightforward. We indicated some of them.

Notice that all finite limits (as discussed there) are induced as soon as there are all pullbacks and equalizers. A pullback in $\mathrm{Con}\left(T\right)$

$\begin{array}{ccc}P& \to & A\\ ↓& & {↓}^{f}\\ B& \stackrel{g}{\to }& C\end{array}$\array{ P &\to& A \\ \downarrow && \downarrow^{\mathrlap{f}} \\ B &\stackrel{g}{\to}& C }

is given by

$P\simeq \sum _{a:A}\sum _{b\in B}\left(f\left(a\right)=g\left(b\right)\right)\phantom{\rule{thinmathspace}{0ex}}.$P \simeq \sum_{a : A} \sum_{b \in B} (f(a) = g(b)) \,.

The equalizer

$P\to A\stackrel{\stackrel{f}{\to }}{\underset{g}{\to }}B$P \to A \stackrel{\overset{f}{\to}}{\underset{g}{\to}} B

is given by

$P=\sum _{a:A}\left(f\left(a\right)=g\left(a\right)\right)\phantom{\rule{thinmathspace}{0ex}}.$P = \sum_{a : A} (f(a) = g(a)) \,.

Next, the internal hom/exponential object is given by function type

$\left[A,B\right]\simeq \left(A\to B\right)\phantom{\rule{thinmathspace}{0ex}}.$[A,B] \simeq (A \to B) \,.
###### Proposition

$\mathrm{Con}\left(T\right)$ is a locally cartesian closed category.

###### Proof

Define the $\mathrm{Con}\left(T\right)$-indexed hyperdoctrine $P\left(T\right)$ by taking for $A\in \mathrm{Con}\left(T\right)$ the category $P\left(T\right)\left(A\right)$ to have as objects the $A$-dependent types and as morphisms $\left(a:A⊢X\left(a\right):\mathrm{type}\right)\to \left(a:A⊢Y\left(a\right):\mathrm{type}\right)$ the terms of dependent function type $\left(a:A⊢t:\left(X\left(a\right)\to Y\left(a\right)\right)\right)$.

This is cartesian closed by the same kind of argument as in the previous proof. It is now sufficient to exhibit a compatible equivalence of categories with the slice category $\mathrm{Con}\left(T{\right)}_{/A}$.

$\mathrm{Con}\left(T{\right)}_{/A}\simeq P\left(T\right)\left(A\right)\phantom{\rule{thinmathspace}{0ex}}.$Con(T)_{/A} \simeq P(T)(A) \,.

In one direction, send a morphism $f:X\to A$ to the dependent type

$a:A⊢{f}^{-1}\left(a\right)≔\sum _{x:X}\left(a=f\left(x\right)\right)\phantom{\rule{thinmathspace}{0ex}}.$a : A \vdash f^{-1}(a) \coloneqq \sum_{x : X} (a = f(x)) \,.

Conversely, for $a:A⊢X\left(a\right)$ a dependent type, send it to the projection ${\sum }_{a:A}X\left(a\right)\to A$.

One shows that this indeed gives an equivalence of categories which is compatible with base change (Seely, prop. 3.2.4).

###### Definition

For $T$ a dependent type theory and $C$ a locally cartesian closed category, an interpretation of $T$ in $C$ is a morphism of locally cartesian closed categories

$\mathrm{Con}\left(T\right)\to C\phantom{\rule{thinmathspace}{0ex}}.$Con(T) \to C \,.

An interpretation of $T$ in another dependent type theory $T\prime$ is a morphism of locally cartesian closed categories

$\mathrm{Con}\left(T\right)\to \mathrm{Con}\left(T\prime \right)\phantom{\rule{thinmathspace}{0ex}}.$Con(T) \to Con(T') \,.

#### Internal language

###### Proposition

Given a locally cartesian closed category $C$, define the corresponding dependent type theory $\mathrm{Lang}\left(C\right)$ as follows

• the non-dependent types of $\mathrm{Lang}\left(C\right)$ are the objects of $C$;

• the $A$-dependent types are the morphisms $B\to A$;

• a context ${x}_{1}:X,{x}_{2}:X,\cdots ,{x}_{n}:{X}_{n}$ is a tower of morphisms

$\begin{array}{c}{X}_{n}\\ ↓\\ \cdots \\ ↓\\ {X}_{2}\\ ↓\\ {X}_{1}\end{array}$\array{ X_n \\ \downarrow \\ \cdots \\ \downarrow \\ X_2 \\ \downarrow \\ X_1 }
• the terms $t\left[{x}_{A}\right]:B\left[{x}_{A}\right]$ are the sections $A\to B$ in ${C}_{/A}$

• the equality type $\left({x}_{A}={y}_{A}\right)$ is the diagonal $A\to A×A$

### Homotopy type theory and locally cartesian closed $\left(\infty ,1\right)$-categories

All this has a higher analog in (∞,1)-category theory and homotopy type theory.

###### Proposition

Every presentable and locally cartesian closed (∞,1)-category has a presentation by a type-theoretic model category. This provides the categorical semantics for homotopy type theory (without, possibly, the univalence axiom).

This includes in particular all (∞-stack-) (∞,1)-toposes (which should in addition satisfy univalence). See also at internal logic of an (∞,1)-topos.

For more on this see at locally cartesian closed (∞,1)-category] in the section on internal logic.

(…)

## References

The equivalence of categories between first order theories and hyperdoctrines is discussed in

• R. A. G. Seely, Hyperdoctrines, natural deduction, and the Beck condition, Zeitschrift für Math. Logik und grundlagen der Math. (1984) (pdf)

A lecture reviewing aspects involved in this equivalence is (see the discussion building up to the theorem on slide 96)

An adjunction between the category of type theories with product types and toposes is discussed in chapter II of

• Joachim Lambek, P. Scott, Introduction to higher order categorical logic, Cambridge University Press (1986) .

The equivalence of categories between locally cartesian closed categories and dependent type theories was originally claimed in

• R. A. G. Seely, Locally cartesian closed categories and type theory, Math. Proc. Camb. Phil. Soc. (1984) 95 (pdf)

following a statement earlier conjectured in

• Per Martin-Löf, An intuitionistic theory of types: predicative part, In Logic Colloquium (1973), ed. H. E. Rose and J. C. Shepherdson (North-Holland, 1974), 73-118. (web)

The problem with strict substitution compared to weak pullback in this argument was discussed and fixed in

• Pierre-Louis Curien, Substitution up to isomorphism, Fundamenta Informaticae, 19(1,2):51–86 (1993)
• Martin Hofmann, On the interpretation of type theory in locally cartesian closed categories, Proc. CSL ‘94, Kazimierz, Poland. Jerzy Tiuryn and Leszek Pacholski, eds. Springer LNCS, Vol. 933 (CiteSeer)

but in the process the equivalence of categories was lost. This was finally all rectified in

• Pierre Clairambault, Peter Dybjer, The Biequivalence of Locally Cartesian Closed Categories and Martin-Löf Type Theories, in Typed lambda calculi and applications, Lecture Notes in Comput. Sci. 6690, Springer 2011 (arXiv:1112.3456)

The analogous statement relating homotopy type theory and locally cartesian closed (infinity,1)-categories was conjectured around

The suggestion that with univalence this is refined to (∞,1)-topos theory appears around

A precise definition of elementary (infinity,1)-topos inspired by giving a natural equivalence to homotopy type theory with univalence was then proposed in

A discussion of the correspondence between type theories and categories of various sorts, from lex categories to toposes is in

• Maria Emilia Maietti, Modular correspondence between dependent type theories and categories including pretopoi and topoi, Math. Struct. in Comp. Science (2005), vol. 15, pp. 1089–1149 (gzipped ps) (doi)

Revised on November 4, 2013 03:17:53 by Urs Schreiber (89.204.139.245)