mirror of
https://github.com/Z3Prover/z3
synced 2025-08-26 13:06:05 +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:
parent
63f89f8c45
commit
3989d238c0
8 changed files with 78 additions and 40 deletions
|
@ -1235,6 +1235,14 @@ namespace smt {
|
|||
ctx.set_var_theory(bv, get_id());
|
||||
rational _k;
|
||||
VERIFY(m_util.is_numeral(rhs, _k));
|
||||
if (is_int(v) && !_k.is_int()) {
|
||||
if (kind == A_UPPER) {
|
||||
_k = floor(_k);
|
||||
}
|
||||
else {
|
||||
_k = ceil(_k);
|
||||
}
|
||||
}
|
||||
inf_numeral k(_k);
|
||||
atom * a = alloc(atom, bv, v, k, kind);
|
||||
mk_bound_axioms(a);
|
||||
|
@ -1399,22 +1407,22 @@ namespace smt {
|
|||
final_check_status result = FC_DONE;
|
||||
final_check_status ok;
|
||||
do {
|
||||
TRACE("final_check_arith", tout << "m_final_check_idx: " << m_final_check_idx << ", result: " << result << "\n";);
|
||||
TRACE("arith", tout << "m_final_check_idx: " << m_final_check_idx << ", result: " << result << "\n";);
|
||||
switch (m_final_check_idx) {
|
||||
case 0:
|
||||
ok = check_int_feasibility();
|
||||
TRACE("final_check_arith", tout << "check_int_feasibility(), ok: " << ok << "\n";);
|
||||
TRACE("arith", tout << "check_int_feasibility(), ok: " << ok << "\n";);
|
||||
break;
|
||||
case 1:
|
||||
if (assume_eqs_core())
|
||||
ok = FC_CONTINUE;
|
||||
else
|
||||
ok = FC_DONE;
|
||||
TRACE("final_check_arith", tout << "assume_eqs(), ok: " << ok << "\n";);
|
||||
TRACE("arith", tout << "assume_eqs(), ok: " << ok << "\n";);
|
||||
break;
|
||||
default:
|
||||
ok = process_non_linear();
|
||||
TRACE("final_check_arith", tout << "non_linear(), ok: " << ok << "\n";);
|
||||
TRACE("arith", tout << "non_linear(), ok: " << ok << "\n";);
|
||||
break;
|
||||
}
|
||||
m_final_check_idx = (m_final_check_idx + 1) % 3;
|
||||
|
@ -1425,7 +1433,7 @@ namespace smt {
|
|||
result = FC_GIVEUP;
|
||||
break;
|
||||
case FC_CONTINUE:
|
||||
TRACE("final_check_arith",
|
||||
TRACE("arith",
|
||||
tout << "continue arith..."
|
||||
<< (get_context().inconsistent()?"inconsistent\n":"\n"););
|
||||
return FC_CONTINUE;
|
||||
|
@ -1442,7 +1450,7 @@ namespace smt {
|
|||
template<typename Ext>
|
||||
final_check_status theory_arith<Ext>::final_check_eh() {
|
||||
TRACE("arith_eq_adapter_info", m_arith_eq_adapter.display_already_processed(tout););
|
||||
TRACE("arith_final_check", display(tout););
|
||||
TRACE("arith", display(tout););
|
||||
|
||||
if (!propagate_core())
|
||||
return FC_CONTINUE;
|
||||
|
@ -1459,7 +1467,7 @@ namespace smt {
|
|||
m_liberal_final_check = false;
|
||||
m_changed_assignment = false;
|
||||
result = final_check_core();
|
||||
TRACE("final_check_arith", tout << "result: " << result << "\n";);
|
||||
TRACE("arith", tout << "result: " << result << "\n";);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2416,6 +2424,7 @@ namespace smt {
|
|||
theory_var v = b->get_var();
|
||||
inf_numeral const & k = b->get_value();
|
||||
|
||||
TRACE("arith", display_bound(tout, b); tout << "v" << v << " <= " << k << "\n";);
|
||||
bound * u = upper(v);
|
||||
bound * l = lower(v);
|
||||
|
||||
|
@ -2456,7 +2465,7 @@ namespace smt {
|
|||
|
||||
template<typename Ext>
|
||||
bool theory_arith<Ext>::assert_bound(bound * b) {
|
||||
TRACE("assert_bound", display_bound(tout, b););
|
||||
TRACE("assert_bound", display_bound(tout, b); display(tout););
|
||||
theory_var v = b->get_var();
|
||||
|
||||
if (b->is_atom()) {
|
||||
|
@ -2478,7 +2487,7 @@ namespace smt {
|
|||
break;
|
||||
}
|
||||
|
||||
TRACE("arith_assert", tout << "result: " << result << "\n"; display(tout););
|
||||
TRACE("arith_bound", tout << "result: " << result << "\n"; display(tout););
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -1267,11 +1267,11 @@ namespace smt {
|
|||
final_check_status theory_arith<Ext>::check_int_feasibility() {
|
||||
TRACE("arith_int_detail", get_context().display(tout););
|
||||
if (!has_infeasible_int_var()) {
|
||||
TRACE("arith_int_incomp", tout << "FC_DONE 1...\n"; display(tout););
|
||||
TRACE("arith", tout << "FC_DONE 1...\n"; display(tout););
|
||||
return FC_DONE;
|
||||
}
|
||||
|
||||
TRACE("arith_int_fracs",
|
||||
TRACE("arith",
|
||||
int num = get_num_vars();
|
||||
for (theory_var v = 0; v < num; v++) {
|
||||
if (is_int(v) && !get_value(v).is_int()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue