3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-13 12:28:44 +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();
}
void farkas_util::add(rational const & coef, app * c) {
bool farkas_util::add(rational const & coef, app * c) {
bool is_pos = true;
expr* e;
while (m.is_not(c, e)) {
@ -306,9 +306,15 @@ namespace smt {
}
if (!coef.is_zero() && !m.is_true(c)) {
m_coeffs.push_back(coef);
m_ineqs.push_back(fix_sign(is_pos, c));
if (m.is_eq(c) || a.is_le(c) || a.is_lt(c) || a.is_gt(c) || a.is_ge(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() {

View file

@ -67,8 +67,9 @@ namespace smt {
/**
\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.

View file

@ -1227,7 +1227,8 @@ namespace smt {
continue;
}
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) {
enode_pair const& p = eqs[i];
@ -1236,9 +1237,11 @@ namespace smt {
tmp = m.mk_eq(x,y);
parameter const& pa = params[1 + num_lits + i];
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();
if (m.has_trace_stream()) {
log_axiom_instantiation(tmp);
m.trace_stream() << "[end-of-instance]\n";