Category Theory
Zulip Server
Archive

You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.


Stream: learning: questions

Topic: Categorical semantics of this dependent type


view this post on Zulip Bruno Gavranović (Jan 18 2024 at 22:07):

It's known that a dependent function type can be modeled as a morphism in the slice from the identity map. That is, the set of dependent functions Π(a:A).X(a)\Pi (a :A).X(a) in Set\mathbf{Set} is isomorphic to the set of morphisms Set/A(idA,πA)\mathbf{Set}/A(\text{id}_A, \pi_A), (where πA:Σ(a:A).X(a)A\pi_A : \Sigma (a :A).X(a) \to A is the projection). This allows us to move away from Set\mathbf{Set} and state this in an arbitrary category C\mathcal{C}.

It's also known that a dependent pair type is modeled simply as an object in the slice category. That is, Σ(a:A).X(a)\Sigma (a :A).X(a), together with the above projection, is simply an object of Set/A\mathbf{Set}/A.

But how do I state the following set --- a combination of these --- in an arbitrary category?

Π(a:A).Σ(b:B).R(a,b)\Pi (a :A) . \Sigma (b :B) . R(a, b)

I imagine this should be a morphism in the slice over AA, but I'm getting confused since at the end I'm producing something over BB. But it also can't be a map in slice over A×BA \times B since that would imply we're universally quantifying over (b:B)(b:B).

view this post on Zulip Mike Shulman (Jan 18 2024 at 23:11):

Your description of Π\Pi- and Σ\Sigma-types is a bit confused, which I think is what's producing your confusion about combining them. E.g. while "the set of morphisms from the identity in a slice category" can be stated in any category, it itself is only ever a set, whereas a Π\Pi-type in a category CC should also be a thing in CC.

view this post on Zulip Mike Shulman (Jan 18 2024 at 23:12):

