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

[Merged by Bors] - feat(category_theory): functorial images #2373

Closed
wants to merge 11 commits into from

Conversation

TwoFX
Copy link
Member

@TwoFX TwoFX commented Apr 10, 2020

This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I

  • add documentation for comma.lean,
  • introduce the arrow category as a special case of the comma construction, and
  • introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.

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

@TwoFX TwoFX added the awaiting-review The author would like community review of the PR label Apr 10, 2020
@TwoFX TwoFX added this to In progress in Homological algebra via automation Apr 10, 2020
src/category_theory/comma.lean Show resolved Hide resolved
src/category_theory/comma.lean Outdated Show resolved Hide resolved
src/category_theory/comma.lean Outdated Show resolved Hide resolved
src/category_theory/comma.lean Outdated Show resolved Hide resolved
src/category_theory/comma.lean Outdated Show resolved Hide resolved
src/category_theory/comma.lean Outdated Show resolved Hide resolved
src/category_theory/comma.lean Show resolved Hide resolved
src/category_theory/limits/shapes/images.lean Outdated Show resolved Hide resolved
@semorrison
Copy link
Collaborator

Could you add a paragraph to the module doc for images.lean, explaining the has_image_map typeclass? (Actually, we should document has_image there as well... I seem to have done a bad job of this first time round.)

