3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 09:34:08 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-10-02 20:35:36 -07:00
parent c8908e81aa
commit 5b4cd6dde4
4 changed files with 23 additions and 11 deletions

View file

@ -87,8 +87,10 @@ br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c
default: st = BR_FAILED; break;
}
CTRACE("arith_rewriter", st != BR_FAILED, tout << st << ": " << mk_pp(f, m());
for (unsigned i = 0; i < num_args; ++i) tout << mk_pp(args[i], m()) << " ";
tout << "\n==>\n" << mk_pp(result.get(), m()) << "\n";);
for (unsigned i = 0; i < num_args; ++i) tout << mk_pp(args[i], m()) << " ";
tout << "\n==>\n" << mk_pp(result.get(), m()) << "\n";
tout << "args: " << to_app(result)->get_num_args() << "\n";
);
return st;
}
@ -527,14 +529,15 @@ bool arith_rewriter::is_arith_term(expr * n) const {
}
br_status arith_rewriter::mk_eq_core(expr * arg1, expr * arg2, expr_ref & result) {
br_status st = BR_FAILED;
if (m_eq2ineq) {
result = m().mk_and(m_util.mk_le(arg1, arg2), m_util.mk_ge(arg1, arg2));
return BR_REWRITE2;
st = BR_REWRITE2;
}
if (m_arith_lhs || is_arith_term(arg1) || is_arith_term(arg2)) {
return mk_le_ge_eq_core(arg1, arg2, EQ, result);
else if (m_arith_lhs || is_arith_term(arg1) || is_arith_term(arg2)) {
st = mk_le_ge_eq_core(arg1, arg2, EQ, result);
}
return BR_FAILED;
return st;
}
expr_ref arith_rewriter::neg_monomial(expr* e) const {

View file

@ -117,10 +117,18 @@ expr * poly_rewriter<Config>::mk_mul_app(unsigned num_args, expr * const * args)
return new_args[0];
}
else {
numeral a;
if (new_args.size() > 2 && is_numeral(new_args.get(0), a)) {
return mk_mul_app(a, mk_mul_app(new_args.size() - 1, new_args.c_ptr() + 1));
}
return m().mk_app(get_fid(), mul_decl_kind(), new_args.size(), new_args.c_ptr());
}
}
else {
numeral a;
if (num_args > 2 && is_numeral(args[0], a)) {
return mk_mul_app(a, mk_mul_app(num_args - 1, args + 1));
}
return m().mk_app(get_fid(), mul_decl_kind(), num_args, args);
}
}
@ -180,12 +188,14 @@ br_status poly_rewriter<Config>::mk_flat_mul_core(unsigned num_args, expr * cons
flat_args.push_back(args[j]);
}
}
br_status st = mk_nflat_mul_core(flat_args.size(), flat_args.c_ptr(), result);
TRACE("poly_rewriter",
tout << "flat mul:\n";
for (unsigned i = 0; i < num_args; i++) tout << mk_bounded_pp(args[i], m()) << "\n";
tout << "---->\n";
for (unsigned i = 0; i < flat_args.size(); i++) tout << mk_bounded_pp(flat_args[i], m()) << "\n";);
br_status st = mk_nflat_mul_core(flat_args.size(), flat_args.c_ptr(), result);
for (unsigned i = 0; i < flat_args.size(); i++) tout << mk_bounded_pp(flat_args[i], m()) << "\n";
tout << st << "\n";
);
if (st == BR_FAILED) {
result = mk_mul_app(flat_args.size(), flat_args.c_ptr());
return BR_DONE;

View file

@ -336,7 +336,7 @@ namespace smt {
template<typename Ext>
theory_var theory_arith<Ext>::internalize_mul(app * m) {
rational _val;
TRACE("arith", tout << mk_pp(m, get_manager()) << "\n";);
TRACE("arith", tout << m->get_num_args() << " " << mk_pp(m, get_manager()) << "\n";);
SASSERT(m_util.is_mul(m));
expr* arg0 = m->get_arg(0);
expr* arg1 = m->get_arg(1);
@ -366,7 +366,7 @@ namespace smt {
add_row_entry<false>(r_id, numeral::one(), s);
init_row(r_id);
return s;
}
}
else {
return internalize_mul_core(m);
}

View file

@ -143,7 +143,6 @@ public:
if (e != nullptr) {
m_trail_stack.push_back(e->m_data);
e->m_data.m_data = data;
return;
}
else {
m_trail_stack.push_back(dummy);