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: Sub-types in Dependent Type Theory


view this post on Zulip Avi Craimer (Sep 13 2020 at 05:31):

I am reading David Corfield's book Modal Homotopy Type Theory. The chapter on Dependent Types is great, helping me wrap my head around intuitive use cases for dependent types in philosophy and programming. In section 2.6, he discusses the question of whether a philosophical type theory should posit a single master type for individuals (e.g., Entity) or rather have several basic types such as (Object, Event, Agent, etc). In the course of this discussion he references the idea of building up sub-types from more basic types. However, I am a bit confused about how the construction of sub-types using dependent types is supposed to work.

I understand how to construct a proposition like "Fluffy is a Cat" from a given element Fluffy of type Animal as a truncated dependent pair type.

||Sigma( Fluffy: Animal, isCat(Fluffy) )||

But this doesn't give me Cat as a Type, nor an element c : Cat. So I am wondering if there is a way using DTT (or perhaps full blown HoTT) to actually construct the sub-type object and it's elements. Maybe another way of asking this question is that I'd like to know what is the type theoretic analogue to the category theory method of using a pullback from the sub-object classifier to define a sub-object.

In the book I've only made it to the start of Chapter 3, so it is possible that the author discusses this at a later point.

view this post on Zulip Dan Doel (Sep 13 2020 at 05:47):

It seem to me that "Fluffy is a Cat" is isCat(Fluffy)\mathsf{isCat}(\mathsf{Fluffy}). That's referring to a specific Fluffy\mathsf{Fluffy}. The truncated type is more like c.isCat(c)∃ c. \mathsf{isCat}(c). I know mathematicians often interchange existential propositions and specific constructions, but I think it's arguably bad practice, and might be one of the things the book is trying to address (although I haven't read it).

view this post on Zulip Dan Doel (Sep 13 2020 at 05:49):

Also you could perhaps define the Cat\mathsf{Cat} type to be ΣAnimal isCatΣ \mathsf{Animal}\ \mathsf{isCat}, since it is the type of animals together with a proof that they are cats. Without the truncation, you are not removing the distinction between different cats.

view this post on Zulip Dan Doel (Sep 13 2020 at 05:52):

This type is a pullback along isCat:AnimalΩ\mathsf{isCat} : \mathsf{Animal} → Ω. The first projection is the monomorphism into Animal\mathsf{Animal}.

view this post on Zulip Dan Doel (Sep 13 2020 at 05:55):

Or at least, it could be, depending on the details of how everything is arranged.

view this post on Zulip Henry Story (Sep 13 2020 at 07:08):

I asked a similar question on the HoTT Café Mailing list 4 years ago: on the mortality of Socrates. So there may be some good answers to glean from there.

view this post on Zulip Avi Craimer (Sep 13 2020 at 15:57):

Dan Doel said:

It seem to me that "Fluffy is a Cat" is isCat(Fluffy)\mathsf{isCat}(\mathsf{Fluffy}). That's referring to a specific Fluffy\mathsf{Fluffy}. The truncated type is more like c.isCat(c)∃ c. \mathsf{isCat}(c).

Yes, that's right, my mistake. I guess the element of the (untruncated) sigma type would be an element of "Fluffy as Cat" (sort of like type casting in programming). The truncated sigma type is the existential proposition, "there is a Cat".

Dan Doel said:

Also you could perhaps define the Cat\mathsf{Cat} type to be ΣAnimal isCatΣ \mathsf{Animal}\ \mathsf{isCat}, since it is the type of animals together with a proof that they are cats. Without the truncation, you are not removing the distinction between different cats.

I'm not clear what you mean by forming a sigma type with Animal as the first element of the pair. That would be saying something like, "The abstract category of animals is a Cat" which is plainly false. Animal : Type is not an animal much less a cat. Maybe I'm misunderstanding your suggestion.

Dan Doel said:

This type is a pullback along isCat:AnimalΩ\mathsf{isCat} : \mathsf{Animal} → Ω. The first projection is the monomorphism into Animal\mathsf{Animal}.

Right, this is how it would work in Topos theory. What I don't understand is what is the analogue to this in DTT or HoTT.

view this post on Zulip Avi Craimer (Sep 13 2020 at 16:31):

Henry Story said:

I asked a similar question on the HoTT Café Mailing list 4 years ago: on the mortality of Socrates. So there may be some good answers to glean from there.

Thanks for linking to that discussion. Very interesting although I didn't quite feel it answered the question. I'm left wondering if there is a disconnect between the type systems that make sense for mathematics and those that might make sense for philosophy and common-sense ontologies.

view this post on Zulip Dan Doel (Sep 13 2020 at 16:45):

Sorry. By ΣABΣ A B I mean Σx:AB(x)Σ_{x:A} B(x). This is sometimes how it might be written when there is sufficient machinery for ΣΣ to not have to act as a variable binder itself.

view this post on Zulip Dan Doel (Sep 13 2020 at 16:46):

Anyhow, what I wrote was all intended to be in type theory, not topos theory.

view this post on Zulip Dan Doel (Sep 13 2020 at 16:52):

I don't know exactly how the type theory is structured in the book you're reading, but it would go something like this...

view this post on Zulip Dan Doel (Sep 13 2020 at 17:02):

There is a type ΩΩ whose values are propositional types. This allows you to have isCat:AnimalΩ\mathsf{isCat} : \mathsf{Animal} → Ω act in a sort of double way. It's an arrow into the subobject classifier, but it's also a family of types. This happens a lot if you decide to make the type theory have types whose values are other types. isCat\mathsf{isCat} is both a map into the subobject classifier and a family of types, while in topos theory there is just a correspondence between these two things.

view this post on Zulip Dan Doel (Sep 13 2020 at 17:17):

Since isCat\mathsf{isCat} is a family of types indexed by Animal\mathsf{Animal}, we can form the sigma type Σa:AnimalisCat(a)Σ_{a:\mathsf{Animal}} \mathsf{isCat}(a). There are generally multiple ways to think about this. If you think about the family BB as primary, it's the disjoint union of all the fibers, or the sort of 'total space' of the family. In category theory you usually think of the family as already being the total space with a display map into the indexing type, but type theory prefers to present the family like it's mapping from the indexing type.

But, since the fibers of isCat\mathsf{isCat} are propositional, this can also be read like it's a subset of Animal\mathsf{Animal}, {cAnimalisCat(c)}\{c \in \mathsf{Animal} | \mathsf{isCat}(c) \}. The values of the sigma type are animals together with proofs that they are cats, but there is 'at most one' such proof (homotopically if you're doing that) for each animal. So the values of the sigma type are more structured than the elements of a subset are usually thought to be, but the structure is in some sense just acting as a filter.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:02):

