Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(category_theory/limits): kernels #1445

Closed
wants to merge 19 commits into from
Closed

feat(category_theory/limits): kernels #1445

wants to merge 19 commits into from

Conversation

semorrison
Copy link
Collaborator

Another special shape, as we crawl towards the basics of homological algebra...

@semorrison semorrison requested a review from a team as a code owner September 16, 2019 05:22
local attribute [simp] zero_morphism_comp comp_zero_morphism

/-- A category with a zero object has zero morphisms. -/
instance : has_zero_morphisms.{v} C := {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a lovely proof.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's actually a Lean bug/feature(?) I noticed recently, that prevented me from simplifying quite a few proofs in the limits library to this form. Apparently when you use auto_param in a class field, it can turn implicit arguments back into explicit ones... I'll see if I can pin it down.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't really like this style of proof from a software engineering point of view, at least in this case. It's too much "action at a distance". Suppose you want to know how the zero morphisms in your category are defined. Even once you have tracked them down to this instance : has_zero_morphisms.{v} C, you still need to figure out why there is no definition of has_zero provided and that it comes from an instance 10 lines above.

Much clearer to simply replace everything so far in this section by

/-- A category with a zero object has zero morphisms. -/
instance : has_zero_morphisms.{v} C :=
{ has_zero := λ X Y, ⟨inhabited.default (X ⟶ 0) ≫ inhabited.default (0 ⟶ Y)⟩,
  comp_zero' := λ X Y f Z, by { dunfold has_zero.zero, rw ←category.assoc, congr, },
  zero_comp' := λ X Y Z f, by { dunfold has_zero.zero, rw category.assoc, congr, }, }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that was horrible. Fixed.

@robertylewis robertylewis added the needs-documentation This PR is missing required documentation label Sep 18, 2019
@semorrison
Copy link
Collaborator Author

Thanks, @robertylewis, for the reminders about missing docs!

@semorrison semorrison removed the needs-documentation This PR is missing required documentation label Sep 18, 2019
@semorrison semorrison added the awaiting-review The author would like community review of the PR label Sep 20, 2019
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I'm only wondering if we need to support some sort of multiplicative version... we might want to have short exact sequences 1 → µ_n → Gm → Gm → 1 at some point...

src/category_theory/limits/shapes/zero.lean Show resolved Hide resolved
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @rwbarton Do you have any remarks?

@rwbarton
Copy link
Collaborator

How about an example: AddCommGroup? (Or the rest of the monoid/group categories, though we probably only care about AddCommGroup.)

src/category_theory/limits/shapes/zero.lean Outdated Show resolved Hide resolved
local attribute [simp] zero_morphism_comp comp_zero_morphism

/-- A category with a zero object has zero morphisms. -/
instance : has_zero_morphisms.{v} C := {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't really like this style of proof from a software engineering point of view, at least in this case. It's too much "action at a distance". Suppose you want to know how the zero morphisms in your category are defined. Even once you have tracked them down to this instance : has_zero_morphisms.{v} C, you still need to figure out why there is no definition of has_zero provided and that it comes from an instance 10 lines above.

Much clearer to simply replace everything so far in this section by

/-- A category with a zero object has zero morphisms. -/
instance : has_zero_morphisms.{v} C :=
{ has_zero := λ X Y, ⟨inhabited.default (X ⟶ 0) ≫ inhabited.default (0 ⟶ Y)⟩,
  comp_zero' := λ X Y f Z, by { dunfold has_zero.zero, rw ←category.assoc, congr, },
  zero_comp' := λ X Y Z f, by { dunfold has_zero.zero, rw category.assoc, congr, }, }


/-- A category "has a zero object" if it has an object which is both initial and terminal. -/
class has_zero_object :=
(zero : C)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to treat this zero differently than has_zero in has_zero_morphisms? (But see below.)

src/category_theory/limits/shapes/zero.lean Outdated Show resolved Hide resolved
/-- A category "has a zero object" if it has an object which is both initial and terminal. -/
class has_zero_object :=
(zero : C)
(unique_to : ∀ X : C, unique (zero ⟶ X))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_initial and is_terminal should exist, and these conditions should be expressed in terms of them.

src/category_theory/limits/shapes/zero.lean Outdated Show resolved Hide resolved
@rwbarton
Copy link
Collaborator

I'm a little reluctant to add more stuff on top of special shapes when they aren't really finished, as discussed in #1444. However, I guess we can always change it later.

This PR adds entirely too many instances of the form instance : some_class C where C is a variable. I think they are probably all bad. For example, take instance : has_zero_morphisms.{v} C, which I'll name zero_morphisms_of_zero_object. Imagine that we also have the following two instances.

variables (D : Type u') [𝒟 : category.{v'} D]
include 𝒟

instance functor.has_zero_morphisms [has_zero_morphisms.{v'} D] :
  has_zero_morphisms.{max u v'} (C ⥤ D) :=
{ has_zero := λ F G, ⟨{ app := λ X, 0 }⟩ }

local attribute [elab_simple] inhabited.default
instance functor.has_zero_object [has_zero_object.{v'} D] : has_zero_object.{max u v'} (C ⥤ D) :=
{ zero := (category_theory.functor.const C).obj 0,
  unique_from := λ F, { default := { app := λ X, inhabited.default (F.obj X ⟶ 0) }, uniq := by tidy },
  unique_to := λ F, { default := { app := λ X, inhabited.default (0 ⟶ F.obj X) }, uniq := by tidy } }

These are sensible instances because they work by "structural recursion" on the type C ⥤ D, and they say two different things. Now, there are two ways to get from has_zero_object.{v'} D to has_zero_morphisms.{max u v'} (C ⥤ D): we could apply zero_morphisms_of_zero_object to D and then functor.has_zero_morphisms, or we could apply functor.has_zero_object and then zero_morphisms_of_zero_object. To my immense disappointment, these two ways resulted in definitionally equal has_zero_morphisms.{max u v'} (C ⥤ D) instances, so this isn't necessarily a disaster. However, it's not clear to me that we can expect this to hold for every similar construction.

I would rather make all the instances in this PR into definitions, which can be used either to define instances for specific categories, or locally made into instances where desired for proving general theorems (although this still has its own dangers, since we may not easily be able to apply those general theorems to specific categories where the expected definitional equalities do not hold).

@rwbarton
Copy link
Collaborator

Finally, I worry we are accumulating definitions at too high a rate relative to examples and especially theorems, though I'm not sure off-hand what kind of theorems to suggest proving...

@rwbarton
Copy link
Collaborator

Even things like the kernel of a (regular?) monomorphism is initial/terminal/zero (whatever is the correct statement in general here) or that the kernel of the zero map is an isomorphism would be a good start.

@semorrison semorrison added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Sep 26, 2019
@semorrison
Copy link
Collaborator Author

I dealt with some of these comments. I'll get started on "proving some stuff" ... sometime! For now I'll mark as [WIP].

@semorrison semorrison added WIP Work in progress and removed awaiting-author A reviewer has asked the author a question or requested changes labels Oct 20, 2019
@semorrison
Copy link
Collaborator Author

For (even my own) future reference, we should:

  • Construct has_zero_object e.g. for AddCommGroup, possibly others.
  • Connect kernel to the concrete version in some examples.
  • Prove some basic lemmas, e.g. about the kernel of the zero map being an iso.

@semorrison
Copy link
Collaborator Author

I'm going to close this, to work on later.

@semorrison semorrison closed this Oct 22, 2019
@TwoFX
Copy link
Member

TwoFX commented Feb 11, 2020

Hi, I'd be interested in "adopting" this PR and finishing the remaining work that needs to be done. I have been working on zero objects and kernels independently (and only just discovered this PR), and while I used very slightly different definitions, I have proofs that the kernel of a monomorphism is zero and that the kernel of the zero map is an isomorphism and I am certain they can be ported easily. I'd also be happy to create some of the concrete instances and fill in the missing proofs.

@semorrison, would you prefer to work on this yourself or could I give it a try?

@semorrison
Copy link
Collaborator Author

semorrison commented Feb 11, 2020 via email

@TwoFX TwoFX mentioned this pull request Feb 14, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants