mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
Polysat updates (#5444)
* Simplify adding lemmas * Remove misleading constructor from tmp_assign. The idea is that tmp_assign is only created on the stack and short-lived. Instead of having a convenience constructor that takes a constraint_ref, it's clearer to have an explicit .get() at the call site. * Remove some log messages * bugfix * fix * Add stub for conflict_core * wip * Add example by Clemens
This commit is contained in:
parent
2ef8ee25f1
commit
8a773d2bee
12 changed files with 302 additions and 116 deletions
|
@ -43,6 +43,7 @@ namespace polysat {
|
|||
|
||||
public:
|
||||
scoped_solver(std::string name): solver(lim), m_name(name) {
|
||||
std::cout << "\n\n\n" << std::string(78, '#') << "\n";
|
||||
std::cout << "\nSTART: " << m_name << "\n";
|
||||
}
|
||||
|
||||
|
@ -355,7 +356,7 @@ namespace polysat {
|
|||
* We do overflow checks by doubling the base bitwidth here.
|
||||
*/
|
||||
static void test_monot(unsigned base_bw = 5) {
|
||||
scoped_solver s(__func__);
|
||||
scoped_solver s(std::string{__func__} + "(" + std::to_string(base_bw) + ")");
|
||||
|
||||
auto max_int_const = rational::power_of_two(base_bw) - 1;
|
||||
|
||||
|
@ -589,7 +590,7 @@ namespace polysat {
|
|||
* y*z >= 2^32
|
||||
*/
|
||||
static void test_monot_bounds(unsigned base_bw = 32) {
|
||||
scoped_solver s(__func__);
|
||||
scoped_solver s(std::string{__func__} + "(" + std::to_string(base_bw) + ")");
|
||||
unsigned bw = 2 * base_bw;
|
||||
auto y = s.var(s.add_var(bw));
|
||||
auto z = s.var(s.add_var(bw));
|
||||
|
@ -709,6 +710,41 @@ namespace polysat {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* x*x <= z
|
||||
* (x+1)*(x+1) <= z
|
||||
* y == x+1
|
||||
* ¬(y*y <= z)
|
||||
*
|
||||
* The original version had signed comparisons but that doesn't matter for the UNSAT result.
|
||||
* UNSAT can be seen easily by substituting the equality.
|
||||
*/
|
||||
static void test_subst(unsigned bw = 32) {
|
||||
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_ule(x * x, z); // optional
|
||||
s.add_ule((x + 1) * (x + 1), z);
|
||||
s.add_eq(x + 1 - y);
|
||||
s.add_ult(z, y*y);
|
||||
s.check();
|
||||
s.expect_unsat();
|
||||
}
|
||||
|
||||
static void test_subst_signed(unsigned bw = 32) {
|
||||
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_sle(x * x, z); // optional
|
||||
s.add_sle((x + 1) * (x + 1), z);
|
||||
s.add_eq(x + 1 - y);
|
||||
s.add_slt(z, y*y);
|
||||
s.check();
|
||||
s.expect_unsat();
|
||||
}
|
||||
|
||||
|
||||
// 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)
|
||||
|
@ -833,8 +869,9 @@ namespace polysat {
|
|||
|
||||
|
||||
void tst_polysat() {
|
||||
polysat::test_subst();
|
||||
// polysat::test_monot_bounds(8);
|
||||
polysat::test_monot_bounds_simple(8);
|
||||
// polysat::test_monot_bounds_simple(8);
|
||||
return;
|
||||
|
||||
polysat::test_add_conflicts();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue