mirror of
https://github.com/Z3Prover/z3
synced 2025-04-15 13:28:47 +00:00
fix bug in simplifier of bv2int over concatentations exposed by #948
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e342b87921
commit
25d839ed10
|
@ -1517,13 +1517,24 @@ void bv_simplifier_plugin::mk_bv2int(expr * arg, sort* range, expr_ref & result)
|
||||||
result = m_arith.mk_add(tmp1, tmp2);
|
result = m_arith.mk_add(tmp1, tmp2);
|
||||||
}
|
}
|
||||||
// commented out to reproduce bug in reduction of int2bv/bv2int
|
// commented out to reproduce bug in reduction of int2bv/bv2int
|
||||||
else if (m_util.is_concat(arg)) {
|
else if (m_util.is_concat(arg) && to_app(arg)->get_num_args() > 0) {
|
||||||
expr_ref tmp1(m_manager), tmp2(m_manager);
|
expr_ref_vector args(m_manager);
|
||||||
unsigned sz2 = get_bv_size(to_app(arg)->get_arg(1));
|
unsigned num_args = to_app(arg)->get_num_args();
|
||||||
mk_bv2int(to_app(arg)->get_arg(0), range, tmp1);
|
for (unsigned i = 0; i < num_args; ++i) {
|
||||||
mk_bv2int(to_app(arg)->get_arg(1), range, tmp2);
|
expr_ref tmp(m_manager);
|
||||||
tmp1 = m_arith.mk_mul(m_arith.mk_numeral(power(numeral(2), sz2), true), tmp1);
|
mk_bv2int(to_app(arg)->get_arg(i), range, tmp);
|
||||||
result = m_arith.mk_add(tmp1, tmp2);
|
args.push_back(tmp);
|
||||||
|
}
|
||||||
|
unsigned sz = get_bv_size(to_app(arg)->get_arg(num_args-1));
|
||||||
|
for (unsigned i = num_args - 1; i > 0; ) {
|
||||||
|
expr_ref tmp(m_manager);
|
||||||
|
--i;
|
||||||
|
tmp = args[i].get();
|
||||||
|
tmp = m_arith.mk_mul(m_arith.mk_numeral(power(numeral(2), sz), true), tmp);
|
||||||
|
args[i] = tmp;
|
||||||
|
sz += get_bv_size(to_app(arg)->get_arg(i));
|
||||||
|
}
|
||||||
|
result = m_arith.mk_add(args.size(), args.c_ptr());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parameter parameter(range);
|
parameter parameter(range);
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace smt {
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
void theory_arith<Ext>::found_underspecified_op(app * n) {
|
void theory_arith<Ext>::found_underspecified_op(app * n) {
|
||||||
if (!m_found_underspecified_op) {
|
if (!m_found_underspecified_op) {
|
||||||
TRACE("arith", tout << "found non underspecificed expression:\n" << mk_pp(n, get_manager()) << "\n";);
|
TRACE("arith", tout << "found underspecificed expression:\n" << mk_pp(n, get_manager()) << "\n";);
|
||||||
get_context().push_trail(value_trail<context, bool>(m_found_underspecified_op));
|
get_context().push_trail(value_trail<context, bool>(m_found_underspecified_op));
|
||||||
m_found_underspecified_op = true;
|
m_found_underspecified_op = true;
|
||||||
}
|
}
|
||||||
|
@ -395,6 +395,7 @@ namespace smt {
|
||||||
|
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
theory_var theory_arith<Ext>::internalize_div(app * n) {
|
theory_var theory_arith<Ext>::internalize_div(app * n) {
|
||||||
|
if (!m_util.is_numeral(n->get_arg(1))) found_underspecified_op(n);
|
||||||
found_underspecified_op(n);
|
found_underspecified_op(n);
|
||||||
theory_var s = mk_binary_op(n);
|
theory_var s = mk_binary_op(n);
|
||||||
context & ctx = get_context();
|
context & ctx = get_context();
|
||||||
|
@ -418,7 +419,7 @@ namespace smt {
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
theory_var theory_arith<Ext>::internalize_mod(app * n) {
|
theory_var theory_arith<Ext>::internalize_mod(app * n) {
|
||||||
TRACE("arith_mod", tout << "internalizing...\n" << mk_pp(n, get_manager()) << "\n";);
|
TRACE("arith_mod", tout << "internalizing...\n" << mk_pp(n, get_manager()) << "\n";);
|
||||||
found_underspecified_op(n);
|
if (!m_util.is_numeral(n->get_arg(1))) found_underspecified_op(n);
|
||||||
theory_var s = mk_binary_op(n);
|
theory_var s = mk_binary_op(n);
|
||||||
context & ctx = get_context();
|
context & ctx = get_context();
|
||||||
if (!ctx.relevancy())
|
if (!ctx.relevancy())
|
||||||
|
@ -428,7 +429,7 @@ namespace smt {
|
||||||
|
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
theory_var theory_arith<Ext>::internalize_rem(app * n) {
|
theory_var theory_arith<Ext>::internalize_rem(app * n) {
|
||||||
found_underspecified_op(n);
|
if (!m_util.is_numeral(n->get_arg(1))) found_underspecified_op(n);
|
||||||
theory_var s = mk_binary_op(n);
|
theory_var s = mk_binary_op(n);
|
||||||
context & ctx = get_context();
|
context & ctx = get_context();
|
||||||
if (!ctx.relevancy()) {
|
if (!ctx.relevancy()) {
|
||||||
|
|
|
@ -607,12 +607,13 @@ namespace smt {
|
||||||
}
|
}
|
||||||
expr_ref sum(m);
|
expr_ref sum(m);
|
||||||
arith_simp().mk_add(sz, args.c_ptr(), sum);
|
arith_simp().mk_add(sz, args.c_ptr(), sum);
|
||||||
|
literal l(mk_eq(n, sum, false));
|
||||||
TRACE("bv",
|
TRACE("bv",
|
||||||
tout << mk_pp(n, m) << "\n";
|
tout << mk_pp(n, m) << "\n";
|
||||||
tout << mk_pp(sum, m) << "\n";
|
tout << mk_pp(sum, m) << "\n";
|
||||||
|
ctx.display_literal_verbose(tout, l);
|
||||||
|
tout << "\n";
|
||||||
);
|
);
|
||||||
|
|
||||||
literal l(mk_eq(n, sum, false));
|
|
||||||
|
|
||||||
ctx.mark_as_relevant(l);
|
ctx.mark_as_relevant(l);
|
||||||
ctx.mk_th_axiom(get_id(), 1, &l);
|
ctx.mk_th_axiom(get_id(), 1, &l);
|
||||||
|
|
Loading…
Reference in a new issue