mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
create a conflict explanation
Signed-off-by: Lev Nachmanson <levnach@hotmail.com>
This commit is contained in:
parent
52653e6e43
commit
59e2dab69a
|
@ -211,7 +211,7 @@ namespace lp {
|
||||||
init();
|
init();
|
||||||
while(m_f.size()) {
|
while(m_f.size()) {
|
||||||
if (!normalize_by_gcd())
|
if (!normalize_by_gcd())
|
||||||
return lia_move::unsat;
|
return lia_move::conflict;
|
||||||
rewrite_eqs();
|
rewrite_eqs();
|
||||||
}
|
}
|
||||||
return lia_move::sat;
|
return lia_move::sat;
|
||||||
|
@ -298,11 +298,12 @@ namespace lp {
|
||||||
remove_fresh_variables(m_eprime[p.j()].m_e);
|
remove_fresh_variables(m_eprime[p.j()].m_e);
|
||||||
}
|
}
|
||||||
u_dependency* dep = nullptr;
|
u_dependency* dep = nullptr;
|
||||||
for (const auto & p : ep.m_l) {
|
for (const auto & pl : ep.m_l)
|
||||||
if (lra.column_is_fixed(p.j())) {
|
for (const auto & p : m_eprime[pl.j()].m_e)
|
||||||
lra.explain_fixed_column(p.j(), ex);
|
if (lra.column_is_fixed(p.j()))
|
||||||
}
|
lra.explain_fixed_column(p.j(), ex);
|
||||||
}
|
|
||||||
|
TRACE("dioph_eq", lra.print_expl(tout, ex););
|
||||||
}
|
}
|
||||||
void remove_fresh_variables(term_o& t) {
|
void remove_fresh_variables(term_o& t) {
|
||||||
// TODO implement
|
// TODO implement
|
||||||
|
|
|
@ -17,6 +17,7 @@ Revision History:
|
||||||
--*/
|
--*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "math/lp/lia_move.h"
|
#include "math/lp/lia_move.h"
|
||||||
|
#include "math/lp/explanation.h"
|
||||||
|
|
||||||
namespace lp {
|
namespace lp {
|
||||||
|
|
||||||
|
|
|
@ -168,8 +168,9 @@ namespace lp {
|
||||||
dioph_eq de(lia);
|
dioph_eq de(lia);
|
||||||
lia_move r = de.check();
|
lia_move r = de.check();
|
||||||
|
|
||||||
if (r == lia_move::unsat) {
|
if (r == lia_move::conflict) {
|
||||||
de.explain(*this->m_ex);
|
de.explain(*this->m_ex);
|
||||||
|
return lia_move::conflict;
|
||||||
} else if (r == lia_move::sat) {
|
} else if (r == lia_move::sat) {
|
||||||
NOT_IMPLEMENTED_YET();
|
NOT_IMPLEMENTED_YET();
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,6 +591,14 @@ public:
|
||||||
}
|
}
|
||||||
return dep;
|
return dep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::ostream& print_expl(std::ostream& out, const explanation& exp) const {
|
||||||
|
for (auto p : exp)
|
||||||
|
constraints().display(
|
||||||
|
out, [this](lpvar j) { return get_variable_name(j); }, p.ci());
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
void explain_fixed_column(unsigned j, explanation& ex);
|
void explain_fixed_column(unsigned j, explanation& ex);
|
||||||
u_dependency* join_deps(u_dependency* a, u_dependency *b) { return m_dependencies.mk_join(a, b); }
|
u_dependency* join_deps(u_dependency* a, u_dependency *b) { return m_dependencies.mk_join(a, b); }
|
||||||
inline constraint_set const& constraints() const { return m_constraints; }
|
inline constraint_set const& constraints() const { return m_constraints; }
|
||||||
|
|
|
@ -213,20 +213,13 @@ public:
|
||||||
m_visited_rows.reset();
|
m_visited_rows.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& print_expl(std::ostream& out, const explanation& exp) const {
|
|
||||||
for (auto p : exp)
|
|
||||||
lp().constraints().display(
|
|
||||||
out, [this](lpvar j) { return lp().get_variable_name(j); }, p.ci());
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool add_eq_on_columns(const explanation& exp, lpvar je, lpvar ke, bool is_fixed) {
|
bool add_eq_on_columns(const explanation& exp, lpvar je, lpvar ke, bool is_fixed) {
|
||||||
lp_assert(je != ke && is_int(je) == is_int(ke));
|
lp_assert(je != ke && is_int(je) == is_int(ke));
|
||||||
lp_assert(ival(je) == ival(ke));
|
lp_assert(ival(je) == ival(ke));
|
||||||
|
|
||||||
TRACE("eq",
|
TRACE("eq",
|
||||||
tout << "reported idx " << je << ", " << ke << "\n";
|
tout << "reported idx " << je << ", " << ke << "\n";
|
||||||
print_expl(tout, exp);
|
lp().print_expl(tout, exp);
|
||||||
tout << "theory_vars v" << lp().local_to_external(je) << " == v" << lp().local_to_external(ke) << "\n";);
|
tout << "theory_vars v" << lp().local_to_external(je) << " == v" << lp().local_to_external(ke) << "\n";);
|
||||||
|
|
||||||
bool added = m_imp.add_eq(je, ke, exp, is_fixed);
|
bool added = m_imp.add_eq(je, ke, exp, is_fixed);
|
||||||
|
@ -257,7 +250,7 @@ public:
|
||||||
TRACE("eq", tout << lp().get_row(row) << std::endl);
|
TRACE("eq", tout << lp().get_row(row) << std::endl);
|
||||||
for (const auto& c : lp().get_row(row))
|
for (const auto& c : lp().get_row(row))
|
||||||
if (lp().column_is_fixed(c.var()))
|
if (lp().column_is_fixed(c.var()))
|
||||||
explain_fixed_column(c.var(), ex);
|
lp().explain_fixed_column(c.var(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned explain_fixed_in_row_and_get_base(unsigned row, explanation& ex) {
|
unsigned explain_fixed_in_row_and_get_base(unsigned row, explanation& ex) {
|
||||||
|
@ -265,7 +258,7 @@ public:
|
||||||
TRACE("eq", tout << lp().get_row(row) << std::endl);
|
TRACE("eq", tout << lp().get_row(row) << std::endl);
|
||||||
for (const auto& c : lp().get_row(row)) {
|
for (const auto& c : lp().get_row(row)) {
|
||||||
if (lp().column_is_fixed(c.var())) {
|
if (lp().column_is_fixed(c.var())) {
|
||||||
explain_fixed_column(c.var(), ex);
|
lp().explain_fixed_column(c.var(), ex);
|
||||||
}
|
}
|
||||||
else if (lp().is_base(c.var())) {
|
else if (lp().is_base(c.var())) {
|
||||||
base = c.var();
|
base = c.var();
|
||||||
|
@ -357,7 +350,7 @@ public:
|
||||||
);
|
);
|
||||||
explanation ex;
|
explanation ex;
|
||||||
explain_fixed_in_row(row_index, ex);
|
explain_fixed_in_row(row_index, ex);
|
||||||
explain_fixed_column(j, ex);
|
lp().explain_fixed_column(j, ex);
|
||||||
add_eq_on_columns(ex, j, v_j, true);
|
add_eq_on_columns(ex, j, v_j, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue