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(algebra/direct_sum_graded): endow direct_sum with a ring structure #6053

Closed
wants to merge 12 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Feb 5, 2021

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).


This PR is an alternative to #5956

Copy link
Member

@robertylewis robertylewis left a 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.

src/algebra/direct_sum_graded.lean Outdated Show resolved Hide resolved
src/algebra/direct_sum_graded.lean Outdated Show resolved Hide resolved
end

private lemma mul_assoc (a b c : ⨁ i, A i) : a * b * c = a * (b * c) :=
begin
Copy link
Member

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 onlys can be combined (and above too), same with rw/erws.

Copy link
Member Author

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...

Copy link
Member Author

@eric-wieser eric-wieser Feb 22, 2021

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?

Copy link
Collaborator

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).

Copy link
Member Author

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!

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've replaced almost all the simp onlys with rw, and the proof is almost an order of magnitude faster.

@robertylewis robertylewis 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 Feb 22, 2021
@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Feb 22, 2021
Copy link
Collaborator

@Vierkantor Vierkantor left a 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.

src/algebra/direct_sum_graded.lean Outdated Show resolved Hide resolved
src/algebra/direct_sum_graded.lean Outdated Show resolved Hide resolved
Co-authored-by: Anne Baanen <Vierkantor@users.noreply.github.com>
@jcommelin
Copy link
Member

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

@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 Mar 4, 2021
bors bot pushed a commit that referenced this pull request Mar 4, 2021
…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)`.
@bors
Copy link

bors bot commented Mar 4, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(algebra/direct_sum_graded): endow direct_sum with a ring structure [Merged by Bors] - feat(algebra/direct_sum_graded): endow direct_sum with a ring structure Mar 4, 2021
@bors bors bot closed this Mar 4, 2021
@bors bors bot deleted the direct_sum_graded branch March 4, 2021 16:01
b-mehta pushed a commit that referenced this pull request Apr 2, 2021
…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)`.
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+`.)
Development

Successfully merging this pull request may close these issues.

None yet

5 participants