If you want to get really into the weeds, then there is an alternate way of presenting this. You have a type ΩΩ of propositions, and a family

p:ΩTrue(p) typep : Ω ⊢ \mathsf{True}(p)\ \mathsf{type}

of truth values. Pullback corresponds to substitution, so if you have

a:AnimalisCat(a):Ωa : \mathsf{Animal} ⊢ \mathsf{isCat}(a) : Ω

then the substitution

a:AnimalTrue(isCat(a)) typea : \mathsf{Animal} ⊢ \mathsf{True}(\mathsf{isCat}(a))\ \mathsf{type}

is the family you get by pulling back the truth family along the arrow isCat:AnimalΩ\mathsf{isCat} : \mathsf{Animal} → Ω.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:03):

Then you can use Σ to realize the total space of the family as a type in itself, rather than a family of types.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:06):

This doesn't blur the lines of what you do in the category theory as much.

view this post on Zulip Avi Craimer (Sep 13 2020 at 18:07):

Thanks, I think I'm starting to understand better. One question about the sigma type.

Dan Doel said:

The values of the sigma type are animals together with proofs that they are cats...

So when you write, Σa:AnimalisCat(a)Σ_{a:\mathsf{Animal}} \mathsf{isCat}(a) you mean for the a to range over all the terms in Animal. Is that what a sigma type is? I though you needed to give specific term to form a particular dependent pair type. i.e., I that the a:Animal was a concrete term (like Fluffy) rather than a term variable.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:15):

