3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-10 05:00:51 +00:00

convert reduce-args to a simplifier

- convert reduce-args to a simplifier. Currently exposed as reduce-args2 tactic until the old tactic code gets removed.
- bug fixes in model_reconstruction trail
  - allow multiple defs to be added with same pool of removed formulas
  - fix tracking of function symbols instead of expressions to filter replay
- add nla_divisions to track (cheap) divisibility lemmas.
-
This commit is contained in:
Nikolaj Bjorner 2023-01-28 20:12:14 -08:00
parent 246d6f7b77
commit 8ea49eed8e
23 changed files with 740 additions and 92 deletions

View file

@ -13,6 +13,7 @@ Author:
#include "ast/for_each_expr.h"
#include "ast/ast_ll_pp.h"
#include "ast/rewriter/macro_replacer.h"
#include "ast/simplifiers/model_reconstruction_trail.h"
#include "ast/simplifiers/dependent_expr_state.h"
@ -24,6 +25,10 @@ Author:
// TODO: add filters to skip sections of the trail that do not touch the current free variables.
void model_reconstruction_trail::replay(unsigned qhead, expr_ref_vector& assumptions, dependent_expr_state& st) {
TRACE("simplifier",
for (unsigned i = qhead; i < st.qtail(); ++i)
tout << mk_bounded_pp(st[i].fml(), m) << "\n";
);
ast_mark free_vars;
scoped_ptr<expr_replacer> rp = mk_default_expr_replacer(m, false);
for (unsigned i = qhead; i < st.qtail(); ++i)
@ -32,6 +37,7 @@ void model_reconstruction_trail::replay(unsigned qhead, expr_ref_vector& assumpt
add_vars(a, free_vars);
for (auto& t : m_trail) {
TRACE("simplifier", tout << " active " << t->m_active << " hide " << t->is_hide() << " intersects " << t->intersects(free_vars) << "\n");
if (!t->m_active)
continue;
@ -56,15 +62,17 @@ void model_reconstruction_trail::replay(unsigned qhead, expr_ref_vector& assumpt
if (t->is_def()) {
macro_replacer mrp(m);
app_ref head(m);
func_decl* d = t->m_decl;
ptr_buffer<expr> args;
for (unsigned i = 0; i < d->get_arity(); ++i)
args.push_back(m.mk_var(i, d->get_domain(i)));
head = m.mk_app(d, args);
mrp.insert(head, t->m_def, t->m_dep);
dependent_expr de(m, t->m_def, nullptr, t->m_dep);
add_vars(de, free_vars);
for (auto const& [d, def, dep] : t->m_defs) {
app_ref head(m);
ptr_buffer<expr> args;
for (unsigned i = 0; i < d->get_arity(); ++i)
args.push_back(m.mk_var(i, d->get_domain(i)));
head = m.mk_app(d, args);
mrp.insert(head, def, dep);
TRACE("simplifier", tout << d << " " << def << " " << dep << "\n");
dependent_expr de(m, def, nullptr, dep);
add_vars(de, free_vars);
}
for (unsigned i = qhead; i < st.qtail(); ++i) {
auto [f, p, dep1] = st[i]();
@ -140,6 +148,7 @@ model_converter_ref model_reconstruction_trail::get_model_converter() {
* Append model conversions starting at index i
*/
void model_reconstruction_trail::append(generic_model_converter& mc, unsigned& i) {
TRACE("simplifier", display(tout));
for (; i < m_trail.size(); ++i) {
auto* t = m_trail[i];
if (!t->m_active)
@ -147,7 +156,8 @@ void model_reconstruction_trail::append(generic_model_converter& mc, unsigned& i
else if (t->is_hide())
mc.hide(t->m_decl);
else if (t->is_def())
mc.add(t->m_decl, t->m_def);
for (auto const& [f, def, dep] : t->m_defs)
mc.add(f, def);
else {
for (auto const& [v, def] : t->m_subst->sub())
mc.add(v, def);
@ -167,8 +177,10 @@ std::ostream& model_reconstruction_trail::display(std::ostream& out) const {
continue;
else if (t->is_hide())
out << "hide " << t->m_decl->get_name() << "\n";
else if (t->is_def())
out << t->m_decl->get_name() << " <- " << mk_pp(t->m_def, m) << "\n";
else if (t->is_def()) {
for (auto const& [f, def, dep] : t->m_defs)
out << f->get_name() << " <- " << mk_pp(def, m) << "\n";
}
else {
for (auto const& [v, def] : t->m_subst->sub())
out << mk_pp(v, m) << " <- " << mk_pp(def, m) << "\n";