category theory

# Contents

## Idea

One may interpret mathematical logic as being a formal language for talking about the collection of monomorphisms into a given object of a given category: the poset of subobjects of that object.

More generally, one may interpret type theory and notably dependent type theory as being a formal language for talking about slice categories, consisting of all morphisms into a given object.

Conversely, starting with a given theory of logic or a given type theory, we say that it has a categorical semantics if there is a category such that the given theory is that of its slice categories, if it is the internal logic of that category.

## Definition

For the general idea, for the moment see at type theory the section An introduction for category theorists and see at relation between type theory and category theory.

### Of dependent type theory

We discuss how to interpret judgements of dependent type theory in a given category $𝒞$ with finite limits. For more see categorical model of dependent types.

Write $\mathrm{cod}:{𝒞}^{I}\to 𝒞$ for its codomain fibration, and write

$\chi :{𝒞}^{\mathrm{op}}\to \mathrm{Cat}$\chi : \mathcal{C}^{op} \to Cat

for the corresponding classifying functor, the self-indexing

$\chi :\Gamma ↦{𝒞}_{/\Gamma }$\chi : \Gamma \mapsto \mathcal{C}_{/\Gamma}

that sends an object of $𝒞$ to the slice category over it, and sends a morphism $f:\Gamma \to \Gamma \prime$ to the pullback/base change functor