Comment on lines 350 to 352
{ map := 𝟙 (image f.hom),
factor_map' := by erw [arrow.id_left, category.id_comp, category.comp_id],
map_ι' := by erw [arrow.id_right, category.id_comp, category.comp_id] }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
{ map := 𝟙 (image f.hom),
factor_map' := by erw [arrow.id_left, category.id_comp, category.comp_id],
map_ι' := by erw [arrow.id_right, category.id_comp, category.comp_id] }
{ map := 𝟙 (image f.hom), }

Both of these proofs actually work by simp, dsimp, simp.

  1. It would be good to understand why we need to drop back to dsimp here. Unfortunately this seems to be frequently necessary when using highly dependent types.
  2. I know that I've written a great many erws in the category_theory library, but most of them are code smells, and we should be suspicious of them.
  3. In this case let's leave the proofs out, as they are boring and tidy can cope just fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't been able to fully pin this down, but I think the reason why the dsimp is needed here has something to do with the fact that implicit arguments are in the wrong from: category.id_comp expects that the goal contains 𝟙 X ≫ f with f : X ⟶ Y, but in reality the codomain of f is something like (𝟭 C).obj X (actually, in this particular case there's some auto_param in there too because of how comma is defined, but fixing that doesn't solve the problem) and in non-trivial cases simp and rw category.id_comp cannot make sense of that and rw functor.id_obj produces motive is not type correct, while dsimp only [functor.id_obj] somehow manages to do the right thing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gebner provided a very interesting solution to this dsimp, simp problem!

But for now everything is great here.

variables {f g : arrow C} [has_image f.hom] [has_image g.hom] (sq : f ⟶ g)

section
local attribute [ext] has_image_map
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 make this local? It seems a reasonable lemma to have ext be able to use.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why would you use ext on a subsingleton?

Copy link
Member

Choose a reason for hiding this comment

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

Because then tidy can make easy progress, because it call ext.

Copy link
Member Author

@TwoFX TwoFX Apr 11, 2020

Choose a reason for hiding this comment

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

It shouldn't call ext. There is no need to: has_image_map sq is a subsingleton, so if we have a goal x = y where x y : has_image_map sq, then tidy will just close the goal with exact dec_trivial. It would be bad if tidy called ext, because then it couldn't automatically solve the goal any more.

Copy link
Collaborator

Choose a reason for hiding this comment

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

tidy will always call dec_trivial before trying ext, so it won't actually fall down this hole.

I guess the thing I hadn't appreciated is that applying this ext attribute creates what is actually a quite poor ext lemma (which gets named has_image_map_ext). Of course, the attribute @[ext] on this lemma disappears by the end of the section, so it's not particularly bad pollution.

I'm now happy to leave as is --- although if you'd prefer to not have the has_image_map_ext declaration be synthesised and left around at all I think that would be reasonable. (Just do the cases ..., congr yourself in the construction of the subsingleton.)

@TwoFX
Copy link
Member Author

TwoFX commented Apr 11, 2020

Could you add a paragraph to the module doc for images.lean, explaining the has_image_map typeclass? (Actually, we should document has_image there as well... I seem to have done a bad job of this first time round.)

Done!

@semorrison
Copy link
Collaborator

bors d+

@bors
Copy link

bors bot commented Apr 11, 2020

✌️ TwoFX can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@semorrison
Copy link
Collaborator

bors r+

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Apr 11, 2020
bors bot pushed a commit that referenced this pull request Apr 11, 2020
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I
* add documentation for `comma.lean`,
* introduce the arrow category as a special case of the comma construction, and
* introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.
@bors
Copy link

bors bot commented Apr 11, 2020

Build succeeded

@bors
Copy link

bors bot commented Apr 11, 2020

Pull request successfully merged into master.

@bors bors bot changed the title feat(category_theory): functorial images [Merged by Bors] - feat(category_theory): functorial images Apr 11, 2020
@bors bors bot closed this Apr 11, 2020
bors bot pushed a commit that referenced this pull request Apr 13, 2020
This is the second in a series of most likely three PRs about the cohomology functor. As such, this PR depends on #2373.

In the project laid out in `homology.lean`, @semorrison asks what the minimal assumptions are that are needed to get induced maps on images. In this PR, I offer a tautologial answer to this question: We get induced maps on images when there are induced maps on images. In this way, we can let type class resolution answer the question whether cohomology is functorial.

In particular, the third PR will contain the fact that if our images are strong epi-mono factorizations, then we get induced maps on images. Since the regular coimage construction in regular categories is a strong epi-mono factorization, the approach in this PR generalizes the previous suggestion of requiring `V` to be regular.

A quick remark about cohomology and dependent types: As you can see, at one point Lean forces us to write `i - 1 + 1` instead of `i` because these two things are not definitionally equal. I am afraid, as we do more with cohomology, there will be many cases of this issue, and to compose morphisms whose types contain different incarnations of the same integer, we will have to insert some `eq_to_hom`-esque glue and pray that we will be able to rewrite them all away in the proofs without getting the beloved `motive is not type correct` error. Maybe there is some better way to solve this problem? (Or am I overthinking this and it is not actually going to be an issue at all?)
b-mehta pushed a commit that referenced this pull request Apr 13, 2020
This is the second in a series of most likely three PRs about the cohomology functor. As such, this PR depends on #2373.

In the project laid out in `homology.lean`, @semorrison asks what the minimal assumptions are that are needed to get induced maps on images. In this PR, I offer a tautologial answer to this question: We get induced maps on images when there are induced maps on images. In this way, we can let type class resolution answer the question whether cohomology is functorial.

In particular, the third PR will contain the fact that if our images are strong epi-mono factorizations, then we get induced maps on images. Since the regular coimage construction in regular categories is a strong epi-mono factorization, the approach in this PR generalizes the previous suggestion of requiring `V` to be regular.

A quick remark about cohomology and dependent types: As you can see, at one point Lean forces us to write `i - 1 + 1` instead of `i` because these two things are not definitionally equal. I am afraid, as we do more with cohomology, there will be many cases of this issue, and to compose morphisms whose types contain different incarnations of the same integer, we will have to insert some `eq_to_hom`-esque glue and pray that we will be able to rewrite them all away in the proofs without getting the beloved `motive is not type correct` error. Maybe there is some better way to solve this problem? (Or am I overthinking this and it is not actually going to be an issue at all?)
@bryangingechen bryangingechen deleted the arrow_category branch April 14, 2020 06:00
@TwoFX TwoFX moved this from In progress to Done in Homological algebra Apr 14, 2020
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I
* add documentation for `comma.lean`,
* introduce the arrow category as a special case of the comma construction, and
* introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 15, 2020
…2374)

This is the second in a series of most likely three PRs about the cohomology functor. As such, this PR depends on leanprover-community#2373.

In the project laid out in `homology.lean`, @semorrison asks what the minimal assumptions are that are needed to get induced maps on images. In this PR, I offer a tautologial answer to this question: We get induced maps on images when there are induced maps on images. In this way, we can let type class resolution answer the question whether cohomology is functorial.

In particular, the third PR will contain the fact that if our images are strong epi-mono factorizations, then we get induced maps on images. Since the regular coimage construction in regular categories is a strong epi-mono factorization, the approach in this PR generalizes the previous suggestion of requiring `V` to be regular.

A quick remark about cohomology and dependent types: As you can see, at one point Lean forces us to write `i - 1 + 1` instead of `i` because these two things are not definitionally equal. I am afraid, as we do more with cohomology, there will be many cases of this issue, and to compose morphisms whose types contain different incarnations of the same integer, we will have to insert some `eq_to_hom`-esque glue and pray that we will be able to rewrite them all away in the proofs without getting the beloved `motive is not type correct` error. Maybe there is some better way to solve this problem? (Or am I overthinking this and it is not actually going to be an issue at all?)
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I
* add documentation for `comma.lean`,
* introduce the arrow category as a special case of the comma construction, and
* introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.
anrddh pushed a commit to anrddh/mathlib that referenced this pull request May 16, 2020
…2374)

