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(group_theory/group_action): define distrib_smul and smul_zero_class #16123

Closed
wants to merge 11 commits into from

Conversation

Vierkantor
Copy link
Collaborator

These are two new superclasses of distrib_mul_action that get rid of the mul_action part:

  • smul_zero_class is has_smul + a • 0 = 0
  • distrib_smul is smul_zero_class + a • (x + y) = a • x + a • y.

The motivation for these classes is to instantiate qsmul on splitting_field: in general scalar multiplication with rational numbers is not a distrib_mul_action but it is a distrib_smul, and distrib_smul is sufficient to lift an action to the splitting_field.

I set up both distrib_mul_action and smul_with_zero to be subclasses of the above classes, and unify smul_zero (depending on distrib_mul_action) and smul_zero' (depending on smul_with_zero) into one lemma.

There are a few places where I need to help the elaborator because e.g. it's expecting units.mk0 a ha • 0 = 0 (with smul coming from distrib_mul_action) and getting a • 0 = 0 (with smul coming from smul_zero_class). Apparently having both the type and instance differ is too hard for the unifier. Because we don't have definitional eta for structures yet, setting up the inheritance is a bit more tricky than you might think; I added an example test case to ensure everything stays OK.


Open in Gitpod

…_class`

These are two new superclasses of `distrib_mul_action` that get rid of the `mul_action` part:

 * `smul_zero_class` is `has_smul` + `a • 0 = 0`
 * `distrib_smul` is `smul_zero_class` + `a • (x + y) = a • x + a • y`.

The motivation for these classes is to instantiate `qsmul` on `splitting_field`: in general scalar multiplication with rational numbers is not a `distrib_mul_action` but it is a `distrib_smul`, and `distrib_smul` is sufficient to lift an action to the `splitting_field`.

I set up both `distrib_mul_action` and `smul_with_zero` to be subclasses of the above classes, and unify `smul_zero` (depending on `distrib_mul_action`) and `smul_zero'` (depending on `smul_with_zero`) into one lemma.

There are a few places where I need to help the elaborator because e.g. it's expecting `units.mk0 a ha • 0 = 0` (with `smul` coming from `distrib_mul_action`) and getting `a • 0 = 0` (with `smul` coming from `smul_zero_class`). Apparently having both the type and instance differ is too hard for the unifier. Because we don't have definitional eta for structures yet, setting up the inheritance is a bit more tricky than you might think; I added an `example` test case to ensure everything stays OK.
@Vierkantor Vierkantor added awaiting-review The author would like community review of the PR awaiting-CI The author would like to see what CI has to say before doing more work. t-algebra Algebra (groups, rings, fields etc) labels Aug 18, 2022
@YaelDillies
Copy link
Collaborator

I would have expected smul_zero to take the monoid the 0 is from as an explicit argument, as is done with one_smul. But I guess there is a difference in one being the ring and the other being the module?

@Vierkantor
Copy link
Collaborator Author

I would have expected smul_zero to take the monoid the 0 is from as an explicit argument, as is done with one_smul. But I guess there is a difference in one being the ring and the other being the module?

I would expect the same, but that is how the distributive_mul_action version did it and it's by far more popular than smul_with_zero's smul_zero' which did have the explicit parameter. So I went with the more popular option.

Copy link
Collaborator

@ericrbg ericrbg left a comment

Choose a reason for hiding this comment

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