Values of Σa:AB(a)Σ_{a:A} B(a) are pairs (M,N)(M,N) where M:AM : A and N:B(M)N : B(M).

This is very much like the existential quantifier. ∃ binds a variable in x:A.B(x)∃ x:A. B(x), and the variable ranges over AA. But to prove an existential statement, you give a particular value of AA and a proof that BB holds for that value. But for we want to consider all proofs equivalent, which is what truncation does. If you don't truncate, there are potentially many distinct choices of M:AM : A.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:19):

Also, you should be careful about saying the variable ranges over "terms". Those are syntactic expressions that denote something in the semantics. But the semantic values may not be the syntactic expressions.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:23):

See e.g. here.

view this post on Zulip Avi Craimer (Sep 13 2020 at 18:26):

Dan Doel said:

Values of Σa:AB(a)Σ_{a:A} B(a) are pairs (M,N)(M,N) where M:AM : A and N:B(M)N : B(M).

Ok, so just to be sure I understand, as a simple example, if I have a type Bool with values true and false. Then the dependent sum type Σx:Bool(B(x):Prop)Σ_{x:Bool} (B(x) : Prop) would have two possible values namely the pairs p1 = (true, warrant of B(true)) and p2 = (false, warrant of B(false) ). These would only be values of the sigma type insofar as B(true) and B(false) are true propositions.

Is this correct?

view this post on Zulip Dan Doel (Sep 13 2020 at 18:40):

Yes, that's correct.

view this post on Zulip Avi Craimer (Sep 13 2020 at 18:43):

Ok. So that was the root of my misunderstanding. Now I can see how the sigma type provides a sub-type. Thank you so much for your help. I'll go back through your explanations of the weedy parts to try to really map it out, but I think I get the basics now.

view this post on Zulip Dan Doel (Sep 13 2020 at 18:43):

Cool.

view this post on Zulip Henry Story (Sep 14 2020 at 09:37):

I think there is another way where Sigma types act as subtypes. I was looking at these in detail a year ago and wrote it up in a post Modal HoTT on the Web. I tried to illustrate carefully how Sigma Types arise out of an adjunction on slice categories.
So a x:AD(x)\sum_{x: A} D(x) is the result of mapping the object g:DAg: D \to A in the slice category C/A\mathcal{C}/A to C\mathcal{C} using the left adjoint of f:=A×()f*:=A \times (-). The D(x)D(x) is the type of the fiber over xx, thus a part of DD. On this view it looks like D(x)D(x) really selects a subset of DD (thinking set theoretically), which would in a way be equivalent to a subclass of DD. It actually partitions the space, where subclasses in OO can be multi-layered. Somehow this does not appear that clearly in the HoTT definition of a sigma time. So I am not quite sure. Sigma Types as Adjunctions, explained in Modal HoTT on the Web blog post

view this post on Zulip Henry Story (Sep 14 2020 at 09:39):

Somehow I also came to the conclusion that a sigma type is a pullback (shown in the illustration above). But I am not sure anymore where I got that from.

view this post on Zulip Henry Story (Sep 14 2020 at 10:56):

Actually, reading @Dan Doel 's example with animals and cats I think I got something wrong in my illustration (it was something that bothered me when I put the post together). I'll draw up an illustration for the Cat example above.

view this post on Zulip Henry Story (Sep 14 2020 at 11:34):

Here is my illustration of the isCat dependent sum as an adjunction on the base change functor for f:Ω1f: \Omega \to 1 .

Is this correct? I like the way the function is central. But I think the objects in the slice category C/Ω\mathcal{C}_{/\Omega} are called Ω\Omega-dependent, yet I thought one says that Σx:AnimalisCat(x)\Sigma_{x: \text{Animal}} isCat(x) this type is animal dependent. :thinking:

DependentSum.Cat.jpg

view this post on Zulip Henry Story (Sep 14 2020 at 16:27):

Looking at the nlab page on dependent sum especially the section "relation to Type Theory" it seems indeed that the dependent sum arising from x:AP(x)x: A \dashv P(x) corresponded to the slice category over A.
(In a way it also corresponds better to the fibered view, where the fibers are over A).