${f}^{*}:{𝒞}_{/\Gamma \prime }\to {𝒞}_{/\Gamma }\phantom{\rule{thinmathspace}{0ex}}.$f^\ast : \mathcal{C}_{/\Gamma'} \to \mathcal{C}_{/\Gamma} \,.

We give now rules for choices ”$\left[xyz\right]$” that associate with every string ”$xyz$” of symbols in type theory objects and morphisms in $𝒞$. A collection of such choices following these rules an an interpretation / a choice of categorical semantics of the type theory in the category $𝒞$.

#### Contexts and type judgements

1. The empty context $\left(\right)$ in type theory is interpreted as the terminal object of $𝒞$

$\left[\left(\right)\right]:=*\phantom{\rule{thinmathspace}{0ex}}.$[ () ] := * \,.
2. If $\Gamma$ is a context which has already been given an interpretation $\left[\Gamma \right]\in \mathrm{Obj}\left(𝒞\right)$, then a judgement of the form

$\Gamma ⊢A:\mathrm{Type}$\Gamma \vdash A : Type

is interpreted as an object in the slice over $\Gamma$

$\left[\Gamma ⊢A:\mathrm{Type}\right]\in \mathrm{Obj}\left({𝒞}_{/\Gamma }\right)\phantom{\rule{thinmathspace}{0ex}},$[\Gamma \vdash A : Type] \in Obj(\mathcal{C}_{/\Gamma}) \,,

hence as a choice of morphism

$\begin{array}{c}\left[\left(\Gamma ,x:A\right)\right]\\ {↓}^{\left[\Gamma ⊢A:\mathrm{Type}\right]}\\ \left[\Gamma \right]\end{array}$\array{ [(\Gamma, x : A)] \\ \downarrow^{\mathrlap{[\Gamma \vdash A : Type]}} \\ [\Gamma] }

in $𝒞$.

3. If a judgement of the form $\Gamma ⊢A:\mathrm{Type}$ has already found an interpretation, as above, then an extended context of the form $\left(\Gamma ,x:A\right)$ is interpreted as the domain object $\left[\left(\Gamma ,x:A\right)\right]$ of the above choice of morphism.

#### Terms

Assume for a context $\Gamma$ and a judgement $\Gamma ⊢:A:\mathrm{Type}$ we have already chosen an interpretation $\left[\Gamma ,x:A\right]\stackrel{\left[\Gamma ⊢A:\mathrm{Type}\right]}{\to }\left[\Gamma \right]$ as above.

A judgement of the form $\Gamma ⊢a:A$ (a term of type $A$) is to be interpreted as a section of this morphism, equivalently as a morphism in ${𝒞}_{/\Gamma }$

$\left[\Gamma ⊢:a:A\right]:*\to \left[\Gamma ,x:A\right]$[\Gamma \vdash : a : A] : * \to [\Gamma, x : A]

from the terminal object to $\left[\Gamma ⊢A:\mathrm{Type}\right]$, which in $𝒞$ is a commuting triangle

$\begin{array}{ccccc}\left[\Gamma \right]& & \stackrel{\left[\left(\Gamma ⊢a:A\right)\right]}{\to }& & \left[\Gamma ,x:A\right]\\ & {}_{\left[\Gamma \right]}↘& & {↙}_{\left[\Gamma ⊢A:\mathrm{Type}\right]}\\ & & \left[\Gamma \right]\end{array}\phantom{\rule{thinmathspace}{0ex}}.$\array{ [\Gamma] &&\stackrel{[(\Gamma \vdash a : A)]}{\to}&& [\Gamma, x : A] \\ & {}_\mathllap{[\Gamma]}\searrow && \swarrow_{\mathrlap{[\Gamma \vdash A : Type]}} \\ && [\Gamma] } \,.

#### Variables

For a term $\Gamma ⊢a:A$ the context $\Gamma$ is the collection of free variables in $a$.

(…)

#### Substitution

Assume that interpretations for judgements

$\Gamma ,x:A⊢B\left(x\right):\mathrm{Type}$\Gamma , x : A \vdash B(x) : Type

and

$\Gamma ⊢a:A$\Gamma \vdash a : A

have been given as above. Then the substitution judgement

$\Gamma ⊢B\left[a/x\right]:\mathrm{Type}$\Gamma \vdash B[a/x] : Type

is to be interpreted as follows. The interpretation of the first two terms corresponds to a diagram in $𝒞$ of the form

$\begin{array}{ccccc}& & & & \left[\left(\Gamma ,x:A,y:B\left(x\right)\right)\right]\\ & & & & {↓}^{\left[\Gamma ,x:A⊢B\left(x\right):\mathrm{Type}\right]}\\ \left[\Gamma \right]& & \stackrel{\left[\Gamma ⊢a:A\right]}{\to }& & \left[\left(\Gamma ,x:A\right)\right]\\ & {}_{\mathrm{id}}↘& & {↙}_{\left[\Gamma ⊢A:\mathrm{Type}\right]}\\ & & \left[\Gamma \right]\end{array}$\array{ &&&& [(\Gamma, x : A, y : B(x))] \\ &&&& \downarrow^{\mathrlap{[\Gamma, x : A \vdash B(x) : Type]}} \\ [\Gamma] &&\stackrel{[\Gamma \vdash a : A]}{\to}&& [(\Gamma, x : A)] \\ & {}_{id}\searrow && \swarrow_{\mathrlap{[\Gamma \vdash A : Type]}} \\ && [\Gamma] }

The interpretation of the substitution statement is then the pullback

$\left[\Gamma ⊢B\left[a/x\right]:\mathrm{Type}\right]:=\left[\Gamma ⊢a:A{\right]}^{*}\left[\Gamma ,x:A⊢B\left(x\right):\mathrm{Type}\right]\phantom{\rule{thinmathspace}{0ex}},$[\Gamma \vdash B[a/x] : Type] := [\Gamma \vdash a : A]^* [\Gamma, x : A \vdash B(x) : Type] \,,

hence the morphism in $𝒞$ that universally completes the above diagram as

$\begin{array}{ccccc}\left[\left(\Gamma ,y:B\left[x/a\right]\right)\right]& & \to & & \left[\left(\Gamma ,x:A,y:B\left(x\right)\right)\right]\\ {}^{\left[\Gamma ⊢B\left[a/x\right]:\mathrm{Type}\right]}↓& & & & {↓}^{\left[\Gamma ,x:A⊢B\left(x\right):\mathrm{Type}\right]}\\ \left[\Gamma \right]& & \stackrel{\left[\Gamma ⊢a:A\right]}{\to }& & \left[\left(\Gamma ,x:A\right)\right]\\ & {}_{\mathrm{id}}↘& & {↙}_{\left[\Gamma ⊢A:\mathrm{Type}\right]}\\ & & \left[\Gamma \right]\end{array}$\array{ [(\Gamma, y : B[x/a])] &&\to&& [(\Gamma, x : A, y : B(x))] \\ {}^{\mathllap{[\Gamma \vdash B[a/x] : Type] }}\downarrow &&&& \downarrow^{\mathrlap{[\Gamma, x : A \vdash B(x) : Type]}} \\ [\Gamma] &&\stackrel{[\Gamma \vdash a : A]}{\to}&& [(\Gamma, x : A)] \\ & {}_{id}\searrow && \swarrow_{\mathrlap{[\Gamma \vdash A : Type]}} \\ && [\Gamma] }

## References

A standard textbook reference for categorical semantics of logic is section D1.2 of

A discussion of categorical semantics of type theory is for instance in

• Martin Hofmann, Syntax and semantics of dependent types, Semantics and Logics of Computation (P. Dybjer and A. M. Pitts, eds.), Publications of the Newton Institute, Cambridge University Press, Cambridge, (1997) pp. 79-130.

• Roy Crole, Categories for types