-
Notifications
You must be signed in to change notification settings - Fork 297
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(algebra/direct_sum_graded): endow direct_sum
with a ring structure
#6053
Conversation
340a635
to
3809e02
Compare
3809e02
to
565de58
Compare
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.
This looks reasonable but I think some of the proofs can use some golfing. I'm no expert here so I'd appreciate another review.
end | ||
|
||
private lemma mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) := | ||
begin |
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.
This proof looks really weird, did it come from tidy
? Lots of simp only
s can be combined (and above too), same with rw
/erw
s.
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.
Nope, it was written by hand...
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 think I found that sometimes simp only [x, y], simp only [z]
would behave differently compared to simp only [x, y, z]
, since the former requires z
to happen only after all x and y are done. I'll see if I can reduce this further though. Would you expect combining simp / erw / rw calls to speed up the proofs?
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 don't think combing calls would be expected to speed up a proof at all significantly. If that were the concern, possibly simp_rw
with a correctly ordered list would be superior.
But I don't think speed is what Rob was noticing here; just that it's mildly confusing to have them separate (just because a reader can look at it and think "hmm, it's strange these were done as separate tactic invocations, there must be some good reason for that" and then be left unable to guess a reason).
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.
Something else that motivated it was to try and group together morally similar lemmas, so that the progression in tactic states looked reasonable - the depth of binders makes this proof really quite hard to keep track of.
Golfing attempts greatly appreciated, as usual!
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've replaced almost all the simp only
s with rw
, and the proof is almost an order of magnitude faster.
9e88c22
to
618c3a8
Compare
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.
Found a few typos, otherwise looks good to me.
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
Somewhere some part of me feels a bit uneasy about the heterogeneous classes and potential DTT issues. But several eyes have now looked at this, and several brains haven't come up with a better strategy. So let's move forward and try this out. If (not when) issues arise later, then we'll deal with them at that point. bors merge |
…ture (#6053) To quote the module docstring > This module provides a set of heterogenous typeclasses for defining a multiplicative structure > over `⨁ i, A i` such that `(*) : A i → A j → A (i + j)`; that is to say, `A` forms an > additively-graded ring. The typeclasses are: > > * `direct_sum.ghas_one A` > * `direct_sum.ghas_mul A` > * `direct_sum.gmonoid A` > * `direct_sum.gcomm_monoid A` > > Respectively, these imbue the direct sum `⨁ i, A i` with: > > * `has_one` > * `mul_zero_class`, `distrib` > * `semiring`, `ring` > * `comm_semiring`, `comm_ring` > > Additionally, this module provides helper functions to construct `gmonoid` and `gcomm_monoid` > instances for: > > * `A : ι → submonoid S`: `direct_sum.ghas_one.of_submonoids`, `direct_sum.ghas_mul.of_submonoids`, > `direct_sum.gmonoid.of_submonoids`, `direct_sum.gcomm_monoid.of_submonoids` > * `A : ι → submonoid S`: `direct_sum.ghas_one.of_subgroups`, `direct_sum.ghas_mul.of_subgroups`, > `direct_sum.gmonoid.of_subgroups`, `direct_sum.gcomm_monoid.of_subgroups` > > If the `A i` are disjoint, these provide a gradation of `⨆ i, A i`, and the mapping > `⨁ i, A i →+ ⨆ i, A i` can be obtained as > `direct_sum.to_monoid (λ i, add_submonoid.inclusion $ le_supr A i)`.
Pull request successfully merged into master. Build succeeded: |
direct_sum
with a ring structuredirect_sum
with a ring structure
…ture (#6053) To quote the module docstring > This module provides a set of heterogenous typeclasses for defining a multiplicative structure > over `⨁ i, A i` such that `(*) : A i → A j → A (i + j)`; that is to say, `A` forms an > additively-graded ring. The typeclasses are: > > * `direct_sum.ghas_one A` > * `direct_sum.ghas_mul A` > * `direct_sum.gmonoid A` > * `direct_sum.gcomm_monoid A` > > Respectively, these imbue the direct sum `⨁ i, A i` with: > > * `has_one` > * `mul_zero_class`, `distrib` > * `semiring`, `ring` > * `comm_semiring`, `comm_ring` > > Additionally, this module provides helper functions to construct `gmonoid` and `gcomm_monoid` > instances for: > > * `A : ι → submonoid S`: `direct_sum.ghas_one.of_submonoids`, `direct_sum.ghas_mul.of_submonoids`, > `direct_sum.gmonoid.of_submonoids`, `direct_sum.gcomm_monoid.of_submonoids` > * `A : ι → submonoid S`: `direct_sum.ghas_one.of_subgroups`, `direct_sum.ghas_mul.of_subgroups`, > `direct_sum.gmonoid.of_subgroups`, `direct_sum.gcomm_monoid.of_subgroups` > > If the `A i` are disjoint, these provide a gradation of `⨆ i, A i`, and the mapping > `⨁ i, A i →+ ⨆ i, A i` can be obtained as > `direct_sum.to_monoid (λ i, add_submonoid.inclusion $ le_supr A i)`.
To quote the module docstring
This PR is an alternative to #5956