3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

fix bugs exposed in #677. to_int(x) has the semantics that to_int(x) <= x, and to_int(x) is the largest integer satisfying this inequality. The encoding in purify_arith had it the other way x <= to_int(x) contrary to how to_int(x) is handled elsewhere. Another bug in theory_arith for mixed-integer linear case was also exposed. Fractional bounds on expressions of the form to_int(x), and more generally on integer rows were not rounded prior to internalization

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-07-13 20:32:18 -07:00
parent 63f89f8c45
commit 3989d238c0
8 changed files with 78 additions and 40 deletions

View file

@ -25,6 +25,7 @@ Notes:
#include"ast_smt2_pp.h"
#include"z3_exception.h"
#include"algebraic_numbers.h"
#include"ast_pp.h"
class nlsat_tactic : public tactic {
struct expr_display_var_proc : public nlsat::display_var_proc {
@ -78,9 +79,21 @@ class nlsat_tactic : public tactic {
}
return false;
}
bool eval_model(model& model, goal& g) {
unsigned sz = g.size();
for (unsigned i = 0; i < sz; i++) {
expr_ref val(m);
if (model.eval(g.form(i), val) && !m.is_true(val)) {
TRACE("nlsat", tout << mk_pp(g.form(i), m) << " -> " << val << "\n";);
return false;
}
}
return true;
}
// Return false if nlsat assigned noninteger value to an integer variable.
bool mk_model(expr_ref_vector & b2a, expr_ref_vector & x2t, model_converter_ref & mc) {
bool mk_model(goal & g, expr_ref_vector & b2a, expr_ref_vector & x2t, model_converter_ref & mc) {
bool ok = true;
model_ref md = alloc(model, m);
arith_util util(m);
@ -110,6 +123,7 @@ class nlsat_tactic : public tactic {
continue; // don't care
md->register_decl(to_app(a)->get_decl(), val == l_true ? m.mk_true() : m.mk_false());
}
DEBUG_CODE(eval_model(*md.get(), g););
mc = model2model_converter(md.get());
return ok;
}
@ -151,7 +165,7 @@ class nlsat_tactic : public tactic {
if (!contains_unsupported(b2a, x2t)) {
// If mk_model is false it means that the model produced by nlsat
// assigns noninteger values to integer variables
if (mk_model(b2a, x2t, mc)) {
if (mk_model(*g.get(), b2a, x2t, mc)) {
// result goal is trivially SAT
g->reset();
}