Skip to content

fix: limit ring solver polynomial degree in grind#13585

Merged
leodemoura merged 3 commits into
masterfrom
grind_ring_poly_safe
Apr 30, 2026
Merged

fix: limit ring solver polynomial degree in grind#13585
leodemoura merged 3 commits into
masterfrom
grind_ring_poly_safe

Conversation

@leodemoura
Copy link
Copy Markdown
Member

This PR adds a ringMaxDegree configuration option (default 1024) that bounds the maximum degree of polynomials processed by the grind ring solver. Equality constraints whose polynomial exceeds this threshold are discarded (with an issue reported once per goal), preventing pathological degree explosion on inputs such as r ^ (2 ^ 250 - 1).

This PR also introduces Poly.simpM?, a monadic version of Poly.simp? built on the existing safe arithmetic primitives (mulMonM, combineM, mulConstM) in Grind.Arith.CommRing.SafePoly. The previous reflection-oriented Poly.simp? in Sym.Arith.Poly lacked the abort mechanisms needed during proof search, so the simplification path used by EqCnstr now goes through the safe variant. A regression test tests/elab/grind_ring_degree_explosion.lean ensures grind fails quickly on high-degree problems.

@leodemoura leodemoura added the changelog-tactics User facing tactics label Apr 30, 2026
@leodemoura leodemoura enabled auto-merge April 30, 2026 13:45
@leodemoura leodemoura added this pull request to the merge queue Apr 30, 2026
Merged via the queue into master with commit 427e3bc Apr 30, 2026
17 checks passed
@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Apr 30, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 19baa470e58e04c5832ef7100e9f5de57d9a7704 --onto 0a6c31520b2ebaa6e71227454b46ebfb4986ae7b. You can force Mathlib CI using the force-mathlib-ci label. (2026-04-30 14:38:34)

@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 19baa470e58e04c5832ef7100e9f5de57d9a7704 --onto 3fc99eef102549c743c6c63547983319bfae6f01. You can force reference manual CI using the force-manual-ci label. (2026-04-30 14:38:36)

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

Labels

changelog-tactics User facing tactics toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants