Zulip Chat Archive
Stream: maths
Topic: 1-limits in Cat
Joseph Hua (Jan 31 2022 at 22:40):
Hi! I'm spending this week proving that Cat is complete (as a 1-category). Whilst this is "evil" somehow since Cat is really a 2-category, I think the results are worth having in mathlib. The non-master branch of my repo currently contains constructions of binary products and equalizers in Cat. https://github.com/Jlh18/discrete_fibrations/tree/Joseph is this worth a PR?
Adam Topaz (Jan 31 2022 at 22:52):
Ping @Junyan Xu
Reid Barton (Feb 01 2022 at 00:08):
This doesn't look too bad as far as eq_to_hom
stuff is concerned, but I wonder if we have to deal with eq_to_hom
anyways, maybe we can get a bigger payoff, like proving Cat
is equivalent to some presentation of the 1-category of categories that doesn't involve dependent types.
Reid Barton (Feb 01 2022 at 00:09):
For example the presentation in terms of objects and morphisms with source and target maps and partially defined composition (which is the models of an essentially algebraic theory), or even the presentation as a reflective subcategory of simplicial sets.
Junyan Xu (Feb 01 2022 at 06:06):
Golfed the product part; why didn't you do it with arbitrary product? Because we don't have a category structure on the pi type yet? Will think about equalizers tomorrow; wondering whether using heq instead of eq in the definition of hom could lead to easier proofs.
Joseph Hua (Feb 01 2022 at 10:12):
oh wow, thanks for that @Junyan Xu . I am going to prove things about arbitrary product today! I did binary products first because I wanted to first get used to the category theory library with an easier exercise.
I am not familiar with the theory that you mention @Reid Barton , so I probably won't be doing that... So the conclusion is that this is not good PR material, given that this alternative is available?
Joseph Hua (Feb 01 2022 at 10:33):
hext is amazing
Junyan Xu (Feb 01 2022 at 14:04):
Using hext results in a goal without eq_to_hom, which is simpler in some sense, but there are very few lemmas about == (heq), for example there's no analogue of prod.ext for heq in mathlib, so I need to do dsimp [prod_map, (≫)], cases F.map f, refl
instead of just prod.ext rfl rfl
(in fact the types are defeq as I realized today and heq_of_eq (prod.ext rfl rfl)
works). eq_to_hom is used to flush everything into the same type, and then heq can be expressed using = (eq), and all lemmas about eq can be used. It's not too bad to work with heq in this case, as many things involved are "almost defeq", i.e. Lean can recognized them to be defeq once the structures are broken down into its components using cases
.
Joseph Hua (Feb 01 2022 at 16:05):
I'm struggling to find the right definition for equalizers using heq
. The objects should just be as I originally had, requiring F.obj x = G.obj x
, but it seems like requiring F.map f == G.map f
for morphisms is not a good idea, since I can't do cases on a proof of the statement.
Joseph Hua (Feb 01 2022 at 22:35):
okay i showed that the category of small category has all small limits. I'm still confused about how equalizers should work using heq
Junyan Xu (Feb 02 2022 at 03:53):
Sorry to make you confused. I was just wondering whether heq would make equalizer simpler as well, given that it works well with products; but it turns out not to be the case. Although generally speaking heq between morphisms is equivalent to eq between morphisms conjugated by eq_to_hom, heq has less library support and most lemmas are stated in terms of eq_to_hom. (eq_to_hom seems to play well with simp lemmas, while proofs involving heq often requires the generalize
tactic and that may be hard to automate, and if you want to compose to non-defeq'ly composable morphisms, you have to use eq_to_hom; these are possibly why people invented eq_to_hom and mostly abandoned heq.) Though I'm able to define the equalizer category using heq, it's complicated and this is the best I can get:
equalizer.str'
and here is a proof that the heq condition is equivalent to the "eq to conjugation by eq_to_hom" condition:
heq_iff_eq_conj_eq_to_hom
Now that limits are done, are you proceeding to colimits?
Junyan Xu (Feb 02 2022 at 07:29):
Seems we don't have the forgetful functor from Cat to Type (taking the object part). We'd like to show it preserves (co)limits.
Joseph Hua (Feb 02 2022 at 10:06):
Junyan Xu said:
Sorry to make you confused. I was just wondering whether heq would make equalizer simpler as well, given that it works well with products; but it turns out not to be the case. Although generally speaking heq between morphisms is equivalent to eq between morphisms conjugated by eq_to_hom, heq has less library support and most lemmas are stated in terms of eq_to_hom. (eq_to_hom seems to play well with simp lemmas, while proofs involving heq often requires the
generalize
tactic and that may be hard to automate, and if you want to compose to non-defeq'ly composable morphisms, you have to use eq_to_hom; these are possibly why people invented eq_to_hom and mostly abandoned heq.) Though I'm able to define the equalizer category using heq, it's complicated and this is the best I can get:equalizer.str'
and here is a proof that the heq condition is equivalent to the "eq to conjugation by eq_to_hom" condition:
heq_iff_eq_conj_eq_to_hom
Now that limits are done, are you gonna proceed to colimits? Seems eq.rec is inevitable to define homs for the sigma category ... Oh it's actually Grothendieck construction with base a discrete category ...
Maybe the Grothendieck construction yields the colimit for arbitrary diagram ...
Ah okay - yeah I couldn't figure out how to generalize the data F.map f
to eliminate it. I'll try to see if this definition could tidy up my work. Thanks a lot!
About coproducts: it seems to me that category_theory.elements
and category_theory.sigma
are kind of duplicates of the same Grothendieck construction. Would it be nicer to make the sigma
version from the elements
version by making the indexing type I
a discrete category? Either way, I will use this both for making pullbacks (which I would like to have a direct construction for) and maybe I'll do colimits too.
Junyan Xu (Feb 02 2022 at 14:44):
Oh I didn't know that category_theory.sigma.basic
and category_theory.pi.basic
exist! It seems sigma
works for a functor from a discrete category to Cat, while elements
works for a functor from an arbitrary category to Type, so they are complementary instead of special case of one another (and there is also grothendieck
that works for a functor from any category to Cat, which I've generalized to oplax functors). sigma
defines the homs not via another sigma type, but directly as an inductive type, which may or may not be easy to work with, and it would be interesting to try.
Bhavik Mehta (Feb 02 2022 at 14:47):
I found it a lot easier to work with the homs for sigma
as an inductive type rather than a sigma type, because it avoids eq.rec
and eq_to_hom
sorts of things showing up everywhere and it made the proofs more awkward than usual to work with! My original method was to use a standard sigma type though
Joseph Hua (Feb 02 2022 at 14:55):
I just finished golfing the equalizer proof using heq
and refactoring maps into the limit @Junyan Xu . There are a bunch of irrelevant comments about authenticity (I'm submitting this as coursework) so please ignore them.
Joseph Hua (Feb 02 2022 at 14:56):
Also made a couple of lemmas for composition working with heq
Joseph Hua (Feb 02 2022 at 15:59):
oh right elements is for functors into Type u silly me
Kevin Buzzard (Feb 02 2022 at 16:54):
Joseph -- is this for the assessment "prove a theorem at 1st year undergraduate level" due in on Friday? :laughing:
Junyan Xu (Feb 03 2022 at 05:45):
Just want to note that map_comp_heq
has an easy proof using congr'
as in
equalizer.str'
Joseph Hua (Feb 03 2022 at 20:50):
Junyan Xu said:
Just want to note that
map_comp_heq
has an easy proof usingcongr'
as inequalizer.str'
oh wow that's slick. but why does it work? I don't see how being "less aggressive at breaking down the goal" helps
Junyan Xu (Feb 03 2022 at 23:04):
If you try congr
you'll see it's too aggressive and produces five identical goals F = G
which isn't necessarily true...
Junyan Xu (Feb 03 2022 at 23:06):
and this is the output of show_term { congr' 1, exacts [x.2, y.2, z.2, f.2, g.2] }
:
Joseph Hua (Feb 03 2022 at 23:26):
yeah i used show_term to have a look too. I guess it first looks for proofs of equality then tries to compare the terms, rather than looking to compare the terms, then checking equality (which fails)?
Junyan Xu (Feb 03 2022 at 23:43):
I don't quite get the question. Are you asking why congr
fails? It doesn't actually fail but produces goals you won't be able to prove. For example congr' 1
produces F.obj x.val = G.obj x.val
, but congr
breaks it down one step further to get F = G
, which is too much. It seems congr
does recognize equalities in the context (but not the ones buried in a structure like subtype) but doesn't automatically apply them: if you do have := x.2
before congr
you see that the first resulting goal becomes F.obj x.val = G.obj x.val
(which is the type of x.2
but not automatically solved) but the other four goals remain F = G
. congr'
in contrast automatically uses equalities to solve resulting goals: if you do have := x.2, have := y.2, have := z.2, have := f.2, have := g.2, congr' 1
then goals accomplished
.
Joseph Hua (Feb 03 2022 at 23:47):
you answered my question with yes haha, that is what I vaguely had in mind
Last updated: Dec 20 2023 at 11:08 UTC