mirror of
https://github.com/Z3Prover/z3
synced 2025-04-12 12:08:18 +00:00
fix semantics of check-int64 div operation to align with smtlib semantics
This commit is contained in:
parent
30d72f79ac
commit
ab43d2dcf1
|
@ -25,6 +25,7 @@ Author:
|
||||||
#include "ast/sls/sls_seq_plugin.h"
|
#include "ast/sls/sls_seq_plugin.h"
|
||||||
#include "ast/ast_ll_pp.h"
|
#include "ast/ast_ll_pp.h"
|
||||||
#include "ast/ast_pp.h"
|
#include "ast/ast_pp.h"
|
||||||
|
#include "ast/for_each_expr.h"
|
||||||
#include "smt/params/smt_params_helper.hpp"
|
#include "smt/params/smt_params_helper.hpp"
|
||||||
|
|
||||||
namespace sls {
|
namespace sls {
|
||||||
|
@ -208,6 +209,10 @@ namespace sls {
|
||||||
|
|
||||||
if (bad_model) {
|
if (bad_model) {
|
||||||
IF_VERBOSE(0, verbose_stream() << lit << " " << a->get_id() << " " << mk_bounded_pp(a, m) << " " << eval_a << "\n");
|
IF_VERBOSE(0, verbose_stream() << lit << " " << a->get_id() << " " << mk_bounded_pp(a, m) << " " << eval_a << "\n");
|
||||||
|
TRACE("sls", s.display(tout << lit << " " << a->get_id() << " " << mk_bounded_pp(a, m) << " " << eval_a << "\n");
|
||||||
|
for (expr* t : subterms::all(expr_ref(a, m)))
|
||||||
|
tout << "#" << t->get_id() << ": " << mk_bounded_pp(t, m) << " := " << ev(t) << "\n";
|
||||||
|
);
|
||||||
throw default_exception("failed to create a well-formed model");
|
throw default_exception("failed to create a well-formed model");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,6 +300,16 @@ template<bool CHECK>
|
||||||
inline checked_int64<CHECK> div(checked_int64<CHECK> const& a, checked_int64<CHECK> const& b) {
|
inline checked_int64<CHECK> div(checked_int64<CHECK> const& a, checked_int64<CHECK> const& b) {
|
||||||
checked_int64<CHECK> result(a);
|
checked_int64<CHECK> result(a);
|
||||||
result /= b;
|
result /= b;
|
||||||
|
if (a < 0) {
|
||||||
|
checked_int64<CHECK> r(a);
|
||||||
|
r %= b;
|
||||||
|
if (r != 0) {
|
||||||
|
if (b < 0)
|
||||||
|
result += 1;
|
||||||
|
else
|
||||||
|
result -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue