Zulip Chat Archive

Stream: mathlib4

Topic: learning what a left Kan extension is


Kevin Buzzard (Apr 29 2023 at 13:44):

I find myself (for porting reasons) wanting to learn (for the n'th time) what a left Kan extension is, so I figured that rather than facing nLab I'd try and learn from mathlib4 + pen-and-paper.

First thing I've learnt: they're called lan, their URL is docs4#CategoryTheory.lan and the theorems about them are in namespace CategoryTheory.Lan. Is this capital a mistake or is this what the naming convention gods decreed?

Next thing I discovered: the docstring currently isn't helpful (this can easily be fixed, and probably will be by the end of this), and if I click "Equations" then it says One or more equations did not get rendered due to their size. and that's it. Is this expected? Finally, when I click the ink option I jump to the beginning of the file in a web browser rather than the definition of lan, even though the URL ends in #CategoryTheory.lan. I have more ink questions but I'll ask them elsewhere.

I guess I'm interested in the general question as to whether it is possible to imagine using mathlib4 as a resource for learning precise definitions in mathematics at undergraduate and MSc level, and what work needs to be done to make this happen.

Mario Carneiro (Apr 29 2023 at 13:50):

I don't think that is correct to the naming convention, but the name is very mysterious to me

Mario Carneiro (Apr 29 2023 at 13:51):

If I go to the source I see even more fun capitalization:

set_option linter.uppercaseLean3 false in
  #align category_theory.Lan CategoryTheory.lan

Mario Carneiro (Apr 29 2023 at 13:52):

(also this indentation pattern is not standard, set_option ... in should not have an indent after it)

Mario Carneiro (Apr 29 2023 at 13:54):

Overall, I think you just ran into a lot of bugs. I don't think you can derive much about the effectiveness of mathlib4 as a teaching tool until the bugs are fixed

Adam Topaz (Apr 29 2023 at 13:56):

Re the name. There’s a left Kan extension (lan) and a right one (ran) which have dual (in some sense) universal properties. In the best situations, they give adjoints to the “whiskering” functor, which is a functor on the category of functor as given on objects by composition with a functor. (Sorry for the functor overload…). I think the adjunction is called docs4#CategoryTheory.Ran.adjunction ?

Adam Topaz (Apr 29 2023 at 13:56):

(And the analogous thing for lan)

Adam Topaz (Apr 29 2023 at 13:58):

It is unfortunate that the naming convention has the functor called lan and the namespace Lan :-/

Adam Topaz (Apr 29 2023 at 14:01):

Mario, what would the naming convention have us do in this case? I still don’t understand the convention

Mario Carneiro (Apr 29 2023 at 14:02):

The namespace of a function is spelled the same as the function itself

Mario Carneiro (Apr 29 2023 at 14:03):

otherwise dot notation breaks

Mario Carneiro (Apr 29 2023 at 14:03):

yes, that means it is lowercase sometimes

Adam Topaz (Apr 29 2023 at 14:03):

Well dot notation isn’t useful in this case anyway

Mario Carneiro (Apr 29 2023 at 14:04):

you could also not put them in a namespace and have lan_foo lemmas instead

Adam Topaz (Apr 29 2023 at 14:04):

So should the adjunction be called lanAdjunction

Adam Topaz (Apr 29 2023 at 14:04):

Yeah an adjunction has data

Mario Carneiro (Apr 29 2023 at 14:04):

lanAdjunction sounds fine to me

Mario Carneiro (Apr 29 2023 at 14:05):

although I really want to put a K in there somewhere

Adam Topaz (Apr 29 2023 at 14:07):

Yeah I understand but lan and ran are common in the nonformal literature

Adam Topaz (Apr 29 2023 at 14:07):

nlab#Kan+extension

Mario Carneiro (Apr 29 2023 at 14:07):

really? I had it pegged as a mathlibism

Adam Topaz (Apr 29 2023 at 14:08):

See def 2.1 in the above link

Mario Carneiro (Apr 29 2023 at 14:09):

BTW, I would not be opposed to tweaking the rules around what is a "type" vs "function" in the context of category theory for the purposes of the naming convention

Mario Carneiro (Apr 29 2023 at 14:09):

I think there is a reasonable argument that functors can be seen as type operators and objects in a category as types

Adam Topaz (Apr 29 2023 at 14:16):

BTW concerning the question of whether Mathlib is useful for learning… I certainly learned a lot about Kan extensions by formalizing them!

Reid Barton (Apr 29 2023 at 15:12):

I think Lan/Ran are a lot more common than lan/ran

Reid Barton (Apr 29 2023 at 15:13):

though even more common is sticking some punctuation somewhere

Reid Barton (Apr 29 2023 at 15:13):

(which punctuation depends on whether you are an algebraic geometer)

Reid Barton (Apr 29 2023 at 15:14):

Indeed the mathlib 3 name was Lan

Moritz Firsching (Apr 29 2023 at 20:12):

Mario Carneiro said:

(also this indentation pattern is not standard, set_option ... in should not have an indent after it)

fixing those in !4#3735

Thomas Murrills (Apr 29 2023 at 20:47):

Btw, re: the topic of the thread, definition 2.4 on the nLab page is my favorite—Kan extensions are “universal ways to complete a 2-cell” given two 1-arrows that share a source. (Typically the 1-arrows are functors and the 2-arrows are natural transformations, but the definition works in general.)

To complete such a 2-cell, you need to supply both:

  • a 1-arrow from the target of one of the given 1-arrow (pp) to the target of the other given one (FF) to get a triangle—this new arrow is called (L/R)anpF\text{(L/R)an}_p F—and
  • a 2-arrow to fill in the triangle, going between ((L/R)anpF)p(\text{(L/R)an}_p F) \circ p and FF. Which way this 2-arrow (called ηF\eta_F on the nLab page) is directed determines the left- or rightness of the Kan extension.

This 2-arrow is (at least in this view) the important data, and we have a Kan extension when this 2-arrow is universal in the same way a universal arrow is: any other 2-cell with the same shape factors uniquely through this one. (See the diagram in def 2.4 on nLab.)

This is a “local” Kan extension because both pp and FF are fixed. If it so happens that you can generalize the FF argument of e.g. LanpF\text{Lan}_p F by finding local extensions for all FF, then the operation Lanp\text{Lan}_p becomes one of the adjoint functors described by Adam above. This is analogous to how a family of universal arrows assembles to form an adjunction.

So a pretty good arrows-only characterization of a local Kan extension is a particular kind of “universal 2-arrow”, and global ones are what you get when you organize a family of those into the appropriate adjunction. As you can see, though, it’s the 1-arrow which forms half the (co)domain of this 2-arrow which gets the special name, since it’s the process of making these 1-arrows that actually yields the map on (objects of) the relevant functor category when you have a global Kan extension.

A nice thing about this perspective is that (co)limits are easily visible as the special case where the “middle” vertex of the triangle (codomain of pp, domain of (L/R)anpF\text{(L/R)an}_p F) is the terminal category. Seeing this fall out is straightforward but pretty gratifying! It lets you see Kan extensions as a sort of generalization of (co)limits.

At least…that’s one perspective. 😁 There’s a bunch captured by other perspectives which isn’t captured by this one. I’m not sure how this fits into mathlib’s characterization, though, or how useful this perspective actually is in the practice of formalizing things.

Adam Topaz (Apr 29 2023 at 21:54):

One crucial thing that’s still missing from mathlib is a characteristic predicate for (local/global) Kan extensions, and I’m quite sure the “universal 2-cell” would be the right approach for that!

Scott Morrison (Apr 29 2023 at 22:30):

I would propose we rename the functions themselves to Lan and Ran again.

Joël Riou (Apr 30 2023 at 10:26):

Adam Topaz said:

One crucial thing that’s still missing from mathlib is a characteristic predicate for (local/global) Kan extensions, and I’m quite sure the “universal 2-cell” would be the right approach for that!

I have draft code for total derived functors, and I have defined it like this:

variables {C D H : Type*} [category C] [category D] [category H]
  {F : C  D} (RF : H  D) {L : C  H} (α : F  L  RF)
  (W : morphism_property C) [L.is_localization W]

class is_right_derived_functor : Prop :=
(is_initial [] : nonempty (limits.is_initial (structured_arrow.mk α :
  structured_arrow F ((whiskering_left C H D).obj L))))

This can certainly be adapted for general Kan extensions.


Last updated: Dec 20 2023 at 11:08 UTC