lgtm in general, there's some todos that feel out of scope for this PR but I think should be noted:

  • replace some uses of smul_with_zero to smul_zero_class (e.g. unitization's coe_smul) as the requirements are now overly strong
  • make pi/prod instances (although I see there is some in group_theory/group_action/pi - why do we have different files for this? is it import issues? [the old ones seem to be in algebra/module/pi])

@Vierkantor
Copy link
Collaborator Author

Vierkantor commented Aug 18, 2022

  • make pi/prod instances (although I see there is some in group_theory/group_action/pi - why do we have different files for this? is it import issues? [the old ones seem to be in algebra/module/pi])

I already added instances for pi, prod, set, ulift and units, next to the existing distrib_mul_action instances in whatever file those were already. I assume the separation of those files is just so that group_action/basic.lean doesn't become obnoxiously big?

Vierkantor added a commit that referenced this pull request Aug 18, 2022
This PR builds on #16123 by adding `distrib_smul` (and `smul_zero_class`) instances for:
 * `finsupp`
 * `add_monoid_algebra`
 * `polynomial`
 * submodule quotients
 * scalar multiplication by `ℚ`

It also generalizes some results by weakening `distrib_mul_action` to `distrib_smul`. The choice of instances and generalizations is based on which are necessary to solve instance diamonds in `splitting_field`, so I probably missed a lot of additional changes. Since I'm not so interested in generalizing everything at the moment, I'd rather leave missing instances to follow-up PRs.
@Vierkantor
Copy link
Collaborator Author

I followed up with some generalizations and additional instances in #16132, at least the ones we needed for the splitting field diamond.

Vierkantor added a commit that referenced this pull request Aug 19, 2022
This PR builds on #16123 by adding `distrib_smul` (and `smul_zero_class`) instances for:
 * `finsupp`
 * `add_monoid_algebra`
 * `polynomial`
 * submodule quotients
 * scalar multiplication by `ℚ`

It also generalizes some results by weakening `distrib_mul_action` to `distrib_smul`. The choice of instances and generalizations is based on which are necessary to solve instance diamonds in `splitting_field`, so I probably missed a lot of additional changes. Since I'm not so interested in generalizing everything at the moment, I'd rather leave missing instances to follow-up PRs.
@Vierkantor
Copy link
Collaborator Author

I'm having trouble dealing with the timeouts indicated by the slow-instances linter: it appears this PR doesn't really add to the search space much (there's definitely no recursive instances) so the only explanation is that the space is now just barely big enough to cause linter timeouts.

It's not an actual timeout BTW: lean -T100000 all.lean fails without timeout.

@ericrbg
Copy link
Collaborator

ericrbg commented Aug 22, 2022

aren't we allowed to bump the linters' timeout in this case?

@Vierkantor
Copy link
Collaborator Author

I think I was the last one to bump this timeout so while I think it's fine, it's good to have someone else back me up on this :)

@Vierkantor
Copy link
Collaborator Author

According to binary search, looks like the correct timeout values would be about 27000 for prod.nonempty and 25000 for pi.has_smul'. The current value is 20000 so this is about a 1/3rd increase...

@ericrbg
Copy link
Collaborator

ericrbg commented Sep 5, 2022

The issue with the linter was hard to track down, right? I'll try investigate a little in a couple days if you don't know what it is, Anne

@Vierkantor
Copy link
Collaborator Author

The issue with the linter was hard to track down, right? I'll try investigate a little in a couple days if you don't know what it is, Anne

I don't really understand this timeout beyond that the circumstances suggest slow unification within types. I can't really dedicate a lot of time to my PRs in the coming weeks, so please investigate if you have some time!

@github-actions github-actions bot removed the awaiting-CI The author would like to see what CI has to say before doing more work. label Sep 7, 2022
@Vierkantor
Copy link
Collaborator Author

Sorry for not keeping this PR maintained and thanks for the fixes!

@riccardobrasca
Copy link
Member

This LGTM! I think we should merge master to see if it is still OK and then it is ready to go unless someone has an argument against it.

@riccardobrasca
Copy link
Member

Thanks!

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 Sep 23, 2022
bors bot pushed a commit that referenced this pull request Sep 23, 2022
…_class` (#16123)

These are two new superclasses of `distrib_mul_action` that get rid of the `mul_action` part:

 * `smul_zero_class` is `has_smul` + `a • 0 = 0`
 * `distrib_smul` is `smul_zero_class` + `a • (x + y) = a • x + a • y`.

The motivation for these classes is to instantiate `qsmul` on `splitting_field`: in general scalar multiplication with rational numbers is not a `distrib_mul_action` but it is a `distrib_smul`, and `distrib_smul` is sufficient to lift an action to the `splitting_field`.

I set up both `distrib_mul_action` and `smul_with_zero` to be subclasses of the above classes, and unify `smul_zero` (depending on `distrib_mul_action`) and `smul_zero'` (depending on `smul_with_zero`) into one lemma.

There are a few places where I need to help the elaborator because e.g. it's expecting `units.mk0 a ha • 0 = 0` (with `smul` coming from `distrib_mul_action`) and getting `a • 0 = 0` (with `smul` coming from `smul_zero_class`). Apparently having both the type and instance differ is too hard for the unifier. Because we don't have definitional eta for structures yet, setting up the inheritance is a bit more tricky than you might think; I added an `example` test case to ensure everything stays OK.





Co-authored-by: Mauricio Collares <mauricio@collares.org>
Co-authored-by: Eric Rodriguez <ericrboidi@gmail.com>
@bors
Copy link

bors bot commented Sep 23, 2022

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(group_theory/group_action): define distrib_smul and smul_zero_class [Merged by Bors] - feat(group_theory/group_action): define distrib_smul and smul_zero_class Sep 23, 2022
@bors bors bot closed this Sep 23, 2022
@bors bors bot deleted the distrib_smul branch September 23, 2022 17:33
Vierkantor added a commit that referenced this pull request Sep 24, 2022
This PR builds on #16123 by adding `distrib_smul` (and `smul_zero_class`) instances for:
 * `finsupp`
 * `add_monoid_algebra`
 * `polynomial`
 * submodule quotients
 * scalar multiplication by `ℚ`

It also generalizes some results by weakening `distrib_mul_action` to `distrib_smul`. The choice of instances and generalizations is based on which are necessary to solve instance diamonds in `splitting_field`, so I probably missed a lot of additional changes. Since I'm not so interested in generalizing everything at the moment, I'd rather leave missing instances to follow-up PRs.
bottine pushed a commit that referenced this pull request Sep 25, 2022
…_class` (#16123)

These are two new superclasses of `distrib_mul_action` that get rid of the `mul_action` part:

 * `smul_zero_class` is `has_smul` + `a • 0 = 0`
 * `distrib_smul` is `smul_zero_class` + `a • (x + y) = a • x + a • y`.

The motivation for these classes is to instantiate `qsmul` on `splitting_field`: in general scalar multiplication with rational numbers is not a `distrib_mul_action` but it is a `distrib_smul`, and `distrib_smul` is sufficient to lift an action to the `splitting_field`.

I set up both `distrib_mul_action` and `smul_with_zero` to be subclasses of the above classes, and unify `smul_zero` (depending on `distrib_mul_action`) and `smul_zero'` (depending on `smul_with_zero`) into one lemma.

There are a few places where I need to help the elaborator because e.g. it's expecting `units.mk0 a ha • 0 = 0` (with `smul` coming from `distrib_mul_action`) and getting `a • 0 = 0` (with `smul` coming from `smul_zero_class`). Apparently having both the type and instance differ is too hard for the unifier. Because we don't have definitional eta for structures yet, setting up the inheritance is a bit more tricky than you might think; I added an `example` test case to ensure everything stays OK.





Co-authored-by: Mauricio Collares <mauricio@collares.org>
Co-authored-by: Eric Rodriguez <ericrboidi@gmail.com>
bors bot pushed a commit that referenced this pull request Oct 1, 2022
This PR builds on #16123 by adding `distrib_smul` (and `smul_zero_class`) instances for:
 * `finsupp`
 * `add_monoid_algebra`
 * `polynomial`
 * submodule quotients
 * scalar multiplication by `ℚ`

It also generalizes some results by weakening `distrib_mul_action` to `distrib_smul`. The choice of instances and generalizations is based on which are necessary to solve instance diamonds in `splitting_field`, so I probably missed a lot of additional changes. Since I'm not so interested in generalizing everything at the moment, I'd rather leave missing instances to follow-up PRs.



Co-authored-by: Eric Rodriguez <ericrboidi@gmail.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+`.) t-algebra Algebra (groups, rings, fields etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants