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

fix bug in conflict::is_valid exposed by testing unit propagation

This commit is contained in:
Nikolaj Bjorner 2023-04-02 14:54:20 -07:00
parent dcc87a682c
commit ae57475483
3 changed files with 34 additions and 9 deletions

View file

@ -211,8 +211,8 @@ namespace polysat {
bool conflict::is_valid() const {
SASSERT(!empty());
// If m_dep is set, the corresponding constraint was asserted at m_level and is not valid earlier.
if (!m_dep.is_null())
return m_level <= s.m_level;
if (!m_dep.is_null() && m_level >= s.m_level)
return false;
// All conflict constraints must be bool-assigned.
for (unsigned lit_idx : m_literals)
if (!s.m_bvars.is_assigned(sat::to_literal(lit_idx)))

View file

@ -95,10 +95,33 @@ namespace polysat {
}
lbool solver::unit_propagate() {
#if 1
return l_undef;
// disabled to allow debugging unsoundness for watched literals
#elif 1
unsigned level = m_level;
SASSERT(!m_is_solving);
backjump(base_level());
if (!is_conflict())
propagate();
VERIFY(level == m_level);
if (is_conflict()) {
++m_stats.m_num_conflicts;
return l_false;
}
return l_undef;
#else
flet<uint64_t> _max_d(m_config.m_max_conflicts, m_stats.m_num_conflicts + 2);
return check_sat();
unsigned level = m_level;
lbool r = check_sat();
if (r != l_false) {
backjump(level);
m_conflict.reset();
}
SASSERT(level == m_level);
return r;
#endif
}
dd::pdd_manager& solver::sz2pdd(unsigned sz) const {

View file

@ -271,6 +271,8 @@ namespace bv {
core.push_back(sat::to_literal(n.val() / 2));
else {
auto [v1, v2] = m_var_eqs[n.val() / 2];
VERIFY(var2enode(v1)->get_root() == var2enode(v2)->get_root());
VERIFY(n.val() <= 2 * m_var_eqs_head);
eqs.push_back(euf::enode_pair(var2enode(v1), var2enode(v2)));
}
}