3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-22 16:45:31 +00:00

improve diagnostics

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2024-01-04 11:07:09 -08:00
parent 7b0c04a3e8
commit 5fc208cefc
4 changed files with 22 additions and 4 deletions

View file

@ -658,7 +658,6 @@ namespace polysat {
auto eq0 = eq_internalize(e, bv.mk_numeral(0, sz_e));
auto gelo = mk_literal(bv.mk_ule(bv.mk_numeral(rational::power_of_two(lo), sz_x), x));
auto name = "extract";
verbose_stream() << "extract axiom " << mk_pp(e, m) << " " << eq0 << " " << s().value(eq0) << " " << gelo << " " << s().value(gelo) << "\n";
add_axiom(name, { eq0, gelo });
if (hi + 1 == sz_e)
add_axiom(name, { ~eq0, ~gelo });

View file

@ -114,4 +114,11 @@ namespace polysat {
auto r = m_intblast.check_axiom(clause);
VERIFY (r != l_true);
}
std::ostream& solver::display_clause(char const* name, std::ostream& out, sat::literal_vector const& lits) const {
out << name << ":\n";
for (auto lit : lits)
out << ctx.literal2expr(lit) << "\n";
return out;
}
}

View file

@ -345,8 +345,8 @@ namespace polysat {
TRACE("bv", tout << "literal is true " << ctx.literal2expr(lit) << "\n");
return false;
}
TRACE("bv", tout << name << ": "; for (auto lit : lits) tout << ctx.literal2expr(lit) << " "; tout << "\n");
IF_VERBOSE(1, verbose_stream() << name << ": "; for (auto lit : lits) verbose_stream() << ctx.literal2expr(lit) << " "; verbose_stream() << "\n");
TRACE("bv", display_clause(name, tout, lits));
IF_VERBOSE(1, display_clause(name, verbose_stream(), lits));
validate_axiom(lits);
s().add_clause(lits.size(), lits.data(), sat::status::th(is_redundant, get_id(), hint));
return true;
@ -368,7 +368,17 @@ namespace polysat {
lits.push_back(lit);
}
validate_axiom(lits);
IF_VERBOSE(1, verbose_stream() << name << ": "; for (auto lit : lits) verbose_stream() << ctx.literal2expr(lit) << " "; verbose_stream() << "\n");
unsigned j = 0;
for (auto lit : lits) {
if (s().value(lit) == l_true && s().lvl(lit) == 0)
return;
if (s().value(lit) == l_false && s().lvl(lit) == 0)
continue;
lits[j++] = lit;
}
lits.shrink(j);
IF_VERBOSE(1, display_clause(name, verbose_stream(), lits));
s().add_clause(lits.size(), lits.data(), sat::status::th(is_redundant, get_id(), hint));
}

View file

@ -230,6 +230,8 @@ namespace polysat {
void validate_conflict(sat::literal_vector const& core, euf::enode_pair_vector const& eqs);
void validate_axiom(sat::literal_vector const& clause);
std::ostream& display_clause(char const * name, std::ostream& out, sat::literal_vector const& lits) const;
void explain_dep(dependency const& d, euf::enode_pair_vector& eqs, sat::literal_vector& lits);
std::pair<sat::literal_vector, euf::enode_pair_vector> explain_deps(dependency_vector const& deps);