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

fix(category_theory/limits): Add some missing instances for special shapes of limits #2083

Merged
merged 3 commits into from Mar 6, 2020

Conversation

TwoFX
Copy link
Member

@TwoFX TwoFX commented Mar 4, 2020

This PR adds fin_category instances for the indexing categories for (co)equalizers, pushouts and pullbacks. This means that we can now correctly derive the existence of these special limits from has_finite_limits and has_finite_colimits.

It also adds missing instance attributes for has_kernels and has_cokernels.

TO CONTRIBUTORS:

Make sure you have:

  • reviewed and applied the coding style: coding, naming
  • reviewed and applied the documentation requirements
  • make sure definitions and lemmas are put in the right files
  • make sure definitions and lemmas are not redundant

If this PR is related to a discussion on Zulip, please include a link in the discussion.

For reviewers: code review check list

@@ -62,13 +63,21 @@ instance fintype_walking_parallel_pair : fintype walking_parallel_pair :=
open walking_parallel_pair

/-- The type family of morphisms for the diagram indexing a (co)equalizer. -/
inductive walking_parallel_pair_hom : walking_parallel_pair → walking_parallel_pair → Type v
@[derive _root_.decidable_eq] inductive walking_parallel_pair_hom :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is _root_ needed here?

Copy link
Member Author

Choose a reason for hiding this comment

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

After open walking_parallel_pair, decidable_eq refers to category_theory.limits.walking_parallel_pair.decidable_eq (i.e., the decidable_eq instance derived for walking_parallel_pair).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed here, and a fix is in the works, so we'll leave this as is for now.

| left : walking_parallel_pair_hom zero one
| right : walking_parallel_pair_hom zero one
| id : Π X : walking_parallel_pair.{v}, walking_parallel_pair_hom X X

open walking_parallel_pair_hom

instance (j j' : walking_parallel_pair) : fintype (walking_parallel_pair_hom j j') :=
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would really prefer to see a derive handler that can cope with this. Do you know why the existing one doesn't work here? (I haven't looked at all.)

Copy link
Member Author

Choose a reason for hiding this comment

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

When I put attribute [derive fintype] walking_parallel_pair_hom, I get failed to find a derive handler for 'fintype'. Since even for object types like walking_parallel_pair the fintype instance is implemented manually, I concluded that there simply is no derive handler for fintype. A grep over the mathlib repository seems to support that conclusion.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems the only other successful @[derive fintype] is in archive/sensitivity.lean, where delta_instance is all that's required to get it done. A general purpose derive_handler for fintype unfortunately doesn't exist, but this seems like the sort of thing @cipher1024 likes. :-)

@semorrison
Copy link
Collaborator

So what's the status of

This means that we can now correctly derive the existence of these special limits from has_finite_limits and has_finite_colimits.

What do you think of adding a bunch of lines like:

def has_equalizers_of_has_finite_limits [has_finite_limits.{v} C] : has_equalizers.{v} C :=
{ has_limits_of_shape := by apply_instance }

These shouldn't be global instances, but available in case someone wants them.

@semorrison semorrison added the ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) label Mar 6, 2020
@mergify mergify bot merged commit 8fb9881 into leanprover-community:master Mar 6, 2020
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
…hapes of limits (leanprover-community#2083)

* Add some instances for limit shapes

* Deduce has_(equalizers|kernels|pullbacks) from has_finite_limits

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
…hapes of limits (leanprover-community#2083)

* Add some instances for limit shapes

* Deduce has_(equalizers|kernels|pullbacks) from has_finite_limits

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants