3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

enable reduce_by, more tests

This commit is contained in:
Nikolaj Bjorner 2021-09-19 13:41:39 -04:00
parent 58c66ffee8
commit c69c316b27
7 changed files with 142 additions and 36 deletions

View file

@ -534,16 +534,20 @@ namespace polysat {
// we prove quot3 <= a and quot3 + em >= a
s.push();
s.add_ult(a, quot3);
s.add_ult(quot3 + em, a);
s.check();
s.expect_unsat();
// s.expect_unsat();
s.pop();
s.push();
s.add_ult(quot3 + em, a);
s.add_ult(a, quot3);
s.check();
s.expect_unsat();
// s.expect_unsat();
s.pop();
//exit(0);
}
/** Monotonicity under bounds,
@ -718,6 +722,90 @@ namespace polysat {
s.expect_unsat();
}
// xy < xz and !Omega(x*y) => y < z
static void test_ineq_axiom1(unsigned bw = 32) {
auto const bound = rational::power_of_two(bw-1);
{
scoped_solver s(__func__);
auto x = s.var(s.add_var(bw));
auto y = s.var(s.add_var(bw));
auto z = s.var(s.add_var(bw));
s.add_ult(x * y, x * z);
s.add_ule(z, y);
s.add_ult(x, bound);
s.add_ult(y, bound);
s.check();
s.expect_unsat();
}
{
scoped_solver s(__func__);
auto y = s.var(s.add_var(bw));
auto x = s.var(s.add_var(bw));
auto z = s.var(s.add_var(bw));
s.add_ult(x * y, x * z);
s.add_ule(z, y);
s.add_ult(x, bound);
s.add_ult(y, bound);
s.check();
s.expect_unsat();
}
for (unsigned i = 0; i < 3; ++i) {
for (unsigned j = 0; j < 2; ++j) {
scoped_solver s(__func__);
auto a = s.var(s.add_var(bw));
auto b = s.var(s.add_var(bw));
auto c = s.var(s.add_var(bw));
auto x = a, y = b, z = c;
if (i == 1)
std::swap(x, y);
else if (i == 2)
std::swap(x, z);
if (j == 1)
std::swap(y, z);
s.add_ult(x * y, x * z);
s.add_ule(z, y);
s.add_ult(x, bound);
s.add_ult(y, bound);
s.check();
s.expect_unsat();
}
}
}
// xy <= xz & !Omega(x*y) => y <= z or x = 0
static void test_ineq_axiom2(unsigned bw = 32) {
auto const bound = rational::power_of_two(bw - 1);
for (unsigned i = 0; i < 3; ++i) {
for (unsigned j = 0; j < 2; ++j) {
scoped_solver s(__func__);
auto a = s.var(s.add_var(bw));
auto b = s.var(s.add_var(bw));
auto c = s.var(s.add_var(bw));
auto x = a, y = b, z = c;
if (i == 1)
std::swap(x, y);
else if (i == 2)
std::swap(x, z);
if (j == 1)
std::swap(y, z);
s.add_ult(x * y, x * z);
s.add_ult(z, y);
s.add_ult(x, bound);
s.add_ult(y, bound);
s.add_diseq(x);
s.check();
s.expect_unsat();
}
}
}
// xy < b & a <= x & !Omega(x*y) => a*y < b
// xy <= b & a <= x & !Omega(x*y) => a*y <= b
// a < xy & x <= b & !Omega(x*y) => a < b*y
// a <= xy & x <= b & !omega(x*y) => a <= b*y
// Goal: we probably mix up polysat variables and PDD variables at several points; try to uncover such cases
// NOTE: actually, add_var seems to keep them in sync, so this is not an issue at the moment (but we should still test it later)
@ -843,12 +931,9 @@ namespace polysat {
void tst_polysat() {
polysat::test_p3();
polysat::test_ineq_axiom1();
return;
polysat::test_l2();
// polysat::test_subst();
// return;
// not working
// polysat::test_fixed_point_arith_div_mul_inverse();
@ -864,12 +949,13 @@ 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();
polysat::test_p1();
polysat::test_p2();
polysat::test_p3();
polysat::test_ineq_basic1();
polysat::test_ineq_basic2();
@ -879,7 +965,7 @@ void tst_polysat() {
polysat::test_ineq_basic6();
polysat::test_monot_bounds(2);
polysat::test_cjust();
polysat::test_subst();
// inefficient conflicts:
// Takes time: polysat::test_monot_bounds_full();