[Merged by Bors] - fix(Tactic/Ring): sort terms when evaluating nested powers#37494
Closed
FLDutchmann wants to merge 3 commits intoleanprover-community:masterfrom
Closed
[Merged by Bors] - fix(Tactic/Ring): sort terms when evaluating nested powers#37494FLDutchmann wants to merge 3 commits intoleanprover-community:masterfrom
FLDutchmann wants to merge 3 commits intoleanprover-community:masterfrom
Conversation
PR summary cbbd8c9b8bImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>The doc-module for No changes to technical debt.You can run this locally as
|
Collaborator
Author
|
!bench |
|
Benchmark results for 21266de against cbbd8c9 are in. There are no significant changes. @FLDutchmann
Small changes (1✅)
|
grunweg
reviewed
Apr 1, 2026
Contributor
grunweg
left a comment
There was a problem hiding this comment.
Seems reasonable, thanks! Let me only maintainer merge this since I'm not an expert on ring.
maintainer merge
|
🚀 Pull request has been placed on the maintainer queue by grunweg. |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Apr 2, 2026
`ring` currently misorders the terms in a product when evaluating nested powers. When evaluating e.g. `(x^a*x)^b` where `x` is an atom, it returns `x^(a*b)*x^b` even if `b` is supposed to come before `a*b` in the ordering on `ExProd`s. We fix this by running `evalMulProd` instead of using the `.mul` constructor directly. This in effect does an insertion sort on the terms in the `ExProd`s. We do a similar thing when evaluating multiplication. ``` /-- error: ring failed, ring expressions not equal a : ℚ m n : ℕ ⊢ a ^ n * a ^ (m * n) = a ^ (m * n) * a ^ n -/ #guard_msgs in example (a : ℚ) (m n : ℕ) : (a ^ (m + 1)) ^ n = a ^ (n * (m + 1)) := by ring1 ```
Contributor
|
Build failed (retrying...): |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Apr 2, 2026
`ring` currently misorders the terms in a product when evaluating nested powers. When evaluating e.g. `(x^a*x)^b` where `x` is an atom, it returns `x^(a*b)*x^b` even if `b` is supposed to come before `a*b` in the ordering on `ExProd`s. We fix this by running `evalMulProd` instead of using the `.mul` constructor directly. This in effect does an insertion sort on the terms in the `ExProd`s. We do a similar thing when evaluating multiplication. ``` /-- error: ring failed, ring expressions not equal a : ℚ m n : ℕ ⊢ a ^ n * a ^ (m * n) = a ^ (m * n) * a ^ n -/ #guard_msgs in example (a : ℚ) (m n : ℕ) : (a ^ (m + 1)) ^ n = a ^ (n * (m + 1)) := by ring1 ```
Contributor
|
Pull request successfully merged into master. Build succeeded: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ringcurrently misorders the terms in a product when evaluating nested powers. When evaluating e.g.(x^a*x)^bwherexis an atom, it returnsx^(a*b)*x^beven ifbis supposed to come beforea*bin the ordering onExProds.We fix this by running
evalMulProdinstead of using the.mulconstructor directly. This in effect does an insertion sort on the terms in theExProds. We do a similar thing when evaluating multiplication.This bug was pointed out to me by @Multramate
The fix in this PR was written and investigated with the help of Claude code.