fix: propagate ring equalities that agree up to a constant factor in grind

This PR fixes a regression in the `grind` commutative ring solver where an equality implied by the basis was not propagated when the two sides simplified to the same polynomial up to a common constant factor (e.g., `3 * a` to `3 * p` and `b` to `p`). The regression was exposed by #16525, which changed which basis equation is used to simplify a monomial, and broke a `grind` proof in Mathlib's `Stirling.lean`.

`propagateEqs` looked up candidate equalities by the pair `(k, p)`, where `k` is the multiplier of the simplified polynomial `p`. The key is now divided by `gcd(k, gcdCoeffs p)`. The key only selects candidates; soundness is still ensured by checking that `a - b` simplifies to `0`. This also fixes the key used in the branch for rings without `NoNatZeroDivisors`, which inserted the term under the normal form of `a - b` instead of its own.

The trace in `grind_cutsat_reorder.lean` is updated: the last example now needs two fewer variable reorderings.
3 files changed