mirror of
https://github.com/Z3Prover/z3
synced 2025-05-01 04:45:52 +00:00
wreckfun
This commit is contained in:
parent
612cc5cfba
commit
83f4a006c6
11 changed files with 402 additions and 219 deletions
|
@ -35,62 +35,6 @@ namespace recfun {
|
|||
void reset() { memset(this, 0, sizeof(stats)); }
|
||||
stats() { reset(); }
|
||||
};
|
||||
|
||||
// one case-expansion of `f(t1...tn)`
|
||||
struct case_expansion {
|
||||
app * m_lhs; // the term to expand
|
||||
recfun::def * m_def;
|
||||
ptr_vector<expr> m_args;
|
||||
case_expansion(recfun::util& u, app * n) :
|
||||
m_lhs(n), m_def(nullptr), m_args() {
|
||||
SASSERT(u.is_defined(n));
|
||||
func_decl * d = n->get_decl();
|
||||
m_def = &u.get_def(d);
|
||||
m_args.append(n->get_num_args(), n->get_args());
|
||||
}
|
||||
case_expansion(case_expansion const & from)
|
||||
: m_lhs(from.m_lhs),
|
||||
m_def(from.m_def),
|
||||
m_args(from.m_args) {}
|
||||
case_expansion(case_expansion && from)
|
||||
: m_lhs(from.m_lhs),
|
||||
m_def(from.m_def),
|
||||
m_args(std::move(from.m_args)) {}
|
||||
};
|
||||
|
||||
struct pp_case_expansion {
|
||||
case_expansion & e;
|
||||
ast_manager & m;
|
||||
pp_case_expansion(case_expansion & e, ast_manager & m) : e(e), m(m) {}
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&, pp_case_expansion const &);
|
||||
|
||||
// one body-expansion of `f(t1...tn)` using a `C_f_i(t1...tn)`
|
||||
struct body_expansion {
|
||||
app* m_pred;
|
||||
recfun::case_def const * m_cdef;
|
||||
ptr_vector<expr> m_args;
|
||||
|
||||
body_expansion(recfun::util& u, app * n) : m_pred(n), m_cdef(nullptr), m_args() {
|
||||
m_cdef = &u.get_case_def(n);
|
||||
m_args.append(n->get_num_args(), n->get_args());
|
||||
}
|
||||
body_expansion(app* pred, recfun::case_def const & d, ptr_vector<expr> & args) :
|
||||
m_pred(pred), m_cdef(&d), m_args(args) {}
|
||||
body_expansion(body_expansion const & from):
|
||||
m_pred(from.m_pred), m_cdef(from.m_cdef), m_args(from.m_args) {}
|
||||
body_expansion(body_expansion && from) :
|
||||
m_pred(from.m_pred), m_cdef(from.m_cdef), m_args(std::move(from.m_args)) {}
|
||||
};
|
||||
|
||||
struct pp_body_expansion {
|
||||
body_expansion & e;
|
||||
ast_manager & m;
|
||||
pp_body_expansion(body_expansion & e, ast_manager & m) : e(e), m(m) {}
|
||||
};
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&, pp_body_expansion const &);
|
||||
|
||||
recfun::decl::plugin& m_plugin;
|
||||
recfun::util& m_util;
|
||||
|
@ -103,12 +47,44 @@ namespace recfun {
|
|||
obj_map<expr, unsigned> m_pred_depth;
|
||||
expr_ref_vector m_preds;
|
||||
unsigned_vector m_preds_lim;
|
||||
unsigned m_num_rounds;
|
||||
unsigned m_num_rounds { 0 };
|
||||
|
||||
ptr_vector<case_expansion> m_q_case_expand;
|
||||
ptr_vector<body_expansion> m_q_body_expand;
|
||||
vector<sat::literal_vector> m_q_clauses;
|
||||
ptr_vector<expr> m_q_guards;
|
||||
struct propagation_item {
|
||||
case_expansion* m_case { nullptr };
|
||||
body_expansion* m_body { nullptr };
|
||||
sat::literal_vector m_clause;
|
||||
expr* m_guard { nullptr };
|
||||
|
||||
~propagation_item() {
|
||||
dealloc(m_case);
|
||||
dealloc(m_body);
|
||||
}
|
||||
|
||||
propagation_item(expr* guard):
|
||||
m_guard(guard)
|
||||
{}
|
||||
|
||||
propagation_item(sat::literal_vector const& clause):
|
||||
m_clause(clause)
|
||||
{}
|
||||
|
||||
propagation_item(body_expansion* b):
|
||||
m_body(b)
|
||||
{}
|
||||
propagation_item(case_expansion* c):
|
||||
m_case(c)
|
||||
{}
|
||||
|
||||
bool is_guard() const { return m_guard != nullptr; }
|
||||
bool is_clause() const { return !m_clause.empty(); }
|
||||
bool is_case() const { return m_case != nullptr; }
|
||||
bool is_body() const { return m_body != nullptr; }
|
||||
};
|
||||
scoped_ptr_vector<propagation_item> m_propagation_queue;
|
||||
unsigned m_qhead { 0 };
|
||||
|
||||
void push_body_expand(expr* e);
|
||||
void push_case_expand(expr* e);
|
||||
|
||||
bool is_enabled_guard(expr* guard) { expr_ref ng(m.mk_not(guard), m); return m_enabled_guards.contains(ng); }
|
||||
bool is_disabled_guard(expr* guard) { return m_disabled_guards.contains(guard); }
|
||||
|
@ -122,12 +98,10 @@ namespace recfun {
|
|||
|
||||
void activate_guard(expr* guard, expr_ref_vector const& guards);
|
||||
|
||||
void reset_queues();
|
||||
expr_ref apply_args(unsigned depth, recfun::vars const & vars, ptr_vector<expr> const & args, expr * e); //!< substitute variables by args
|
||||
expr_ref apply_args(vars const & vars, expr_ref_vector const & args, expr * e); //!< substitute variables by args
|
||||
void assert_macro_axiom(case_expansion & e);
|
||||
void assert_case_axioms(case_expansion & e);
|
||||
void assert_body_axiom(body_expansion & e);
|
||||
sat::literal mk_literal(expr* e);
|
||||
|
||||
void add_induction_lemmas(unsigned depth);
|
||||
void disable_guard(expr* guard, expr_ref_vector const& guards);
|
||||
|
@ -141,6 +115,10 @@ namespace recfun {
|
|||
}
|
||||
|
||||
void reset();
|
||||
bool visit(expr* e) override;
|
||||
bool visited(expr* e) override;
|
||||
bool post_visit(expr* e, bool sign, bool root) override;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
@ -157,7 +135,7 @@ namespace recfun {
|
|||
euf::th_solver* clone(euf::solver& ctx) override;
|
||||
bool unit_propagate() override;
|
||||
sat::literal internalize(expr* e, bool sign, bool root, bool learned) override;
|
||||
void internalize(expr* e, bool redundant) override { UNREACHABLE(); }
|
||||
void internalize(expr* e, bool redundant) override;
|
||||
euf::theory_var mk_var(euf::enode* n) override;
|
||||
void init_search() override;
|
||||
void finalize_model(model& mdl) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue