mirror of
https://github.com/Z3Prover/z3
synced 2025-07-03 11:25:40 +00:00
some fixes
This commit is contained in:
parent
ff1185891a
commit
40d62af796
2 changed files with 20 additions and 10 deletions
|
@ -129,7 +129,7 @@ namespace polysat {
|
||||||
// (we still need the list though, for new/temporary constraints.)
|
// (we still need the list though, for new/temporary constraints.)
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (auto c : m_constraints)
|
for (auto c : m_constraints)
|
||||||
if (c->bvar() == var)
|
if (c->bvar() != var)
|
||||||
m_constraints[j++] = c;
|
m_constraints[j++] = c;
|
||||||
m_constraints.shrink(j);
|
m_constraints.shrink(j);
|
||||||
|
|
||||||
|
@ -189,7 +189,9 @@ namespace polysat {
|
||||||
}
|
}
|
||||||
|
|
||||||
clause_builder conflict_core::build_core_lemma(unsigned model_level) {
|
clause_builder conflict_core::build_core_lemma(unsigned model_level) {
|
||||||
LOG_H3("build lemma from core");
|
LOG_H3("Build lemma from core");
|
||||||
|
LOG("core: " << *this);
|
||||||
|
LOG("model_level: " << model_level);
|
||||||
clause_builder lemma(*m_solver);
|
clause_builder lemma(*m_solver);
|
||||||
|
|
||||||
// TODO: try a final core reduction step?
|
// TODO: try a final core reduction step?
|
||||||
|
@ -197,7 +199,7 @@ namespace polysat {
|
||||||
for (auto c : m_constraints) {
|
for (auto c : m_constraints) {
|
||||||
if (!c->has_bvar())
|
if (!c->has_bvar())
|
||||||
keep(c);
|
keep(c);
|
||||||
lemma.push(c);
|
lemma.push(~c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_needs_model) {
|
if (m_needs_model) {
|
||||||
|
@ -210,6 +212,8 @@ namespace polysat {
|
||||||
// Add v != val for each variable
|
// Add v != val for each variable
|
||||||
for (pvar v : vars) {
|
for (pvar v : vars) {
|
||||||
// SASSERT(!m_solver->m_justification[v].is_unassigned()); // TODO: why does this trigger????
|
// SASSERT(!m_solver->m_justification[v].is_unassigned()); // TODO: why does this trigger????
|
||||||
|
if (m_solver->m_justification[v].is_unassigned())
|
||||||
|
continue;
|
||||||
if (m_solver->m_justification[v].level() > model_level)
|
if (m_solver->m_justification[v].level() > model_level)
|
||||||
continue;
|
continue;
|
||||||
auto diseq = ~cm().eq(lemma.level(), m_solver->var(v) - m_solver->m_value[v]);
|
auto diseq = ~cm().eq(lemma.level(), m_solver->var(v) - m_solver->m_value[v]);
|
||||||
|
@ -225,7 +229,7 @@ namespace polysat {
|
||||||
if (is_bailout())
|
if (is_bailout())
|
||||||
return build_fallback_lemma(reverted_level);
|
return build_fallback_lemma(reverted_level);
|
||||||
else
|
else
|
||||||
return build_core_lemma(reverted_level - 1);
|
return build_core_lemma(reverted_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conflict_core::resolve_value(pvar v, vector<signed_constraint> const& cjust_v) {
|
bool conflict_core::resolve_value(pvar v, vector<signed_constraint> const& cjust_v) {
|
||||||
|
|
|
@ -590,7 +590,6 @@ namespace polysat {
|
||||||
LOG_H3("Guessing literal in lemma: " << lemma);
|
LOG_H3("Guessing literal in lemma: " << lemma);
|
||||||
IF_LOGGING(m_viable.log());
|
IF_LOGGING(m_viable.log());
|
||||||
LOG("Boolean assignment: " << m_bvars);
|
LOG("Boolean assignment: " << m_bvars);
|
||||||
SASSERT(lemma.size() >= 2);
|
|
||||||
|
|
||||||
// To make a guess, we need to find an unassigned literal that is not false in the current model.
|
// To make a guess, we need to find an unassigned literal that is not false in the current model.
|
||||||
auto is_suitable = [this](sat::literal lit) -> bool {
|
auto is_suitable = [this](sat::literal lit) -> bool {
|
||||||
|
@ -940,18 +939,25 @@ namespace polysat {
|
||||||
signed_constraints cs;
|
signed_constraints cs;
|
||||||
cs.append(m_original.size(), m_original.data());
|
cs.append(m_original.size(), m_original.data());
|
||||||
cs.append(m_redundant.size(), m_redundant.data());
|
cs.append(m_redundant.size(), m_redundant.data());
|
||||||
|
// Skip boolean literals that aren't active yet
|
||||||
|
uint_set skip;
|
||||||
|
for (unsigned i = m_qhead; i < m_search.size(); ++i)
|
||||||
|
if (m_search[i].is_boolean())
|
||||||
|
skip.insert(m_search[i].lit().to_uint());
|
||||||
for (auto c : cs) {
|
for (auto c : cs) {
|
||||||
|
SASSERT(c->has_bvar());
|
||||||
|
if (skip.contains(c.blit().to_uint()))
|
||||||
|
continue;
|
||||||
int64_t num_watches = 0;
|
int64_t num_watches = 0;
|
||||||
for (auto const& wlist : m_watch) {
|
for (auto const& wlist : m_watch) {
|
||||||
auto n = std::count(wlist.begin(), wlist.end(), c);
|
auto n = std::count(wlist.begin(), wlist.end(), c);
|
||||||
VERIFY(n <= 1); // no duplicates in the watchlist
|
VERIFY(n <= 1); // no duplicates in the watchlist
|
||||||
num_watches += n;
|
num_watches += n;
|
||||||
}
|
}
|
||||||
switch (c->vars().size()) {
|
unsigned expected_watches = std::min(2u, c->vars().size());
|
||||||
case 0: VERIFY(num_watches == 0); break;
|
if (num_watches != expected_watches)
|
||||||
case 1: VERIFY(num_watches == 1); break;
|
LOG("wrong number of watches: " << c);
|
||||||
default: VERIFY(num_watches == 2); break;
|
SASSERT_EQ(num_watches, expected_watches);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue