10
$\begingroup$

In type theory, the dependent sum $\sum_{x : A} T(x)$ and the dependent product $\prod_{x:A} T(x)$ are defined by their introduction/elimination rules.

In category theory, we use a base-change functor. Given a morphism $f \colon b \to a$, we define the functor $f^* \colon C/a \to C/b$ between slice categories using a pullback. The dependent sum $\sum_f$ is then defined as the left adjoint, and the dependent product $\prod_f$ as the right adjoint to $f^*$.

My question is, what's the interpretation of $f$ ? It doesn't show in the type-theoretical definitions. It looks like one can get the type-theoretical definitions by picking $a$ to be the terminal object, with $f \colon b \to 1$ the unique terminal morphism $!$. Is there more to it?

$\endgroup$

2 Answers 2

12
$\begingroup$

The morphism $f$ is invisible in type theory because it corresponds to weakening, which in type theory appears as context extension, rather than an explicitly applied substitution.

Type-theoretic explanation

More precisely, given a context $\Gamma$ and a type family $\Gamma \vdash A \; \mathsf{type}$ there is a substitution $\iota : (\Gamma, x {:} A) \to \Gamma$ which takes each variable $y \in \Gamma$ to itself (but is not identity, it's shifting in terms of de Bruijn indices). This is your $f$. It induces a weakening operation $\iota^{*} : \mathsf{Type}(\Gamma) \to \mathsf{Type}(\Gamma, x{:}A)$ that takes a type family over $\Gamma$ to a type family over $\Gamma, x {:} A$. The dependent product and sum go in the opposite direction $$\Pi, \Sigma : \mathsf{Type}(\Gamma, x{:}A) \to \mathsf{Type}(\Gamma)$$ and their rules state precisely that there are adjunctions $\Sigma \vdash \iota^{*} \vdash \Pi$.

Set-theoretic explanation

Let us also explain what $\iota$ corresponds to set-theoretically. There are two equivalent ways of giving a set-theoretic interpretation, namely families and display maps. You indicated in your question that you prefer the latter, so let us use that. (The families are more natural, please consult Section 5.1 of my notes on realizability for details.)

A context is a set. The empty context is the singleton set.

A type family $\Gamma \vdash A \; \mathsf{type}$ is an element of the slice $\mathsf{Set}/\Gamma$, which we write as $p_A : \overline{A} \to \Gamma$.

A term of type $A$ in context $\Gamma$ is a section $t : \Gamma \to \overline{A}$ of $p_A$, i.e., it has to satisfy $p_A \circ t = \mathsf{id}$. In particular, this means that from $t(\gamma) \in \overline{A}$ we can reconstruct $\gamma = p_A(t(\gamma))$, which means that $t(\gamma)$ should not be thought of as "one element of $A$", but rather as "one element of $A$ together with an environment $\gamma$".

Given a type family $p_A : \overline{A} \to \Gamma$, the context extension $\Gamma, x {:} A$ is the set $\overline{A}$.

A substitution is a map $\sigma : \Gamma \to \Delta$. Specifically, the above substitution $\iota : (\Gamma, x {:} A) \to \Gamma$ is just the map $p_A : \overline{A} \to \Gamma$.

The action of $\sigma : \Gamma \to \Delta$ is pullback $$\sigma^* : \mathsf{Set}/\Delta \to \mathsf{Set}/\Gamma.$$ When we plug in $p_A$ we get the pullback $$p_A* : \mathsf{Set}/\Gamma \to \mathsf{Set}/\overline{A}.$$ It has left and right adjoints $\Sigma_A \dashv p_A^* \dashv \Pi_A$. I can spell them out if you wish.

$\endgroup$
5
  • $\begingroup$ I guess my problem is that I'm used to thinking of types as bona fide sets and terms as functions (closures). Bigger context means bigger set (a product of more sets). But your $\iota$ or my $f$ is not a function, is it? And an empty context (terminal object) is not a singleton? $\endgroup$ Commented May 11, 2023 at 10:52
  • 1
    $\begingroup$ @BartoszMilewski: you can view $\iota$ here as the projection function $\pi_1$ from a pullback. The empty context can be interpreted as a singleton set. $\endgroup$
    – varkor
    Commented May 11, 2023 at 15:31
  • $\begingroup$ I spelled out the set-theoretic interpretation using display maps. You can read about the (more reasonable) set-theoretic interpretation in terms of families in my notes, linked to in the answer. $\endgroup$ Commented May 11, 2023 at 16:24
  • $\begingroup$ @AndrejBauer: So am I to understand that the type-theoretic dependent sum/product is just a special case of $f = \sigma = p_A$? BTW, thanks for the link to your notes. It looks like a real treasure trove of information linking math to programming. $\endgroup$ Commented May 11, 2023 at 17:26
  • $\begingroup$ Yes, the type-theoretic sum and product are both adjoint to $p_A$, so that's actually the only pullback you care about. However, in sets every $f : X \to Y$ is isomorphic to some such $p_A$, so at least there considering products and sums adjoint to $p_A^*$ is not really less general than considering products and sums adjoint to $f^*$ for a general $f$. $\endgroup$ Commented May 11, 2023 at 19:38
7
$\begingroup$

Categorically, the right adjoint $\Pi_f$ exists when $f$ is exponentiable. In the categorical semantics of type theory, exponentiable maps correspond to the display maps. There are several ways one can think of display maps, but a simple way is to view a display map $f \colon B \to A$ as representing a type $B$ that depends on $A$. This means that whenever we have a context containing a variable of type $B$, we can form a term of type $A$. Type theoretically, we might write this as $a : A, b : B(a) \vdash a \colon A$ (or possibly leaving $a : A$ in the context implicit).

The base change functor $f^*$ therefore sends a morphism $t \colon \Gamma \to A$, understood as a term $\Gamma \vdash t : A$, to the projection morphism $f^* t \colon \Gamma \times_A B \to B$ from the pullback, which is understood to represent the term $\Gamma, b : B(t) \vdash b : B(t)$. (This is the mantra "pullback is substitution", or more specifically, "pullback is term-in-type substitution".)

If $B$ does not depend on a type $A$, then the display map is the unique morphism $! \colon B \to 1$, as in your example. So your interpretation is correct when there is no type dependency, but you need to be more careful when dealing with dependent types.

$\endgroup$
5
  • 1
    $\begingroup$ Note that $t$ should be a morphism in the slice category over $\Gamma$ to represent a term. And, just to put a fine point on it, in the model of type theory in a locally Cartesian closed category, every morphism $f : X \to Y$ is a display map and therefore should be interpreted as a type in $Y$ such that the extension of $Y$ by this type is precisely $X$. The right adjoint $f_*$ then corresponds to taking a dependent product over this type. $\endgroup$ Commented May 10, 2023 at 13:51
  • 1
    $\begingroup$ My understanding is that, if $a : A \vdash B(a)\ \mathrm{type}$, then a term $\Gamma \vdash s : B$ can be represented either as a morphism $\Gamma \to B$ in $\mathscr C$ or as a morphism $\Gamma \to \Gamma \times_A B$ in $\mathscr C/\Gamma$, but the two are equivalent by the universal property of the pullback. I agree with the other points, though. $\endgroup$
    – varkor
    Commented May 10, 2023 at 14:32
  • $\begingroup$ I'm having some trouble type-checking this comment. I assumed $A$ was a type in context $\Gamma$, in which case $\Gamma \vdash t : A$ (and $t$ has type $A$ not $B$ above I think) would need to be formulated in the slice over $\Gamma$. If instead $A$ is closed then this isn't necessary. However, I'm having trouble understanding your comment regarding $s$ which seems distinct from the above? It appears that $s$ is meant to be an element of $B(t)$ where $\Gamma \vdash t : A$ and $A$ is a closed type, is that correct? $\endgroup$ Commented May 14, 2023 at 9:49
  • $\begingroup$ To be honest, I think that it is difficult to have this sort of technical discussion in the comments section of MO, and the character limit is going to make it easy to cause undue confusion. Since Andrej Bauer's answer has clarified OP's question, it also doesn't seem so worthwhile to modify mine further; it may be simpler to delete my answer. My general impression, though, is that we are interpreting the semantics of a term in a dependent type theory differently: since categories with finite limits have a lot of redundancy in a certain sense (as some morphisms determine others), there (1/2) $\endgroup$
    – varkor
    Commented May 14, 2023 at 11:36
  • $\begingroup$ are multiple ways to represent a single term. Working over a slice is one way to capture the dependency structure, but it is not necessary to do so. Dependency can be captured instead by working in the original category, and identifying dependencies by projecting out of pullbacks. (I feel this comment is probably not very clear, and I really need more space to make it clear.) Perhaps this is a conversation that could be had elsewhere, without MO's limitations, though. (2/2) $\endgroup$
    – varkor
    Commented May 14, 2023 at 11:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .