From e08e124790a0c4304599ef7b65eaceadcff11fd2 Mon Sep 17 00:00:00 2001 From: Jakob Rath Date: Wed, 28 Sep 2022 10:57:40 +0200 Subject: [PATCH] Expand always-false check --- src/math/polysat/solver.cpp | 1 + src/math/polysat/ule_constraint.cpp | 13 +++++++++---- src/math/polysat/ule_constraint.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/math/polysat/solver.cpp b/src/math/polysat/solver.cpp index b975d83d7..85ccd7f26 100644 --- a/src/math/polysat/solver.cpp +++ b/src/math/polysat/solver.cpp @@ -196,6 +196,7 @@ namespace polysat { break; case l_undef: if (c.is_always_false()) { + LOG("Always false: " << c); // asserted an always-false constraint set_conflict_at_base_level(); return; diff --git a/src/math/polysat/ule_constraint.cpp b/src/math/polysat/ule_constraint.cpp index 389ff5ca1..d12af572b 100644 --- a/src/math/polysat/ule_constraint.cpp +++ b/src/math/polysat/ule_constraint.cpp @@ -134,17 +134,22 @@ namespace polysat { s.m_viable.intersect(p, q, sc); } - bool ule_constraint::is_always_false(bool is_positive, pdd const& lhs, pdd const& rhs) const { - // TODO: other conditions (e.g. when forbidden interval would be full) + bool ule_constraint::is_always_false(bool is_positive, pdd const& lhs, pdd const& rhs) { if (is_positive) { + // lhs <= rhs if (rhs.is_zero()) - return lhs.is_never_zero(); + return lhs.is_never_zero(); // p <= 0 implies p == 0 return lhs.is_val() && rhs.is_val() && lhs.val() > rhs.val(); } else { + // lhs > rhs if (lhs.is_zero()) return true; // 0 > ... is always false - return (lhs.is_val() && rhs.is_val() && lhs.val() <= rhs.val()) || (lhs == rhs); + if (lhs == rhs) + return true; // p > p + if (lhs.is_one() && rhs.is_never_zero()) + return true; // 1 > p implies p == 0 + return lhs.is_val() && rhs.is_val() && lhs.val() <= rhs.val(); } } diff --git a/src/math/polysat/ule_constraint.h b/src/math/polysat/ule_constraint.h index 990c468a6..87d74859d 100644 --- a/src/math/polysat/ule_constraint.h +++ b/src/math/polysat/ule_constraint.h @@ -34,7 +34,7 @@ namespace polysat { pdd const& rhs() const { return m_rhs; } std::ostream& display(std::ostream& out, lbool status) const override; std::ostream& display(std::ostream& out) const override; - bool is_always_false(bool is_positive, pdd const& lhs, pdd const& rhs) const; + static bool is_always_false(bool is_positive, pdd const& lhs, pdd const& rhs); bool is_always_false(bool is_positive) const override; bool is_currently_false(solver& s, bool is_positive) const override; bool is_currently_true(solver& s, bool is_positive) const override;