refactor: move grind's arithmetic instance helpers into Sym.Arith - #15188
Merged
Merged
Conversation
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
enabled auto-merge
September 16, 2026 22:22
leodemoura
disabled auto-merge
September 16, 2026 22:29
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
leodemoura
enabled auto-merge
September 16, 2026 22:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR moves the
IsCharP,PowIdentity, andNoNatZeroDivisorsinstance helpers and the groundNat/Intevaluator used bygrind's arithmetic solvers intoSym.Arith, so thatgrindandSym.Arithshare one implementation. It also bringsSym.Arith.classify?up to date withgrind's ring detection: it now recordsPowIdentityinstances and uses the fast path for the envelope typeRing.OfSemiring.Qthat constructs and registers the ring instances instead of synthesizing them.The files
Grind/Arith/Insts.leanandGrind/Arith/EvalNum.leanare deleted. Their callers inRingId,StructId,SafePoly, and cutsat'sEqCnstrnow use theSymMversions, which lift intoGoalM. The exponent threshold consulted by these functions lives in theSym.Arithstate, soGrindM.runsets it fromGrind.Config.exp. The default of that state field is raised from 8 to 2^20 to matchGrind.Config.exp; with 8,classify?failed to evaluate2 ^ winIsCharP (BitVec w) (2 ^ w)and reported no characteristic forBitVec 64.🤖 Generated with Claude Code