3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-28 08:58:44 +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

@ -23,13 +23,14 @@ class dependent_expr_state_tactic : public tactic, public dependent_expr_state {
public:
using factoryTy = dependent_expr_simplifier(*(*)(ast_manager& m, params_ref const& p, dependent_expr_state& s));
private:
ast_manager& m;
ast_manager& m;
params_ref m_params;
trail_stack m_trail;
goal_ref m_goal;
dependent_expr m_dep;
statistics m_st;
factoryTy m_factory;
expr_ref_vector m_frozen;
scoped_ptr<dependent_expr_simplifier> m_simp;
scoped_ptr<model_reconstruction_trail> m_model_trail;
@ -37,6 +38,9 @@ private:
if (!m_simp) {
m_simp = m_factory(m, m_params, *this);
m_st.reset();
push();
for (expr* e : m_frozen)
freeze(e);
}
if (!m_model_trail)
m_model_trail = alloc(model_reconstruction_trail, m, m_trail);
@ -44,14 +48,20 @@ private:
public:
dependent_expr_state_tactic(ast_manager& m, params_ref const& p, factoryTy f):
dependent_expr_state_tactic(ast_manager& m, params_ref const& p, factoryTy f) :
dependent_expr_state(m),
m(m),
m_params(p),
m_dep(m, m.mk_true(), nullptr, nullptr),
m_factory(f)
m_factory(f),
m_frozen(m)
{}
~dependent_expr_state_tactic() override {
if (m_simp)
pop(1);
}
/**
* size(), [](), update() and inconsisent() implement the abstract interface of dependent_expr_state
*/
@ -61,14 +71,14 @@ public:
m_dep = dependent_expr(m, m_goal->form(i), m_goal->pr(i), m_goal->dep(i));
return m_dep;
}
void update(unsigned i, dependent_expr const& j) override {
if (inconsistent())
return;
auto [f, p, d] = j();
m_goal->update(i, f, p, d);
}
void add(dependent_expr const& j) override {
if (inconsistent())
return;
@ -83,10 +93,10 @@ public:
model_reconstruction_trail& model_trail() override {
return *m_model_trail;
}
char const* name() const override { return m_simp?m_simp->name():"null"; }
void updt_params(params_ref const & p) override {
char const* name() const override { return m_simp ? m_simp->name() : "null"; }
void updt_params(params_ref const& p) override {
m_params.append(p);
init();
m_simp->updt_params(m_params);
@ -97,12 +107,12 @@ public:
m_simp->collect_param_descrs(r);
}
tactic * translate(ast_manager & m) override {
tactic* translate(ast_manager& m) override {
return alloc(dependent_expr_state_tactic, m, m_params, m_factory);
}
void operator()(goal_ref const & in,
goal_ref_buffer & result) override {
void operator()(goal_ref const& in,
goal_ref_buffer& result) override {
init();
statistics_report sreport(*this);
tactic_report report(name(), *in);
@ -124,25 +134,39 @@ public:
}
void cleanup() override {
if (m_simp)
if (m_simp) {
m_simp->collect_statistics(m_st);
pop(1);
}
m_simp = nullptr;
m_model_trail = nullptr;
m_goal = nullptr;
m_dep = dependent_expr(m, m.mk_true(), nullptr, nullptr);
}
void collect_statistics(statistics & st) const override {
if (m_simp)
void collect_statistics(statistics& st) const override {
if (m_simp)
m_simp->collect_statistics(st);
else
st.copy(m_st);
}
void reset_statistics() override {
if (m_simp)
m_simp->reset_statistics();
m_st.reset();
}
};
void user_propagate_register_expr(expr* e) override {
freeze(e);
m_frozen.push_back(e);
}
void user_propagate_clear() override {
if (m_simp) {
pop(1);
push();
}
m_frozen.reset();
}
};