Recognize rational roots in closest-root isolation#10132
Merged
Conversation
…aic.isolate_rational_roots Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…gnition is always on Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
In the closest-root isolation path (
isolate_kth_root, used by the nlsat levelwise solver viaisolate_roots_closest), detect when the unique root in an isolating interval is a rational number and return it as a basic rational numeral instead of constructing analgebraic_cell.Why
Unlike the general
isolate_roots(), the closest-root path does not factor the polynomial, so a reducible polynomial keeps its rational roots hidden inside algebraic cells. Such a cell is never converted to a rational later: interval refinement bisects at dyadic midpoints and can never land on a non-dyadic rational root. Every subsequent equality-flavored operation then pays the expensive machinery — sign evaluation at a sample point where the polynomial vanishes falls through to the resultant-based computation, and comparing two cells hiding the same rational ends in a Sturm-Tarski sequence on every comparison, with nothing cached.Recognizing the rational at isolation time makes all downstream interactions exact and cheap. The detection uses the rational root theorem: refine the isolating interval to width < 1/|a_n| (the
refineloop is adaptive and stops early if the interval is already tight), which leaves at most one candidate m/|a_n| in the interval, then confirm with a single exact sign evaluation.Benchmarks
A/B runs on SMT-LIB QF_NRA (12,154 benchmarks), same commit and machine, differing only in the check being enabled (via a temporary parameter used for the experiment and removed from the final PR):
At T=60 the change solves 9 instances the baseline times out on and loses 5, net +5 solved; aggregate runtime is unchanged within noise (-0.17%). No errors, no model validation failures in either configuration.
🤖 Generated with Claude Code