3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-03-16 12:24:22 -07:00
parent e7ec842cf5
commit f86205b0e8
3 changed files with 16 additions and 6 deletions

View file

@ -297,7 +297,7 @@ namespace smt {
m_coeffs.reset(); m_coeffs.reset();
} }
void farkas_util::add(rational const & coef, app * c) { bool farkas_util::add(rational const & coef, app * c) {
bool is_pos = true; bool is_pos = true;
expr* e; expr* e;
while (m.is_not(c, e)) { while (m.is_not(c, e)) {
@ -306,9 +306,15 @@ namespace smt {
} }
if (!coef.is_zero() && !m.is_true(c)) { if (!coef.is_zero() && !m.is_true(c)) {
m_coeffs.push_back(coef); if (m.is_eq(c) || a.is_le(c) || a.is_lt(c) || a.is_gt(c) || a.is_ge(c)) {
m_ineqs.push_back(fix_sign(is_pos, c)); m_coeffs.push_back(coef);
m_ineqs.push_back(fix_sign(is_pos, c));
}
else {
return false;
}
} }
return true;
} }
expr_ref farkas_util::get() { expr_ref farkas_util::get() {

View file

@ -67,8 +67,9 @@ namespace smt {
/** /**
\brief add a multiple of constraint c to the current state \brief add a multiple of constraint c to the current state
Fail if the constraint cannot be classified.
*/ */
void add(rational const & coef, app * c); bool add(rational const & coef, app * c);
/** /**
\brief Extract the complement of premises multiplied by Farkas coefficients. \brief Extract the complement of premises multiplied by Farkas coefficients.

View file

@ -1227,7 +1227,8 @@ namespace smt {
continue; continue;
} }
ctx.literal2expr(lits[i], tmp); ctx.literal2expr(lits[i], tmp);
farkas.add(abs(pa.get_rational()), to_app(tmp)); if (!farkas.add(abs(pa.get_rational()), to_app(tmp)))
return;
} }
for (unsigned i = 0; i < num_eqs; ++i) { for (unsigned i = 0; i < num_eqs; ++i) {
enode_pair const& p = eqs[i]; enode_pair const& p = eqs[i];
@ -1236,9 +1237,11 @@ namespace smt {
tmp = m.mk_eq(x,y); tmp = m.mk_eq(x,y);
parameter const& pa = params[1 + num_lits + i]; parameter const& pa = params[1 + num_lits + i];
SASSERT(pa.is_rational()); SASSERT(pa.is_rational());
farkas.add(abs(pa.get_rational()), to_app(tmp)); if (!farkas.add(abs(pa.get_rational()), to_app(tmp)))
return;
} }
tmp = farkas.get(); tmp = farkas.get();
if (m.has_trace_stream()) { if (m.has_trace_stream()) {
log_axiom_instantiation(tmp); log_axiom_instantiation(tmp);
m.trace_stream() << "[end-of-instance]\n"; m.trace_stream() << "[end-of-instance]\n";