mirror of
https://github.com/Z3Prover/z3
synced 2026-02-28 02:41:27 +00:00
fix bugs exposed by Nuno's PB example
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9e916edcb0
commit
29c2672407
2 changed files with 24 additions and 9 deletions
|
|
@ -166,10 +166,11 @@ namespace sat {
|
|||
unsigned w = 0;
|
||||
for (unsigned i = 0; i < m_size; ++i) {
|
||||
m_wlits[i].second.neg();
|
||||
VERIFY(w + m_wlits[i].first >= w);
|
||||
w += m_wlits[i].first;
|
||||
}
|
||||
}
|
||||
m_k = w - m_k + 1;
|
||||
SASSERT(w >= m_k && m_k > 0);
|
||||
VERIFY(w >= m_k && m_k > 0);
|
||||
}
|
||||
|
||||
bool ba_solver::pb::is_watching(literal l) const {
|
||||
|
|
@ -526,11 +527,13 @@ namespace sat {
|
|||
bool ba_solver::init_watch(pb& p) {
|
||||
clear_watch(p);
|
||||
if (p.lit() != null_literal && value(p.lit()) == l_false) {
|
||||
//IF_VERBOSE(0, verbose_stream() << "negate: " << p.k() << "\n");
|
||||
p.negate();
|
||||
}
|
||||
|
||||
VERIFY(p.lit() == null_literal || value(p.lit()) == l_true);
|
||||
unsigned sz = p.size(), bound = p.k();
|
||||
//IF_VERBOSE(0, verbose_stream() << "bound: " << p.k() << "\n");
|
||||
|
||||
// put the non-false literals into the head.
|
||||
unsigned slack = 0, slack1 = 0, num_watch = 0, j = 0;
|
||||
|
|
@ -833,9 +836,19 @@ namespace sat {
|
|||
remove_constraint(p, "recompiled to cardinality");
|
||||
return;
|
||||
}
|
||||
|
||||
else {
|
||||
p.set_size(sz);
|
||||
p.update_max_sum();
|
||||
if (p.max_sum() < k) {
|
||||
if (p.lit() == null_literal) {
|
||||
s().set_conflict(justification());
|
||||
}
|
||||
else {
|
||||
s().assign(~p.lit(), justification());
|
||||
}
|
||||
remove_constraint(p, "recompiled to false");
|
||||
return;
|
||||
}
|
||||
p.set_k(k);
|
||||
SASSERT(p.well_formed());
|
||||
|
||||
|
|
@ -3210,6 +3223,7 @@ namespace sat {
|
|||
if (is_marked(l) && m_weights[l.index()] <= p2.get_coeff(i)) {
|
||||
++num_sub;
|
||||
}
|
||||
if (p1.size() + i > p2.size() + num_sub) return false;
|
||||
}
|
||||
return num_sub == p1.size();
|
||||
}
|
||||
|
|
@ -3364,8 +3378,9 @@ namespace sat {
|
|||
m_weights.setx(l.second.index(), l.first, 0);
|
||||
mark_visited(l.second);
|
||||
}
|
||||
for (unsigned i = 0; i < p1.num_watch(); ++i) {
|
||||
subsumes(p1, p1[i].second);
|
||||
for (unsigned i = 0; i < std::min(10u, p1.num_watch()); ++i) {
|
||||
unsigned j = s().m_rand() % p1.num_watch();
|
||||
subsumes(p1, p1[j].second);
|
||||
}
|
||||
for (wliteral l : p1) {
|
||||
m_weights[l.second.index()] = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue