Skip to content

refactor: move grind's arithmetic instance helpers into Sym.Arith - #15188

Merged
leodemoura merged 2 commits into
masterfrom
sym_arith_return
Sep 16, 2026
Merged

leodemoura merged 2 commits into
masterfrom
sym_arith_return

Conversation

@leodemoura

Copy link
Copy Markdown
Member

This PR moves the IsCharP, PowIdentity, and NoNatZeroDivisors instance helpers and the ground Nat/Int evaluator used by grind's arithmetic solvers into Sym.Arith, so that grind and Sym.Arith share one implementation. It also brings Sym.Arith.classify? up to date with grind's ring detection: it now records PowIdentity instances and uses the fast path for the envelope type Ring.OfSemiring.Q that constructs and registers the ring instances instead of synthesizing them.

The files Grind/Arith/Insts.lean and Grind/Arith/EvalNum.lean are deleted. Their callers in RingId, StructId, SafePoly, and cutsat's EqCnstr now use the SymM versions, which lift into GoalM. The exponent threshold consulted by these functions lives in the Sym.Arith state, so GrindM.run sets it from Grind.Config.exp. The default of that state field is raised from 8 to 2^20 to match Grind.Config.exp; with 8, classify? failed to evaluate 2 ^ w in IsCharP (BitVec w) (2 ^ w) and reported no characteristic for BitVec 64.

🤖 Generated with Claude Code

This PR moves the `IsCharP`, `PowIdentity`, and `NoNatZeroDivisors` instance helpers and the ground `Nat`/`Int` evaluator used by `grind`'s arithmetic solvers into `Sym.Arith`, so that `grind` and `Sym.Arith` share one implementation. It also brings `Sym.Arith.classify?` up to date with `grind`'s ring detection: it now records `PowIdentity` instances and uses the fast path for the envelope type `Ring.OfSemiring.Q` that constructs and registers the ring instances instead of synthesizing them.

The files `Grind/Arith/Insts.lean` and `Grind/Arith/EvalNum.lean` are deleted. Their callers in `RingId`, `StructId`, `SafePoly`, and cutsat's `EqCnstr` now use the `SymM` versions, which lift into `GoalM`. The exponent threshold consulted by these functions lives in the `Sym.Arith` state, so `GrindM.run` sets it from `Grind.Config.exp`. The default of that state field is raised from 8 to 2^20 to match `Grind.Config.exp`; with 8, `classify?` failed to evaluate `2 ^ w` in `IsCharP (BitVec w) (2 ^ w)` and reported no characteristic for `BitVec 64`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@leodemoura leodemoura added the changelog-no Do not include this PR in the release changelog label Sep 16, 2026
@leodemoura
leodemoura disabled auto-merge September 16, 2026 22:29
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@leodemoura
leodemoura added this pull request to the merge queue Sep 16, 2026
@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 Sep 16, 2026
Merged via the queue into master with commit 566b215 Sep 16, 2026
17 checks passed
@leodemoura leodemoura added changelog-tactics User facing tactics changelog-no Do not include this PR in the release changelog and removed changelog-no Do not include this PR in the release changelog changelog-tactics User facing tactics labels Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-no Do not include this PR in the release changelog 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.

1 participant