3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-08 04:01:22 +00:00

use assert instead of explicit check

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-04-28 08:48:24 -07:00
parent efbb382646
commit 60972de562
3 changed files with 7 additions and 12 deletions

View file

@ -62,6 +62,7 @@ namespace polysat {
void assign_eh(bool is_true) { m_status = (is_true ^ !m_sign) ? l_true : l_false; } void assign_eh(bool is_true) { m_status = (is_true ^ !m_sign) ? l_true : l_false; }
bool is_positive() const { return m_status == l_true; } bool is_positive() const { return m_status == l_true; }
bool is_negative() const { return m_status == l_false; } bool is_negative() const { return m_status == l_false; }
bool is_undef() const { return m_status == l_undef; }
}; };
inline std::ostream& operator<<(std::ostream& out, constraint const& c) { return c.display(out); } inline std::ostream& operator<<(std::ostream& out, constraint const& c) { return c.display(out); }

View file

@ -128,10 +128,7 @@ namespace polysat {
if (delta == 0) if (delta == 0)
return; return;
m_vars[v].m_value += delta; m_vars[v].m_value += delta;
if (is_base(v)) { SASSERT(!is_base(v));
add_patch(v);
return;
}
// //
// v <- v + delta // v <- v + delta
@ -144,9 +141,8 @@ namespace polysat {
row r = c.get_row(); row r = c.get_row();
row_info& ri = m_rows[r.id()]; row_info& ri = m_rows[r.id()];
var_t s = ri.m_base; var_t s = ri.m_base;
var_info& si = m_vars[s];
ri.m_value += delta * c.get_row_entry().m_coeff; ri.m_value += delta * c.get_row_entry().m_coeff;
si.m_value = 0 - (ri.m_value / ri.m_base_coeff); m_vars[s].m_value = 0 - (ri.m_value / ri.m_base_coeff);
add_patch(s); add_patch(s);
} }
} }

View file

@ -109,12 +109,11 @@ namespace polysat {
bool ule_constraint::is_always_false(pdd const& lhs, pdd const& rhs) { bool ule_constraint::is_always_false(pdd const& lhs, pdd const& rhs) {
// TODO: other conditions (e.g. when forbidden interval would be full) // TODO: other conditions (e.g. when forbidden interval would be full)
VERIFY(!is_undef());
if (is_positive()) if (is_positive())
return lhs.is_val() && rhs.is_val() && !(lhs.val() <= rhs.val()); return lhs.is_val() && rhs.is_val() && !(lhs.val() <= rhs.val());
if (is_negative()) else
return lhs.is_val() && rhs.is_val() && !(lhs.val() > rhs.val()); return lhs.is_val() && rhs.is_val() && !(lhs.val() > rhs.val());
UNREACHABLE();
return false;
} }
bool ule_constraint::is_always_false() { bool ule_constraint::is_always_false() {
@ -130,12 +129,11 @@ namespace polysat {
bool ule_constraint::is_currently_true(solver& s) { bool ule_constraint::is_currently_true(solver& s) {
auto p = lhs().subst_val(s.m_search); auto p = lhs().subst_val(s.m_search);
auto q = rhs().subst_val(s.m_search); auto q = rhs().subst_val(s.m_search);
VERIFY(!is_undef());
if (is_positive()) if (is_positive())
return p.is_val() && q.is_val() && p.val() <= q.val(); return p.is_val() && q.is_val() && p.val() <= q.val();
if (is_negative()) else
return p.is_val() && q.is_val() && p.val() > q.val(); return p.is_val() && q.is_val() && p.val() > q.val();
UNREACHABLE();
return false;
} }
} }