So what I don't quite understand is

  1. HoTT writes A:UA: \mathcal{U} and P:AUP: A \to \mathcal{U}. But the morphisms in the slice category go from PAP \to A. Admittedly P is known as a Type-family
  2. that nlab defines the left adjoint functor as
    ff() ⁣:C/AC/I\sum_f \coloneqq f\circ (-) \colon \mathcal{C}_{/A} \to \mathcal{C}_{/I}. When II is the final object of the category 11, then this equals simply ff which in the case above would have been just f:BAf: B \to A, or in my last diagram f:AnimalsΩf: \text{Animals} \to \Omega. But why is it that the sum pairs have AA (Ω\Omega) first and BB (Animals \text{Animals} ) second?

view this post on Zulip Henry Story (Sep 14 2020 at 20:00):

Also if I don't slice C\mathcal{C} over Ω\Omega but instead did it over Animals\text{Animals} as it seems I should according to nlab for @Dan Doel's Σx:AnimalsisCat(x)\Sigma_{x:\text{Animals}} isCat(x) example, we would have objects ΩAnimals\Omega \to \text{Animals} in the slice category. But that does not makes a lot less sense: would every such morphism select only one cat and one non-cat?

view this post on Zulip Dan Doel (Sep 14 2020 at 22:24):

The point of (sub)object classifiers is that there are correspondences between (certain) PAP → A and AUA → \mathcal U or AΩA → Ω. The 'in the weeds' presentation I talked about makes the fact that this is a correspondence more explicit, but other times they are presented as just being the same thing.

So, you could hypothesize a family

a:AnimalisCat(a) propa : \mathsf{Animal} ⊢ \mathsf{isCat}(a)\ \mathsf{prop}

Meaning essentially that there is a monomorphism isCat:CatAnimal\mathsf{isCat} : \mathsf{Cat} \rightarrowtail \mathsf{Animal}, which is also an object of the slice category over Animal\mathsf{Animal}. The obvious issue is that I have already invoked a type Cat\mathsf{Cat} because I don't know what else to call that part of the subobject.

ΩΩ being a subobject classifier means that there exists isCat~:AnimalΩ\widetilde{\mathsf{isCat}} : \mathsf{Animal} → Ω, which forms part of a pullback square with isCat:CatAnimal\mathsf{isCat} : \mathsf{Cat} \rightarrowtail \mathsf{Animal}. The other parts of the square are true:1Ω\mathsf{true} : 1 \rightarrowtail Ω and !:Cat1! : \mathsf{Cat} → 1. isCat~\widetilde{\mathsf{isCat}} maps animals to the truth value that corresponds to their cat-hood.

In the more explicit notation I gave, the expectation is something like:

a:AnimalisCat(a)=True(isCat~(a))a : \mathsf{Animal} ⊢ \mathsf{isCat}(a) = \mathsf{True}(\widetilde{\mathsf{isCat}}(a))

which says that by pulling back 'truth' along isCat~\widetilde{\mathsf{isCat}}, we get a subobject equivalent to Cat\mathsf{Cat}, and with the same indexing by Animal\mathsf{Animal}. If you want to recover the 'whole space' as a type, rather than an indexed family of types, then you can use the sigma type to get something indexed by 11 instead of Animal\mathsf{Animal}. That would be a type equivalent to Cat\mathsf{Cat}.

You could also instead hypothesize isCat:AnimalΩ\mathsf{isCat} : \mathsf{Animal} → Ω, which doesn't demand you to also invent Cat\mathsf{Cat} directly, and instead allows you to define it. A lot of type theories arguably work this way, where everything is defined in terms of object classifiers (universes) whose values are implicitly usable as their corresponding types.

view this post on Zulip Dan Doel (Sep 14 2020 at 22:29):

I guess the point is that you aren't usually considering various families sliced over ΩΩ. You are reindexing from true:1Ω\mathsf{true} : 1 \rightarrowtail Ω in the slice over ΩΩ along the classifying map AΩA → Ω.