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
Conversation
Could you add a paragraph to the module doc for |
{ 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] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ 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
.
- 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. - I know that I've written a great many
erw
s in the category_theory library, but most of them are code smells, and we should be suspicious of them. - In this case let's leave the proofs out, as they are boring and
tidy
can cope just fine.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
Done! |
bors d+ |
✌️ TwoFX can now approve this pull request. To approve and merge a pull request, simply reply with |
bors r+ |
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.
Build succeeded |
Pull request successfully merged into master. |
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?)
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?)
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.
…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?)
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.
…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?)
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.
…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?)
This is the first in a series of most likely three PRs about the cohomology functor. In this PR, I
comma.lean
,TO CONTRIBUTORS:
Make sure you have:
If this PR is related to a discussion on Zulip, please include a link in the discussion.
For reviewers: code review check list