3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 20:18:18 +00:00

fix #2416 exposed bugs: unsat-core extraction in combination with chronological backracking, equivalence elimination in combination with PB constraints

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-07-25 18:55:44 -07:00
parent 8a0d79251e
commit 53aded3198
4 changed files with 14 additions and 19 deletions

View file

@ -2085,7 +2085,6 @@ namespace sat {
\brief return true to keep watching literal. \brief return true to keep watching literal.
*/ */
bool ba_solver::propagate(literal l, ext_constraint_idx idx) { bool ba_solver::propagate(literal l, ext_constraint_idx idx) {
TRACE("ba", tout << l << "\n";);
SASSERT(value(l) == l_true); SASSERT(value(l) == l_true);
constraint& c = index2constraint(idx); constraint& c = index2constraint(idx);
if (c.lit() != null_literal && l.var() == c.lit().var()) { if (c.lit() != null_literal && l.var() == c.lit().var()) {
@ -2813,7 +2812,7 @@ namespace sat {
// literal is assigned to false. // literal is assigned to false.
unsigned sz = c.size(); unsigned sz = c.size();
unsigned bound = c.k(); unsigned bound = c.k();
TRACE("ba", tout << "assign: " << c.lit() << ": " << ~alit << "@" << lvl(~alit) << "\n";); TRACE("ba", tout << "assign: " << c.lit() << ": " << ~alit << "@" << lvl(~alit) << " " << c << "\n";);
SASSERT(0 < bound && bound <= sz); SASSERT(0 < bound && bound <= sz);
if (bound == sz) { if (bound == sz) {
@ -3242,7 +3241,6 @@ namespace sat {
// pre-condition is that the literals, except c.lit(), in c are unwatched. // pre-condition is that the literals, except c.lit(), in c are unwatched.
if (c.id() == _bad_id) std::cout << "recompile: " << c << "\n"; if (c.id() == _bad_id) std::cout << "recompile: " << c << "\n";
// IF_VERBOSE(0, verbose_stream() << c << "\n";);
m_weights.resize(2*s().num_vars(), 0); m_weights.resize(2*s().num_vars(), 0);
for (literal l : c) { for (literal l : c) {
++m_weights[l.index()]; ++m_weights[l.index()];

View file

@ -230,7 +230,8 @@ namespace sat {
literal l(v, false); literal l(v, false);
literal r = roots[v]; literal r = roots[v];
SASSERT(v != r.var()); SASSERT(v != r.var());
bool root_ok = !m_solver.is_external(v) || m_solver.set_root(l, r); bool set_root = m_solver.set_root(l, r);
bool root_ok = !m_solver.is_external(v) || set_root;
if (m_solver.is_assumption(v) || (m_solver.is_external(v) && (m_solver.is_incremental() || !root_ok))) { if (m_solver.is_assumption(v) || (m_solver.is_external(v) && (m_solver.is_incremental() || !root_ok))) {
// cannot really eliminate v, since we have to notify extension of future assignments // cannot really eliminate v, since we have to notify extension of future assignments
m_solver.mk_bin_clause(~l, r, false); m_solver.mk_bin_clause(~l, r, false);

View file

@ -301,8 +301,10 @@ namespace sat {
clause* solver::mk_clause(unsigned num_lits, literal * lits, bool learned) { clause* solver::mk_clause(unsigned num_lits, literal * lits, bool learned) {
m_model_is_current = false; m_model_is_current = false;
DEBUG_CODE({ DEBUG_CODE({
for (unsigned i = 0; i < num_lits; i++) for (unsigned i = 0; i < num_lits; i++) {
SASSERT(m_eliminated[lits[i].var()] == false); CTRACE("sat", m_eliminated[lits[i].var()], tout << lits[i] << " was eliminated\n";);
SASSERT(m_eliminated[lits[i].var()] == false);
}
}); });
if (m_user_scope_literals.empty()) { if (m_user_scope_literals.empty()) {
@ -2908,26 +2910,20 @@ namespace sat {
justification js = m_conflict; justification js = m_conflict;
int init_sz = init_trail_size();
while (true) { while (true) {
process_consequent_for_unsat_core(consequent, js); process_consequent_for_unsat_core(consequent, js);
while (idx >= 0) { while (idx >= init_sz) {
literal l = m_trail[idx]; consequent = m_trail[idx];
if (is_marked(l.var())) if (is_marked(consequent.var()) && lvl(consequent) == m_conflict_lvl)
break; break;
idx--; idx--;
} }
if (idx < init_sz) {
if (idx < 0) {
break; break;
} }
consequent = m_trail[idx];
if (lvl(consequent) < m_conflict_lvl) {
TRACE("sat", tout << consequent << " at level " << lvl(consequent) << "\n";);
break;
}
bool_var c_var = consequent.var();
SASSERT(lvl(consequent) == m_conflict_lvl); SASSERT(lvl(consequent) == m_conflict_lvl);
js = m_justification[c_var]; js = m_justification[consequent.var()];
idx--; idx--;
} }
reset_unmark(old_size); reset_unmark(old_size);