Repository navigation
Keep the roots sorted in the Zp feasible set of a constraint - #121
Open
ahmed-irfan wants to merge 1 commit into
Open
ahmed-irfan wants to merge 1 commit into
ahmed-irfan wants to merge 1 commit into
Conversation
lp_polynomial_constraint_get_feasible_set_Zp wrote the roots from lp_upolynomial_roots_find_Zp directly into the set. For a field of size 1000 or more, the Rabin root finder returns the roots in no fixed order. lp_feasibility_set_int_find uses binary search, so contains() and pick_value() could accept a value that the constraint excludes. Yices then gave a wrong sat answer (SRI-CSL/yices2#700). Build the set with lp_feasibility_set_int_new_from_integer, which normalizes, sorts and removes duplicates.
This was referenced Nov 28, 2026
Open
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.
Fixes the cause of SRI-CSL/yices2#700 (wrong
saton a small QF_FFA instance with field size 1019).What changed
lp_polynomial_constraint_get_feasible_set_Zp(src/polynomial/polynomial.c) wrote the roots fromlp_upolynomial_roots_find_Zpdirectly intoresult->elements. It did not sort them.feasibility_set_int.hsays that the elements are "kept sorted and unique", andlp_feasibility_set_int_finduses binary search.For a field of size less than 1000, the brute-force root finder returns the roots in ascending order. For a field of size 1000 or more, the Rabin root finder returns them in no fixed order. In the yices2 issue, the set for
-y^3 + y^2 - 2ymod 1019 with!= 0held[0, -216, 217]. Thuscontains(0)was false andpick_valuereturned 0, which the constraint excludes.The function now collects the roots in a local array and builds the set with
lp_feasibility_set_int_new_from_integer. That constructor normalizes, sorts and removes duplicates. Then the function destructs and frees the array. The degree-0 branches do not change.Tests
New test case
feasibility_set_int::constraint_Zp_rootsintest/poly/test_feasible_int_set.cpp, over Z/1019:-y^3 + y^2 - 2ywith!= 0and= 0: the elements are strictly ascending,containsis correct for each root, andpick_valuedoes not return a root.y^2 + 1(no roots): the= 0set is empty and the!= 0set is full.Verification
contains,pick_value). With the fix, it passes.make check: 329 pass, 0 fail.containsagainst direct evaluation for each field element, on 603 polynomials over fields from 13 to 7919. With the fix: 0 failures and no sanitizer report. Without the fix: 117 failures.unsaton the issue input for fields 997, 1009, 1019, 1031 and 7919. Before the fix, it answeredsatfor 1019 and 7919.The review also found two pre-existing leaks outside this change.
lp_feasibility_set_int_destructfrees the element array but does not destruct the elements. The degree-0 returns in this function do not deleteupoly. They are filed as #122.🤖 Generated with Claude Code