This is the second in a series of most likely three PRs about the cohomology functor. As such, this PR depends on leanprover-community#2373.

In the project laid out in `homology.lean`, @semorrison asks what the minimal assumptions are that are needed to get induced maps on images. In this PR, I offer a tautologial answer to this question: We get induced maps on images when there are induced maps on images. In this way, we can let type class resolution answer the question whether cohomology is functorial.

In particular, the third PR will contain the fact that if our images are strong epi-mono factorizations, then we get induced maps on images. Since the regular coimage construction in regular categories is a strong epi-mono factorization, the approach in this PR generalizes the previous suggestion of requiring `V` to be regular.

A quick remark about cohomology and dependent types: As you can see, at one point Lean forces us to write `i - 1 + 1` instead of `i` because these two things are not definitionally equal. I am afraid, as we do more with cohomology, there will be many cases of this issue, and to compose morphisms whose types contain different incarnations of the same integer, we will have to insert some `eq_to_hom`-esque glue and pray that we will be able to rewrite them all away in the proofs without getting the beloved `motive is not type correct` error. Maybe there is some better way to solve this problem? (Or am I overthinking this and it is not actually going to be an issue at all?)
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I
* add documentation for `comma.lean`,
* introduce the arrow category as a special case of the comma construction, and
* introduce the notion of functorial images, which means that commutative squares induce morphisms on images making the obvious diagram commute.
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
…2374)

This is the second in a series of most likely three PRs about the cohomology functor. As such, this PR depends on leanprover-community#2373.

In the project laid out in `homology.lean`, @semorrison asks what the minimal assumptions are that are needed to get induced maps on images. In this PR, I offer a tautologial answer to this question: We get induced maps on images when there are induced maps on images. In this way, we can let type class resolution answer the question whether cohomology is functorial.

In particular, the third PR will contain the fact that if our images are strong epi-mono factorizations, then we get induced maps on images. Since the regular coimage construction in regular categories is a strong epi-mono factorization, the approach in this PR generalizes the previous suggestion of requiring `V` to be regular.

A quick remark about cohomology and dependent types: As you can see, at one point Lean forces us to write `i - 1 + 1` instead of `i` because these two things are not definitionally equal. I am afraid, as we do more with cohomology, there will be many cases of this issue, and to compose morphisms whose types contain different incarnations of the same integer, we will have to insert some `eq_to_hom`-esque glue and pray that we will be able to rewrite them all away in the proofs without getting the beloved `motive is not type correct` error. Maybe there is some better way to solve this problem? (Or am I overthinking this and it is not actually going to be an issue at all?)
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
Development

Successfully merging this pull request may close these issues.

None yet

3 participants