A better way to think about it is that Σ(a:A)\Sigma(a:A) and Π(a:A)\Pi(a:A) are, respectively, left and right adjoints to pullback from CC to the slice C/AC/A. Or, more generally, from one slice C/ΓC/\Gamma to another C/AC/A, where AA is given as an object of C/ΓC/\Gamma (and type-theoretically we would tend to write something like Γ.A\Gamma.A instead of AA, to indicate that it's a "context extension").

view this post on Zulip Mike Shulman (Jan 18 2024 at 23:14):

The reason Σ\Sigma "is" an object of a slice category is that the left adjoint Σ:C/AC\Sigma : C/A \to C just forgets the map to AA, remembering only its domain.

view this post on Zulip Mike Shulman (Jan 18 2024 at 23:14):

So if AA and BB are both objects of CC (i.e. neither depends on the other), then R(a,b)R(a,b) would denote an object of the double slice C/(A×B)C/(A\times B), and Π(a:A).Σ(b:B).R(a,b)\Pi(a:A).\Sigma(b:B).R(a,b) would mean to first apply the left adjoint on BB, that is forgetting the map to BB, or equivalently composing the map RA×BR\to A\times B with the projection A×BAA\times B \to A, and then apply the right adjoint Π:C/AC\Pi : C/A \to C.

view this post on Zulip Dylan Braithwaite (Jan 18 2024 at 23:18):

I think the 'proper' way to think about this is using contexts. That is, where a type ΓT\Gamma \vdash T corresponds with an object of the slice category C/Γ\mathcal C / \Gamma.

The sigma and pi type formers then correspond to functors between the slice categories: if Γ,x:TU(x)\Gamma, x : T \vdash U(x) corresponds with an object (U,p)C/(Γ×T)(U, p) \in \mathcal C/(\Gamma \times T) then the sigma-type ΓΣ(x:T)U(x)\Gamma \vdash \Sigma(x : T) U(x) corresponds with the object ΣTUC/Γ\Sigma_T U \in \mathcal C/\Gamma defined by UpΓ×TπΓΓU \xrightarrow{p} \Gamma \times T \xrightarrow{\pi_\Gamma} \Gamma.

Similarly, if C\mathcal C is locally cartesian closed then you get a functor ΠT:C/(Γ×T)C/Γ\Pi_T : \mathcal C / (\Gamma \times T) \to \mathcal C / \Gamma.

So for the expression you've written you start with something a:A,b:BR(a,b)a : A, b : B \vdash R(a, b) which is interpreted as an object of C/(A×B)\mathcal C/(A \times B), then a:AΣ(b:B).R(a,b)a : A \vdash \Sigma (b : B) . R(a, b) is an object of C/A\mathcal C/A and Π(a:A).Σ(b:B).R(a,b)\vdash \Pi(a : A) . \Sigma (b : B) . R(a, b) is an object of C/1\mathcal C/1.

(Mikes message came in just as I finished typing this, but I'll send it anyway, in case it helps to have the same thing written two ways)

view this post on Zulip Dylan Braithwaite (Jan 18 2024 at 23:42):

Also, you can see where the expression you have (for the set of dependent functions) comes from, using the adjunction between ΠA\Pi_A and the pullback functor !A:CC/A!_A^* : \mathcal C \to \mathcal C/A. (I'm writing !A!_A to mean the terminal map A1A \to 1).

!AΠA!_A^* \dashv \Pi_A means that C(1,ΠAX)C/A(!A(1),X)\mathcal C(1, \Pi_A X) \cong \mathcal C/A(!_A^*(1), X), and !A(1)=idA!_A^*(1) = \mathrm{id}_A, so points of ΠAX\Pi_A X are equivalently elements of C/A(idA,X)\mathcal C/A(\mathrm{id}_A, X).

view this post on Zulip Bruno Gavranović (Jan 19 2024 at 16:05):

Thanks for the answers. Let me check if I understand what you mean.

It sounds like you're suggesting I should make a distinction between

You seem to be suggesting that I should call only the latter a sigma type (is that what you're suggesting?).
Now, I understand the idea of interpreting the latter as a term in a trivial context where the original (a:A)(a:A) is now existentially quantified. But I'm confused by the fact that: a) now this term is not 'over' anything. The whole thing about categorical semantics of dependent types is that we think of things being over one another, no?, and b) in the former, (a:A)(a:A) also appears existentially quantified (in (Σ(a:A).A(A),π)(\Sigma (a : A) . A'(A), \pi)). If this is not to be thought of as a sigma type, then what is this?

view this post on Zulip Dylan Braithwaite (Jan 19 2024 at 16:34):

Bruno Gavranović said:

The whole thing about categorical semantics of dependent types is that we think of things being over one another, no?

Yes, but the thing that we think of types being over is contexts. ΓT\Gamma \vdash T is a type defined over Γ\Gamma and that's reflected in the way it's interpreted as an object of the fibre over Γ\Gamma. The sigma type moves this 'overness' into the object, so that we can talk about closed types which are still dependent. It would be a bit weird if we couldn't give semantics to an arbitrary type T\cdot \vdash T without first looking inside TT to decide which category it belongs in.

It's a similar situation to the use of exponentials in the semantics of simple type theory. You could say the whole thing about categorical semantics of simple types is that we can think of types as morphisms with a domain and codomain, but we still interpret function types as an object of a CCC rather than a morphism, because without that we can't talk about higher order functions. You run into the same thing with the semantics of dependent types because you can't talk about "higher order" dependent types without internalising some of information about the dependence into the object.

view this post on Zulip Dylan Braithwaite (Jan 19 2024 at 16:45):

Bruno Gavranović said:

in the former, $(a:A)$ also appears existentially quantified (in $(\Sigma (a : A) . A'(A), \pi)$). If this is not to be thought of as a sigma type, then what is this?

In the first bullet point you're using the sigma to describe an object of Set\mathbf{Set} whereas in the second you're using the sigma to describe a type in the type theory so these are different situations. But all the same, even in writing that, you have run into a reason why sigma-types should be interpreted in that way, maybe without realising it.

To describe an object of C/A\mathcal C/A you must give an object XX of C\mathcal C and a morphism XAX \to A. You did this by giving an object Σ(a:A).A(A)\Sigma(a : A) . A'(A), but if sigma-types were to be interpreted as an object of C/A\mathcal C/A then this wouldn't type-check, because you gave an object of the wrong category!

view this post on Zulip Mike Shulman (Jan 19 2024 at 17:33):

In case saying the same thing in different words helps:

Bruno Gavranović said:

You seem to be suggesting that I should call only the latter a sigma type (is that what you're suggesting?).

Yes.

Now, I understand the idea of interpreting the latter as a term in a trivial context where the original (a:A)(a:A) is now existentially quantified. But I'm confused by the fact that: a) now this term is not 'over' anything.

What it's "over" syntactically is the empty context, which category-theoretically corresponds to the terminal object. It just so happens that the slice category over the terminal object is equivalent to the category itself, C/1CC/1\simeq C.

b) in the former, (a:A)(a:A) also appears existentially quantified (in (Σ(a:A).A(A),π)(\Sigma (a : A) . A'(A), \pi)). If this is not to be thought of as a sigma type, then what is this?

The Sigma-type is the object Σ(a:A).A(a)\Sigma (a : A) . A'(a) (or, more precisely, that object paired with its unique map to the terminal object). The pair (Σ(a:A).A(a),π)(\Sigma (a : A) . A'(a), \pi) is not a Sigma-type. It "contains within it" the data of the Sigma-type, but the operation of "taking the Sigma-type" is the operation of forgetting the morphism π\pi (or, more precisely, composing it with the unique morphism A1A\to 1).

view this post on Zulip Mike Shulman (Jan 19 2024 at 17:34):

You might also find it helpful to read about some [[categorical models of dependent types]], which distinguish more carefully between "types in a context" and "objects of a slice category". Many category-theorists find it more intuitive to blur that line, but it sounds like maybe this blurring is part of what's causing your confusion and looking at a more precise treatment would help.

view this post on Zulip Kevin Arlin (Jan 19 2024 at 17:53):

Second that motion. I found it all much too floppy to understand till I read about categories with families, which actually distinguish between contexts, types and terms in the semantics.