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_action/defs): add missing comp_hom smul instances #8707

Closed
wants to merge 6 commits into from

Conversation

eric-wieser
Copy link
Member

@eric-wieser eric-wieser commented Aug 16, 2021

This adds missing smul_comm_class and is_scalar_tower instances about the comp_hom definitions.

To resolve unification issues in finding these instances caused by the reducibility of the comp_hom defs, this introduces a semireducible def has_scalar.comp.smul.


I'll follow up with a PR about ring_hom.to_algebra.

Open in Gitpod

@eric-wieser eric-wieser added the awaiting-review The author would like community review of the PR label Aug 16, 2021
@Vierkantor
Copy link
Collaborator

The new instances seem to be creating a loop along with instances further down the import hierarchy, see the linting errors. I've been testing a few files by adding the command

#eval tactic.get_decl ``smul_comm_class >>= fails_quickly 3000 >>= tactic.trace

which returns some "error message" if inference fails or takes too long. I haven't yet found the culprit.

@Vierkantor
Copy link
Collaborator

In fact, running the command in the auto-generated all.lean file doesn't cause the error. Only when setting the limit to less than 700 I get the error. So I might be doing something wrong...

@eric-wieser
Copy link
Member Author

I think it might be a reducibility issue. I think if I introduce a semireducible def to wrap the smul field then the problem will go away

bors bot pushed a commit that referenced this pull request Aug 18, 2021
* The problem was that when writing `@[to_additive] def foo ...` every declaration used in `foo` in namespace `foo` would be additivized without changing the last part of the name. This behavior was intended to translate automatically generated declarations like `foo._proof_1`. However, if `foo` contains a non-internal declaration `foo.bar` and `add_foo.bar` didn't exist yet, it would also create a declaration `add_foo.bar` additivizing `foo.bar`.
* This PR changes the behavior: if `foo.bar` has the `@[to_additive]` attribute (potentially with a custom additive name), then we won't create a second additive version of `foo.bar`, and succeed normally. However, if `foo.bar` doesn't have the `@[to_additive]` attribute, then we fail with a nice error message. We could potentially support this behavior, but it doesn't seem that worthwhile and it would require changing a couple low-level definitions that `@[to_additive]` uses (e.g. by replacing `name.map_prefix` so that it only maps prefixes if the name is `internal`).
* So far this didn't happen in the library yet. There are currently 5 non-internal declarations `foo.bar` that are used in `foo` where `foo` has the `@[to_additive]` attribute, but all of these declarations were already had an additive version `add_foo.bar`.
* These 5 declarations are `[Mon.has_limits.limit_cone, Mon.has_limits.limit_cone_is_limit, con_gen.rel, magma.free_semigroup.r, localization.r]`
* This fixes the error in #8707 and resolves the Zulip thread https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.238707.20linter.20weirdness
* I also added some documentation / comments to the function `transform_decl_with_prefix_fun_aux`, made it non-private, and rewrote some steps.
src/algebra/module/linear_map.lean Outdated Show resolved Hide resolved
src/algebra/module/linear_map.lean Outdated Show resolved Hide resolved
src/algebra/module/linear_map.lean Outdated Show resolved Hide resolved
@jcommelin jcommelin 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 Aug 19, 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 Aug 19, 2021
@jcommelin jcommelin 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 Aug 19, 2021
Co-authored-by: Johan Commelin <johan@commelin.net>
@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 Aug 19, 2021
Copy link
Member

@jcommelin jcommelin left a comment

Choose a reason for hiding this comment

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

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 Aug 19, 2021
bors bot pushed a commit that referenced this pull request Aug 19, 2021
This adds missing `smul_comm_class` and `is_scalar_tower` instances about the `comp_hom` definitions.

To resolve unification issues in finding these instances caused by the reducibility of the `comp_hom` defs, this introduces a semireducible def `has_scalar.comp.smul`.
@bors
Copy link

bors bot commented Aug 19, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(group_action/defs): add missing comp_hom smul instances [Merged by Bors] - feat(group_action/defs): add missing comp_hom smul instances Aug 19, 2021
@bors bors bot closed this Aug 19, 2021
@bors bors bot deleted the eric-wieser/module.comp_hom branch August 19, 2021 14:31
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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants