mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 11:37:54 +00:00
Polysat: fixes in solver, forbidden intervals for eq_constraint (#5240)
* Rename to neg_cond * Add some logging utilities * Implement case of forbidden interval covering the whole domain * Implement diseq_narrow * Do not activate constraint if we are in a conflict state * comments * Assert that lemma isn't undefined * Update revert_decision to work in the case where narrowing causes propagation * Fix case of non-disjunctive lemma from forbidden intervals * Conflict should not leak outside user scope * Add guard to decide(), some notes * Add test case * Add constraints to watchlist of unassigned variable during propagation * Move common propagation functionality into base class * Combine eq/diseq narrow * Compute forbidden interval for equality constraints by considering them as p <=u 0 (or p >u 0 for disequalities)
This commit is contained in:
parent
04876ba8b7
commit
f7e476a4a0
15 changed files with 350 additions and 130 deletions
|
@ -63,6 +63,21 @@ namespace polysat {
|
|||
s.check();
|
||||
}
|
||||
|
||||
/// Has constraints which must be inserted into other watchlist to discover UNSAT
|
||||
static void test_wlist() {
|
||||
scoped_solver s;
|
||||
auto a = s.var(s.add_var(3));
|
||||
auto b = s.var(s.add_var(3));
|
||||
auto c = s.var(s.add_var(3));
|
||||
auto d = s.var(s.add_var(3));
|
||||
s.add_eq(d + c + b + a + 1);
|
||||
s.add_eq(d + c + b + a);
|
||||
s.add_eq(d + c + b);
|
||||
s.add_eq(d + c);
|
||||
s.add_eq(d);
|
||||
s.check();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* most basic linear equation solving.
|
||||
|
@ -143,6 +158,23 @@ namespace polysat {
|
|||
s.check();
|
||||
}
|
||||
|
||||
/**
|
||||
* unsat
|
||||
* - learns 3*x + 1 == 0 by polynomial resolution
|
||||
* - this forces x == 5, which means the first constraint is unsatisfiable by parity.
|
||||
*/
|
||||
static void test_p3() {
|
||||
scoped_solver s;
|
||||
auto x = s.var(s.add_var(4));
|
||||
auto y = s.var(s.add_var(4));
|
||||
auto z = s.var(s.add_var(4));
|
||||
s.add_eq(x*x*y + 3*y + 7);
|
||||
s.add_eq(2*y + z + 8);
|
||||
s.add_eq(3*x + 4*y*z + 2*z*z + 1);
|
||||
s.check();
|
||||
}
|
||||
|
||||
|
||||
// Unique solution: u = 5
|
||||
static void test_ineq_basic1() {
|
||||
scoped_solver s;
|
||||
|
@ -376,15 +408,23 @@ namespace polysat {
|
|||
|
||||
void tst_polysat() {
|
||||
polysat::test_add_conflicts();
|
||||
polysat::test_wlist();
|
||||
polysat::test_l1();
|
||||
polysat::test_l2();
|
||||
polysat::test_l3();
|
||||
polysat::test_l4();
|
||||
polysat::test_l5();
|
||||
#if 0
|
||||
// worry about this later
|
||||
polysat::test_p1();
|
||||
polysat::test_p2();
|
||||
polysat::test_p3();
|
||||
polysat::test_ineq_basic1();
|
||||
polysat::test_ineq_basic2();
|
||||
polysat::test_ineq_basic3();
|
||||
polysat::test_ineq_basic4();
|
||||
polysat::test_ineq_basic5();
|
||||
polysat::test_ineq_basic6();
|
||||
#if 0
|
||||
// worry about this later
|
||||
polysat::test_ineq1();
|
||||
polysat::test_ineq2();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue