3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-07 07:45:46 +00:00

update var dependency tracking

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-09-15 09:10:36 +01:00
parent 4b3af1d0a4
commit 3c8c8f5d40
4 changed files with 33 additions and 30 deletions

View file

@ -78,12 +78,8 @@ namespace polysat {
void conflict_core::set(signed_constraint c) {
LOG("Conflict: " << c);
SASSERT(empty());
insert(c);
for (auto v : c->vars()) {
if (s().is_assigned(v))
m_vars.insert(v);
// inc_pref(v); // hack to be able to test the rest of the conflict resolution loop, TODO: proper fix
}
c->set_var_dependent();
insert(c);
SASSERT(!empty());
}
@ -100,10 +96,8 @@ namespace polysat {
SASSERT(empty());
m_conflict_var = v;
for (auto c : s().m_cjust[v]) {
c->set_var_dependent();
insert(c);
for (auto v : c->vars())
if (s().is_assigned(v))
m_vars.insert(v);
}
SASSERT(!empty());
}
@ -305,15 +299,16 @@ namespace polysat {
void conflict_core::set_mark(signed_constraint c) {
if (c->is_marked())
return;
bool bool_propagated = c->has_bvar() && c.bvalue(s()) == l_true;
c->set_mark();
if (c->has_bvar())
set_bmark(c->bvar());
if (bool_propagated)
c->set_bool_propagated();
else
for (auto v : c->vars())
if (c->is_var_dependent()) {
for (auto v : c->vars()) {
if (s().is_assigned(v))
m_vars.insert(v);
inc_pref(v);
}
}
}
void conflict_core::unset_mark(signed_constraint c) {
@ -322,11 +317,11 @@ namespace polysat {
c->unset_mark();
if (c->has_bvar())
unset_bmark(c->bvar());
if (c->is_bool_propagated())
c->unset_bool_propagated();
else
if (c->is_var_dependent()) {
c->unset_var_dependent();
for (auto v : c->vars())
dec_pref(v);
}
}
void conflict_core::inc_pref(pvar v) {

View file

@ -138,7 +138,7 @@ namespace polysat {
unsigned_vector m_vars;
lbool m_external_sign = l_undef;
bool m_is_marked = false;
bool m_is_bool_propagated = false;
bool m_is_var_dependent = false;
/** The boolean variable associated to this constraint, if any.
* If this is not null_bool_var, then the constraint corresponds to a literal on the assignment stack.
* Convention: the plain constraint corresponds the positive sat::literal.
@ -193,9 +193,9 @@ namespace polysat {
void unset_mark() { m_is_marked = false; }
bool is_marked() const { return m_is_marked; }
void set_bool_propagated() { m_is_bool_propagated = true; }
void unset_bool_propagated() { m_is_bool_propagated = false; }
bool is_bool_propagated() { return m_is_bool_propagated; }
void set_var_dependent() { m_is_var_dependent = true; }
void unset_var_dependent() { m_is_var_dependent = false; }
bool is_var_dependent() { return m_is_var_dependent; }
};
inline std::ostream& operator<<(std::ostream& out, constraint const& c) { return c.display(out); }

View file

@ -497,6 +497,8 @@ namespace polysat {
resolve_bool(lit);
}
}
// here we build conflict clause if it has free variables.
// the last decision is reverted.
report_unsat();
}