Skip to content

fix edge case in algebraic number comparison#9498

Open
ValentinPromies wants to merge 1 commit into
Z3Prover:masterfrom
ValentinPromies:algebraic-numbers-cmp
Open

fix edge case in algebraic number comparison#9498
ValentinPromies wants to merge 1 commit into
Z3Prover:masterfrom
ValentinPromies:algebraic-numbers-cmp

Conversation

@ValentinPromies
Copy link
Copy Markdown
Contributor

So far, algebraic_numbers compare_core handles an edge case incorrectly:

  • If the two compared numbers (a, b) are different,
  • the intervals still overlap after refinements, and
  • both a and b are a root of the second polynomial (cell_b->m_p), e.g. they are the first and second root

then the method would return sign_zero (i.e. "equal"). This behavior can be replicated with the provided test case (before the fix). This requires algebraic.factor=false, though i first encountered it during solver runs on QF_NRA instances with the default algebraic.factor=true, which apparently means that the polynomials for anums are still not always factored.

The fix is to compare the interval bounds of b to a and vice versa. Then the Sturm-Tarski check is only run if a and b both lie in the intersection of the intervals, because only then is it guaranteed to be correct.

@NikolajBjorner NikolajBjorner requested a review from levnach May 11, 2026 15:59
@NikolajBjorner
Copy link
Copy Markdown
Contributor

@levnach

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants