Skip to content

chore: weaken commutativity assumptions for AdjoinRoot.lift and AdjoinRoot.liftHom - #9564

Closed
AntoineChambert-Loir wants to merge 19 commits into
masterfrom
ACL/AdjoinRoot
Closed

AntoineChambert-Loir wants to merge 19 commits into
masterfrom
ACL/AdjoinRoot

Conversation

@AntoineChambert-Loir

@AntoineChambert-Loir AntoineChambert-Loir commented Jan 8, 2024

Copy link
Copy Markdown
Collaborator

I weaken a commutativity assumption for docs#AdjoinRoot.liftHom that the target algebra be commutative. It is only assumed to be a Semiring.
For that, I need to generalize docs#AdjoinRoot.lift which takes i : R ->+* S, a : S with f.eval₂ i a = 0 and defines AdjoinRoot f ->+* S that extends i and sends AdjoinRoot.root f to a.


The initial version of the PR was to define AdjoinRoot.lift' where S is only a Semiring, with the additional assumption hcomm : ∀ r, Commute (i r) a that the element a commutes with the image of i.

@jcommelin suggested to provide this argument as an autoParam, filled in by an ad hoc commutativity tactic. However, such an argument cannot be made implicit and a first version required to have this argument given each time, most of the time by _, even for all subsequent lemmas, AdjoinRoot.lift_mk, etc.

To avoid this, I tried to make this assumption a ⦃hcomm : ∀ r, Commute (i r) a⦄. This appears to have some side effects that proofs using an exact tactic or in term mode do not work well, but one can resort on by simp […]. Maybe @eric-wieser or @Vierkantor will have opinions on that. In some cases one can still give the argument as (hcomm := by commutativity).

(There are 3 options :

  • separate lemmas for the fully commutative case and for the case where a proof is needed
  • using the commutativity tactic, but with an argument _ sometimes
  • using the optional argument.)

Open in Gitpod

@AntoineChambert-Loir AntoineChambert-Loir changed the title remove commutativity assumptions for AdjoinRoot remove commutativity assumptions for AdjoinRoot.lift Jan 8, 2024
@AntoineChambert-Loir AntoineChambert-Loir changed the title remove commutativity assumptions for AdjoinRoot.lift weaken commutativity assumptions for AdjoinRoot.lift and AdjoinRoot.liftHom Jan 8, 2024
@AntoineChambert-Loir AntoineChambert-Loir added awaiting-review t-algebra Algebra (groups, rings, fields, etc) labels Jan 9, 2024
Comment thread Mathlib/FieldTheory/Adjoin.lean Outdated
Comment on lines +994 to +995
-- It is a bit annoying that one be obliged to fill in this implicit hypothesis
AdjoinRoot.lift_root (hc := fun _ ↦ Commute.all _ _) (aeval_gen_minpoly F α)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder whether it can maybe be supplied by a default argument/tactic. So that users in the commutative world never need to think about it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@jcommelin I tried to think about this, but got confused by the syntax and could not make any progress (what I tried did not work at all). From the Zulip discussion, it seems that you had an idea of how that could be implemented… Could you please share some hint?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I pushed to jmc-AdjoinRoot. I'll let you decide which option you prefer.

(Note that I renamed lift' to lift, and there is now only one version.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I just had a look! Wonderful!

Comment thread Mathlib/RingTheory/AdjoinRoot.lean Outdated
@AntoineChambert-Loir

AntoineChambert-Loir commented Jan 20, 2024

Copy link
Copy Markdown
Collaborator Author

The AdjoinRoot.lift function now allows that target to be noncommutative, it only needs a proof that the element that AdjoinRoot.root f maps to commutes with the image of the ring.
Thanks to a tactic commutativity provided by @jcommelin , this argument can be filled automatically.
In all subsequent rewriting lemmas, I made it ⦃hcomm : ∀ r, Commute (i r) a⦄, but the defect is that I couldn't really use exact tactics, or term-mode proofs, so that the proofs are now a bit ugly, using a lot of by simp […].

Antoine Chambert-Loir and others added 3 commits January 20, 2024 20:16
This allows us to restore quite a few uses of `lift` to the original. The only drawback in the commutative case is we have to write `(lift i a h) x` instead of `lift i a h x` (since the autoparam comes after the `h`). Also, `simp` doesn't discharge autoparams automatically, so I added an extra set of lemmas that use implicits instead of autoparams, to be filled by unification.
@Vierkantor

Copy link
Copy Markdown
Contributor

I pushed a commit which tags a few lemmas and replaces commutativity with a call to aesop. It's almost as good as original for the commutative case, if you ignore the parentheses :)

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 25, 2024
Comment thread Mathlib/RingTheory/AdjoinRoot.lean Outdated
apply Ideal.Quotient.lift _ (eval₂RingHom i x)
It is currently only used in `AdjoinRoot.lift`. -/
macro "commutativity" : tactic =>
`(tactic| first | aesop |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably raise an error if there is no Commute in the goal

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@eric-wieser Do you know how to check this? I don't...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are Aesop rulesets a thing? If not, using guard_target would probably work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

guard_target isn't quite what we want here: for example, lift wants to use commutativity to solve ∀ r, Commute (i r) x.

WRT rulesets: do you mean we should set the commutativity tactic to use a commutativity ruleset exclusively? I feel like that's premature optimization.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I think we should do that because it matches the pattern set by measurability. I don't think that commutativity as a tactic should be solving everything that aesop can solve.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@eric-wieser @Vierkantor do you want me to try copying the measurability tactic file and build a commutativity tactic along its line?

@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Apr 1, 2024
@AntoineChambert-Loir AntoineChambert-Loir added WIP Work in progress and removed awaiting-review labels Apr 1, 2024
/-
Copyright (c) 2024 Antoine Chambert-Loir. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Antoine Chambert-Lori (based on Measurability, by Miyahara Kō)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Typo? :)

Suggested change
Authors: Antoine Chambert-Lori (based on Measurability, by Miyahara Kō)
Authors: Antoine Chambert-Loir (based on Measurability, by Miyahara Kō)

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Apr 29, 2024
@grunweg grunweg changed the title weaken commutativity assumptions for AdjoinRoot.lift and AdjoinRoot.liftHom chore: weaken commutativity assumptions for AdjoinRoot.lift and AdjoinRoot.liftHom Nov 19, 2025
@joneugster

Copy link
Copy Markdown
Contributor

Mathlib has moved to PRs from forks. This PR is still from a branch of the main repository and will soon be closed! Please migrate the content to a fork and reopen a PR from there if you wish to do so. See Zulip topic for more instructions. Thank you for contributing to mathlib!

@joneugster joneugster added the will-close-soon Unless something changes, we will close this PR soon label Sep 19, 2026
@joneugster
joneugster marked this pull request as draft September 19, 2026 16:46
@mathlib-bors

mathlib-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

This pull request is now in draft mode. No active bors state needed cleanup.

While this PR remains draft, bors will ignore commands on this PR. Mark it ready for review before using commands like bors r+ or bors try.

@AntoineChambert-Loir

Copy link
Copy Markdown
Collaborator Author

This PR has been migrated to a fork-based workflow: #43971

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) migrated-to-fork t-algebra Algebra (groups, rings, fields, etc) will-close-soon Unless something changes, we will close this PR soon WIP Work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants