Commit 6dc769a
committed
fix(Tactic/Ring): sort terms when evaluating nested powers (#37494)
`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
```1 parent f5da5c5 commit 6dc769a
2 files changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
899 | 899 | | |
900 | 900 | | |
901 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
902 | 907 | | |
903 | 908 | | |
904 | 909 | | |
| |||
933 | 938 | | |
934 | 939 | | |
935 | 940 | | |
936 | | - | |
| 941 | + | |
| 942 | + | |
937 | 943 | | |
938 | 944 | | |
939 | 945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
169 | 170 | | |
170 | 171 | | |
171 | 172 | | |
| |||
0 commit comments