From 59acd7798199dc4c411ca0b8e2661e60904441c8 Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 11 Dec 2021 13:01:08 -0800 Subject: [PATCH] n Signed-off-by: Nikolaj Bjorner --- src/math/dd/dd_pdd.cpp | 6 ++++++ src/math/polysat/explain.cpp | 2 ++ src/math/polysat/mul_ovfl_constraint.cpp | 8 ++------ src/math/polysat/ule_constraint.cpp | 2 +- src/test/polysat.cpp | 7 ++++++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/math/dd/dd_pdd.cpp b/src/math/dd/dd_pdd.cpp index 64e178e08..0fb848953 100644 --- a/src/math/dd/dd_pdd.cpp +++ b/src/math/dd/dd_pdd.cpp @@ -960,13 +960,19 @@ namespace dd { pdd r = zero(); a.factor(v, l, a1, a2); b.factor(v, m, b1, b2); + std::cout << "factor v*" << a1 << " ++ " << a2 << "\n"; + std::cout << "factor v*" << b1 << " ++ " << b2 << "\n"; quot_rem(a1, b1, q, r); + std::cout << "quot " << q << " rem " << r << "\n"; if (r.is_zero()) { SASSERT(q * b1 == a1); a1 = -q * pow(mk_var(v), l - m) * b2; if (l > m) a1 = reduce(v, a1, b); + } + else if (m_semantics == mod2N_e && r.is_val() && r.val().is_odd() && q.is_zero()) { + } else a1 = a1 * pow(mk_var(v), l); diff --git a/src/math/polysat/explain.cpp b/src/math/polysat/explain.cpp index 0c7cf94f5..a792a74ee 100644 --- a/src/math/polysat/explain.cpp +++ b/src/math/polysat/explain.cpp @@ -157,11 +157,13 @@ namespace polysat { auto rhs = c->to_ule().rhs(); auto a = lhs.reduce(v, p); auto b = rhs.reduce(v, p); + LOG("try-reduce: " << c << " " << a << " " << b << " vs " << lhs << " " << rhs); if (a == lhs && b == rhs) continue; auto c2 = s.ule(a, b); if (!c.is_positive()) c2 = ~c2; + LOG("try-reduce is false " << c2.is_currently_false(s)); if (!c2.is_currently_false(s)) continue; SASSERT(c2.is_currently_false(s)); diff --git a/src/math/polysat/mul_ovfl_constraint.cpp b/src/math/polysat/mul_ovfl_constraint.cpp index cb6321d5b..fe7c90b3d 100644 --- a/src/math/polysat/mul_ovfl_constraint.cpp +++ b/src/math/polysat/mul_ovfl_constraint.cpp @@ -100,11 +100,7 @@ namespace polysat { } /** - * if p constant, q, propagate inequality - * - * TODO optimizations: - * if p is constant, q variable, update viable for q - * + * if p constant, q, propagate inequality */ bool mul_ovfl_constraint::narrow_bound(solver& s, bool is_positive, pdd const& p0, pdd const& q0, pdd const& p, pdd const& q) { @@ -148,7 +144,7 @@ namespace polysat { } unsigned mul_ovfl_constraint::hash() const { - return mk_mix(p().hash(), q().hash(), 325); + return mk_mix(p().hash(), q().hash(), kind()); } bool mul_ovfl_constraint::operator==(constraint const& other) const { diff --git a/src/math/polysat/ule_constraint.cpp b/src/math/polysat/ule_constraint.cpp index 67e676c04..4581bb581 100644 --- a/src/math/polysat/ule_constraint.cpp +++ b/src/math/polysat/ule_constraint.cpp @@ -208,7 +208,7 @@ namespace polysat { } unsigned ule_constraint::hash() const { - return mk_mix(lhs().hash(), rhs().hash(), 23); + return mk_mix(lhs().hash(), rhs().hash(), kind()); } bool ule_constraint::operator==(constraint const& other) const { diff --git a/src/test/polysat.cpp b/src/test/polysat.cpp index 2bb1c124b..42f7e2c96 100644 --- a/src/test/polysat.cpp +++ b/src/test/polysat.cpp @@ -19,8 +19,12 @@ namespace polysat { public: scoped_solver(std::string name): solver(lim), m_name(name) { LOG("\n\n\n" << std::string(78, '#') << "\n\nSTART: " << m_name << "\n"); + set_max_conflicts(10); + } + + void set_max_conflicts(unsigned c) { params_ref p; - p.set_uint("max_conflicts", 10); + p.set_uint("max_conflicts", c); updt_params(p); } @@ -942,6 +946,7 @@ namespace polysat { static void test_quot_rem(unsigned bw = 32) { scoped_solver s(__func__); + s.set_max_conflicts(2); auto a = s.var(s.add_var(bw)); auto quot = s.var(s.add_var(bw)); auto rem = s.var(s.add_var(bw));