3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-08 18:31:49 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2013-12-09 19:58:34 -08:00
commit 26bf64a0c3
2 changed files with 42 additions and 4 deletions

View file

@ -653,6 +653,7 @@ namespace smt {
lits.push_back(c.lit());
for (unsigned i = 0; i < c.size(); ++i) {
if (ctx.get_assignment(c.lit(i)) == l_undef) {
SASSERT(validate_assign(c, lits, c.lit(i)));
add_assign(c, lits, c.lit(i));
}
}
@ -701,12 +702,12 @@ namespace smt {
else {
del_watch(watch, watch_index, c, w);
removed = true;
if (c.max_sum() - coeff < k + c.max_coeff()) {
if (c.max_sum() < k + c.max_coeff()) {
//
// opportunities for unit propagation for unassigned
// literals whose coefficients satisfy
// c.max_sum() - coeff < k
// c.max_sum() < k
//
// L: 3*x1 + 2*x2 + x4 >= 3, but x1 <- 0
// Create clauses x1 or ~L or x2
@ -717,6 +718,7 @@ namespace smt {
lits.push_back(c.lit());
for (unsigned i = 0; i < c.size(); ++i) {
if (c.max_sum() - c.coeff(i) < k && ctx.get_assignment(c.lit(i)) == l_undef) {
SASSERT(validate_assign(c, lits, c.lit(i)));
add_assign(c, lits, c.lit(i));
}
}
@ -985,7 +987,7 @@ namespace smt {
}
}
std::ostream& theory_pb::display(std::ostream& out, ineq& c, bool values) const {
std::ostream& theory_pb::display(std::ostream& out, ineq const& c, bool values) const {
ast_manager& m = get_manager();
context& ctx = get_context();
out << c.lit();
@ -1058,6 +1060,7 @@ namespace smt {
tout << "=> " << l << "\n";
display(tout, c, true););
ctx.assign(l, ctx.mk_justification(
pb_justification(
c, get_id(), ctx.get_region(), lits.size(), lits.c_ptr(), l)));
@ -1084,6 +1087,35 @@ namespace smt {
verbose_stream() << "\n";);
}
bool theory_pb::validate_assign(ineq const& c, literal_vector const& lits, literal l) const {
uint_set nlits;
context& ctx = get_context();
for (unsigned i = 0; i < lits.size(); ++i) {
SASSERT(ctx.get_assignment(lits[i]) == l_false);
nlits.insert((~lits[i]).index());
}
SASSERT(ctx.get_assignment(l) == l_undef);
SASSERT(ctx.get_assignment(c.lit()) == l_true);
nlits.insert(l.index());
numeral sum = numeral::zero();
for (unsigned i = 0; i < c.size(); ++i) {
literal lit = c.lit(i);
if (!nlits.contains(lit.index())) {
sum += c.coeff(i);
}
}
if (sum >= c.k()) {
IF_VERBOSE(0,
display(verbose_stream(), c, true);
for (unsigned i = 0; i < lits.size(); ++i) {
verbose_stream() << lits[i] << " ";
}
verbose_stream() << " => " << l << "\n";);
}
SASSERT(sum < c.k());
return true;
}
void theory_pb::set_mark(bool_var v, unsigned idx) {
SASSERT(v != null_bool_var);
if (v >= static_cast<bool_var>(m_conseq_index.size())) {
@ -1212,6 +1244,11 @@ namespace smt {
while (m_num_marks > 0) {
m_lemma.normalize();
lbool is_sat = m_lemma.normalize();
if (is_sat != l_undef) {
IF_VERBOSE(0, display(verbose_stream() << "created non-tautology lemma: ", m_lemma, true););
return false;
}
TRACE("pb", display(tout, m_lemma, true););
SASSERT(m_lemma.well_formed());

View file

@ -116,7 +116,7 @@ namespace smt {
bool assign_watch(bool_var v, bool is_true, watch_list& watch, unsigned index);
void assign_ineq(ineq& c, bool is_true);
std::ostream& display(std::ostream& out, ineq& c, bool values = false) const;
std::ostream& display(std::ostream& out, ineq const& c, bool values = false) const;
virtual void display(std::ostream& out) const;
void add_clause(ineq& c, literal_vector const& lits);
@ -157,6 +157,7 @@ namespace smt {
void validate_final_check();
void validate_final_check(ineq& c);
bool validate_assign(ineq const& c, literal_vector const& lits, literal l) const;
public:
theory_pb(ast_manager& m);