3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-02 01:13:18 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-04-02 15:04:05 -07:00
parent f98b94bdbc
commit 896a1b2048
17 changed files with 59 additions and 56 deletions

View file

@ -89,7 +89,7 @@ br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c
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";
tout << "args: " << to_app(result)->get_num_args() << "\n";
if (is_app(result)) tout << "args: " << to_app(result)->get_num_args() << "\n";
);
return st;
}

View file

@ -83,9 +83,9 @@ class default_expr_replacer : public expr_replacer {
default_expr_replacer_cfg m_cfg;
rewriter_tpl<default_expr_replacer_cfg> m_replacer;
public:
default_expr_replacer(ast_manager & m):
default_expr_replacer(ast_manager & m, bool proofs_enabled):
m_cfg(m),
m_replacer(m, m.proofs_enabled(), m_cfg) {
m_replacer(m, m.proofs_enabled() && proofs_enabled, m_cfg) {
}
ast_manager & m() const override { return m_replacer.m(); }
@ -115,8 +115,8 @@ public:
}
};
expr_replacer * mk_default_expr_replacer(ast_manager & m) {
return alloc(default_expr_replacer, m);
expr_replacer * mk_default_expr_replacer(ast_manager & m, bool proofs_allowed) {
return alloc(default_expr_replacer, m, proofs_allowed);
}
/**

View file

@ -49,7 +49,7 @@ public:
/**
\brief Create a vanilla replacer. It just applies the substitution.
*/
expr_replacer * mk_default_expr_replacer(ast_manager & m);
expr_replacer * mk_default_expr_replacer(ast_manager & m, bool proofs_allowed);
/**
\brief Apply substitution and simplify.

View file

@ -35,47 +35,49 @@ void rewriter_tpl<Config>::process_var(var * v) {
m_r = nullptr;
return;
}
if (!ProofGen) {
// bindings are only used when Proof Generation is not enabled.
unsigned idx = v->get_idx();
unsigned idx = v->get_idx();
if (ProofGen) {
result_pr_stack().push_back(nullptr); // implicit reflexivity
if (idx < m_bindings.size()) {
unsigned index = m_bindings.size() - idx - 1;
expr * r = m_bindings[index];
if (r != nullptr) {
CTRACE("rewriter", v->get_sort() != m().get_sort(r),
tout << expr_ref(v, m()) << ":" << sort_ref(v->get_sort(), m()) << " != " << expr_ref(r, m()) << ":" << sort_ref(m().get_sort(r), m());
tout << "index " << index << " bindings " << m_bindings.size() << "\n";
display_bindings(tout););
SASSERT(v->get_sort() == m().get_sort(r));
if (!is_ground(r) && m_shifts[index] != m_bindings.size()) {
unsigned shift_amount = m_bindings.size() - m_shifts[index];
expr* c = get_cached(r, shift_amount);
if (c) {
result_stack().push_back(c);
set_new_child_flag(v);
return;
}
expr_ref tmp(m());
m_shifter(r, shift_amount, tmp);
result_stack().push_back(tmp);
TRACE("rewriter", tout << "shift: " << shift_amount << " idx: " << idx << " --> " << tmp << "\n";
display_bindings(tout););
cache_shifted_result(r, shift_amount, tmp);
}
else {
result_stack().push_back(r);
TRACE("rewriter", tout << idx << " " << mk_ismt2_pp(r, m()) << "\n";);
}
SASSERT(
true || // disabled for now
idx >= m_bindings.size() ||
!m_bindings[m_bindings.size() - idx - 1] ||
v == m_bindings[m_bindings.size() - idx - 1]);
}
unsigned index = 0;
expr * r;
if (!ProofGen && idx < m_bindings.size() &&
(index = m_bindings.size() - idx - 1, r = m_bindings[index])) {
CTRACE("rewriter", v->get_sort() != m().get_sort(r),
tout << expr_ref(v, m()) << ":" << sort_ref(v->get_sort(), m()) << " != " << expr_ref(r, m()) << ":" << sort_ref(m().get_sort(r), m());
tout << "index " << index << " bindings " << m_bindings.size() << "\n";
display_bindings(tout););
SASSERT(v->get_sort() == m().get_sort(r));
if (!is_ground(r) && m_shifts[index] != m_bindings.size()) {
unsigned shift_amount = m_bindings.size() - m_shifts[index];
expr* c = get_cached(r, shift_amount);
if (c) {
result_stack().push_back(c);
set_new_child_flag(v);
return;
}
expr_ref tmp(m());
m_shifter(r, shift_amount, tmp);
result_stack().push_back(tmp);
TRACE("rewriter", tout << "shift: " << shift_amount << " idx: " << idx << " --> " << tmp << "\n";
display_bindings(tout););
cache_shifted_result(r, shift_amount, tmp);
}
else {
result_stack().push_back(r);
TRACE("rewriter", tout << idx << " " << mk_ismt2_pp(r, m()) << "\n";);
}
set_new_child_flag(v);
return;
}
result_stack().push_back(v);
if (ProofGen)
result_pr_stack().push_back(nullptr); // implicit reflexivity
}
template<typename Config>