fix: `grind` ring solver OOM on high-degree polynomials (#13032) This PR fixes #12842 where `grind` exhausts memory on goals involving high-degree polynomials such as `(x + y)^2 = x^128 + y^2` over `Fin 2`. The root cause is that `incSteps` in the ring module's Groebner basis engine increments the step counter by 1 per simplification, regardless of polynomial size. For high-degree polynomials (e.g., degree 128), intermediate results can have hundreds of terms, making each operation extremely expensive — but the flat counter cannot catch this before memory is exhausted. The fix weights each step by `Poly.numTerms` of the result polynomial and increases the default `ringSteps` from 10 000 to 100 000 to accommodate the new cost model. Note: the example from #12842 will not be *proved* by `grind` even after this fix, because Frobenius / Fermat's little theorem (`x^p = x` in `Fin p`) is not available in core Lean. The long-term plan is to introduce a type class in core stating this property, with an instance provided by Mathlib, so that `grind` can exploit it when Mathlib is imported. Closes #12842 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This is the repository for Lean 4.
See Install Lean.
Please read our Contribution Guidelines first.
See Building Lean.