mirror of
https://github.com/Z3Prover/z3
synced 2025-08-27 13:39:49 +00:00
updated conflict state
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
486cc632d0
commit
c48f14e537
8 changed files with 1085 additions and 1067 deletions
|
@ -51,6 +51,10 @@ namespace polysat {
|
|||
out << " vars";
|
||||
for (auto v : m_vars)
|
||||
out << " v" << v;
|
||||
if (!m_bail_vars.empty())
|
||||
out << " bail vars";
|
||||
for (auto v : m_bail_vars)
|
||||
out << " v" << v;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -60,6 +64,7 @@ namespace polysat {
|
|||
m_constraints.reset();
|
||||
m_literals.reset();
|
||||
m_vars.reset();
|
||||
m_bail_vars.reset();
|
||||
m_conflict_var = null_var;
|
||||
m_bailout = false;
|
||||
SASSERT(empty());
|
||||
|
@ -139,14 +144,26 @@ namespace polysat {
|
|||
m_constraints.push_back(c);
|
||||
}
|
||||
|
||||
void conflict::propagate(signed_constraint c) {
|
||||
cm().ensure_bvar(c.get());
|
||||
switch (c.bvalue(s)) {
|
||||
case l_undef:
|
||||
s.assign_eval(c.blit());
|
||||
break;
|
||||
case l_true:
|
||||
break;
|
||||
case l_false:
|
||||
break;
|
||||
}
|
||||
insert(c);
|
||||
}
|
||||
|
||||
void conflict::insert_vars(signed_constraint c) {
|
||||
for (pvar v : c->vars())
|
||||
if (s.is_assigned(v))
|
||||
m_vars.insert(v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Premises can either be justified by a Clause or by a value assignment.
|
||||
* Premises that are justified by value assignments are not assigned (the bvalue is l_undef)
|
||||
|
@ -232,10 +249,18 @@ namespace polysat {
|
|||
SASSERT(contains_literal(lit));
|
||||
SASSERT(!contains_literal(~lit));
|
||||
|
||||
remove_literal(lit);
|
||||
signed_constraint c = s.lit2cnstr(lit);
|
||||
unset_mark(c);
|
||||
insert_vars(c);
|
||||
bool has_decision = false;
|
||||
for (pvar v : c->vars())
|
||||
if (s.is_assigned(v) && s.m_justification[v].is_decision())
|
||||
m_bail_vars.insert(v), has_decision = true;
|
||||
|
||||
if (!has_decision) {
|
||||
remove(c);
|
||||
for (pvar v : c->vars())
|
||||
if (s.is_assigned(v))
|
||||
m_vars.insert(v);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,42 +338,24 @@ namespace polysat {
|
|||
bool conflict::resolve_value(pvar v) {
|
||||
// NOTE:
|
||||
// In the "standard" case where "v = val" is on the stack:
|
||||
// - core contains both false and true constraints
|
||||
// (originally only false ones, but additional true ones may come from saturation)
|
||||
|
||||
// forbidden interval projection is performed at top level
|
||||
SASSERT(v != conflict_var());
|
||||
|
||||
if (is_bailout()) {
|
||||
if (!s.m_justification[v].is_decision())
|
||||
m_vars.remove(v);
|
||||
return false;
|
||||
}
|
||||
SASSERT(v != conflict_var());
|
||||
|
||||
auto const& j = s.m_justification[v];
|
||||
|
||||
s.inc_activity(v);
|
||||
|
||||
#if 0
|
||||
if (j.is_decision() && m_vars.contains(v)) {
|
||||
set_bailout();
|
||||
if (j.is_decision() && m_bail_vars.contains(v))
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s.inc_activity(v);
|
||||
m_vars.remove(v);
|
||||
|
||||
if (j.is_propagation()) {
|
||||
for (auto const& c : s.m_viable.get_constraints(v)) {
|
||||
if (!c->has_bvar()) {
|
||||
// it is a side-condition that was not propagated already.
|
||||
// it is true in the current variable assignment.
|
||||
cm().ensure_bvar(c.get());
|
||||
s.assign_eval(c.blit());
|
||||
}
|
||||
insert(c);
|
||||
}
|
||||
}
|
||||
if (is_bailout())
|
||||
goto bailout;
|
||||
|
||||
if (j.is_propagation())
|
||||
for (auto const& c : s.m_viable.get_constraints(v))
|
||||
propagate(c);
|
||||
|
||||
LOG("try-explain v" << v);
|
||||
if (try_explain(v))
|
||||
|
@ -365,6 +372,7 @@ namespace polysat {
|
|||
}
|
||||
LOG("bailout v" << v);
|
||||
set_bailout();
|
||||
bailout:
|
||||
if (s.is_assigned(v) && j.is_decision())
|
||||
m_vars.insert(v);
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue