3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-25 10:05:32 +00:00

remove propagate_bool_at, it is technically not propagating but assigning

This commit is contained in:
Nikolaj Bjorner 2021-09-19 08:47:14 -04:00
parent 16d48c17dd
commit 58c66ffee8
4 changed files with 43 additions and 49 deletions

View file

@ -212,7 +212,7 @@ namespace polysat {
if (lemma->size() == 1)
c->set_unit_clause(lemma.get());
if (s().m_bvars.value(c.blit()) == l_undef)
s().propagate_bool_at(s().level(*lemma), c.blit(), lemma.get());
s().assign_bool(s().level(*lemma), c.blit(), lemma.get(), nullptr);
}
clause_builder conflict_core::build_core_lemma() {

View file

@ -124,7 +124,7 @@ namespace polysat {
if (first)
s.set_conflict(cl);
else
s.propagate_bool_at(s.level(cl), cl[0], &cl);
s.assign_bool(s.level(cl), cl[0], &cl, nullptr);
}
void constraint_manager::unwatch(clause& cl) {

View file

@ -155,7 +155,7 @@ namespace polysat {
else if (c.is_always_false())
m_conflict.set(c);
else
propagate_bool_at(m_level, c.blit(), c->unit_clause());
assign_bool(m_level, c.blit(), c->unit_clause(), nullptr);
}
bool solver::can_propagate() {
@ -178,38 +178,6 @@ namespace polysat {
SASSERT(assignment_invariant());
}
bool solver::propagate(sat::literal lit, clause& cl) {
SASSERT(cl.size() >= 2);
unsigned idx = cl[0] == ~lit ? 1 : 0;
SASSERT(cl[1 - idx] == ~lit);
if (m_bvars.is_true(cl[idx]))
return true;
unsigned i = 2;
for (; i < cl.size() && m_bvars.is_false(cl[i]); ++i);
if (i < cl.size()) {
m_bvars.watch(cl[i]).push_back(&cl);
std::swap(cl[1 - idx], cl[i]);
return false;
}
if (m_bvars.is_false(cl[idx]))
set_conflict(cl);
else
assign_bool(level(cl), cl[idx], &cl, nullptr);
return true;
}
void solver::linear_propagate() {
#if ENABLE_LINEAR_SOLVER
switch (m_linear_solver.check()) {
case l_false:
// TODO extract conflict
break;
default:
break;
}
#endif
}
/**
* Propagate assignment to a Boolean variable
*/
@ -243,6 +211,38 @@ namespace polysat {
wlist.shrink(j);
}
bool solver::propagate(sat::literal lit, clause& cl) {
SASSERT(cl.size() >= 2);
unsigned idx = cl[0] == ~lit ? 1 : 0;
SASSERT(cl[1 - idx] == ~lit);
if (m_bvars.is_true(cl[idx]))
return true;
unsigned i = 2;
for (; i < cl.size() && m_bvars.is_false(cl[i]); ++i);
if (i < cl.size()) {
m_bvars.watch(cl[i]).push_back(&cl);
std::swap(cl[1 - idx], cl[i]);
return false;
}
if (m_bvars.is_false(cl[idx]))
set_conflict(cl);
else
assign_bool(level(cl), cl[idx], &cl, nullptr);
return true;
}
void solver::linear_propagate() {
#if ENABLE_LINEAR_SOLVER
switch (m_linear_solver.check()) {
case l_false:
// TODO extract conflict
break;
default:
break;
}
#endif
}
void solver::propagate(pvar v, rational const& val, signed_constraint c) {
LOG("Propagation: " << assignment_pp(*this, v, val) << ", due to " << c);
if (m_viable.is_viable(v, val)) {
@ -587,7 +587,7 @@ namespace polysat {
push_cjust(lemma.justified_var(), c);
if (num_choices == 1)
propagate_bool_at(level(lemma), choice, &lemma);
assign_bool(level(lemma), choice, &lemma, nullptr);
else
decide_bool(choice, &lemma);
}
@ -682,18 +682,9 @@ namespace polysat {
SASSERT(!can_propagate());
SASSERT(!is_conflict());
push_level();
LOG_H2("Decide boolean literal " << lit << " @ " << m_level);
assign_bool(m_level, lit, nullptr, lemma);
}
void solver::propagate_bool_at(unsigned level, sat::literal lit, clause* reason) {
LOG("Propagate boolean literal " << lit << " @ " << level << " by " << show_deref(reason));
SASSERT(reason);
SASSERT(level <= m_level);
assign_bool(level, lit, reason, nullptr);
}
unsigned solver::level(clause const& cl) {
unsigned lvl = 0;
for (auto lit : cl) {
@ -707,7 +698,11 @@ namespace polysat {
/// Assign a boolean literal and put it on the search stack
void solver::assign_bool(unsigned level, sat::literal lit, clause* reason, clause* lemma) {
SASSERT(!m_bvars.is_true(lit));
LOG("Assigning boolean literal: " << lit);
if (reason)
LOG("Propagate literal " << lit << " @ " << level << " by " << *reason);
else
LOG("Decide literal " << lit << " @ " << m_level);
m_bvars.assign(lit, level, reason, lemma);
m_trail.push_back(trail_instr_t::assign_bool_i);
m_search.push_boolean(lit);

View file

@ -153,7 +153,6 @@ namespace polysat {
void deactivate_constraint(signed_constraint c);
void decide_bool(clause& lemma);
void decide_bool(sat::literal lit, clause* lemma);
void propagate_bool_at(unsigned level, sat::literal lit, clause* reason);
unsigned level(clause const& cl);
void assign_core(pvar v, rational const& val, justification const& j);