mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
prepare user propagator declared functions for likely Clemens use case
This commit is contained in:
parent
a288f9048a
commit
6cc9aa3562
8 changed files with 120 additions and 15 deletions
|
@ -38,6 +38,7 @@ class elim_uncnstr_tactic : public tactic {
|
|||
struct rw_cfg : public default_rewriter_cfg {
|
||||
bool m_produce_proofs;
|
||||
obj_hashtable<expr> & m_vars;
|
||||
obj_hashtable<expr>& m_nonvars;
|
||||
ref<mc> m_mc;
|
||||
arith_util m_a_util;
|
||||
bv_util m_bv_util;
|
||||
|
@ -49,10 +50,11 @@ class elim_uncnstr_tactic : public tactic {
|
|||
unsigned long long m_max_memory;
|
||||
unsigned m_max_steps;
|
||||
|
||||
rw_cfg(ast_manager & m, bool produce_proofs, obj_hashtable<expr> & vars, mc * _m,
|
||||
unsigned long long max_memory, unsigned max_steps):
|
||||
rw_cfg(ast_manager & m, bool produce_proofs, obj_hashtable<expr> & vars, obj_hashtable<expr> & nonvars, mc * _m,
|
||||
unsigned long long max_memory, unsigned max_steps):
|
||||
m_produce_proofs(produce_proofs),
|
||||
m_vars(vars),
|
||||
m_nonvars(nonvars),
|
||||
m_mc(_m),
|
||||
m_a_util(m),
|
||||
m_bv_util(m),
|
||||
|
@ -73,7 +75,7 @@ class elim_uncnstr_tactic : public tactic {
|
|||
}
|
||||
|
||||
bool uncnstr(expr * arg) const {
|
||||
return m_vars.contains(arg);
|
||||
return m_vars.contains(arg) && !m_nonvars.contains(arg);
|
||||
}
|
||||
|
||||
bool uncnstr(unsigned num, expr * const * args) const {
|
||||
|
@ -749,16 +751,17 @@ class elim_uncnstr_tactic : public tactic {
|
|||
class rw : public rewriter_tpl<rw_cfg> {
|
||||
rw_cfg m_cfg;
|
||||
public:
|
||||
rw(ast_manager & m, bool produce_proofs, obj_hashtable<expr> & vars, mc * _m,
|
||||
rw(ast_manager & m, bool produce_proofs, obj_hashtable<expr> & vars, obj_hashtable<expr>& nonvars, mc * _m,
|
||||
unsigned long long max_memory, unsigned max_steps):
|
||||
rewriter_tpl<rw_cfg>(m, produce_proofs, m_cfg),
|
||||
m_cfg(m, produce_proofs, vars, _m, max_memory, max_steps) {
|
||||
m_cfg(m, produce_proofs, vars, nonvars, _m, max_memory, max_steps) {
|
||||
}
|
||||
};
|
||||
|
||||
ast_manager & m_manager;
|
||||
ref<mc> m_mc;
|
||||
obj_hashtable<expr> m_vars;
|
||||
obj_hashtable<expr> m_nonvars;
|
||||
scoped_ptr<rw> m_rw;
|
||||
unsigned m_num_elim_apps = 0;
|
||||
unsigned long long m_max_memory;
|
||||
|
@ -774,12 +777,11 @@ class elim_uncnstr_tactic : public tactic {
|
|||
}
|
||||
|
||||
void init_rw(bool produce_proofs) {
|
||||
m_rw = alloc(rw, m(), produce_proofs, m_vars, m_mc.get(), m_max_memory, m_max_steps);
|
||||
m_rw = alloc(rw, m(), produce_proofs, m_vars, m_nonvars, m_mc.get(), m_max_memory, m_max_steps);
|
||||
}
|
||||
|
||||
void run(goal_ref const & g, goal_ref_buffer & result) {
|
||||
bool produce_proofs = g->proofs_enabled();
|
||||
|
||||
TRACE("goal", g->display(tout););
|
||||
tactic_report report("elim-uncnstr", *g);
|
||||
m_vars.reset();
|
||||
|
@ -890,6 +892,16 @@ public:
|
|||
m_num_elim_apps = 0;
|
||||
}
|
||||
|
||||
unsigned user_propagate_register(expr* e) override {
|
||||
m_nonvars.insert(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void user_propagate_clear() override {
|
||||
m_nonvars.reset();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,33 @@ namespace user_propagator {
|
|||
typedef std::function<void*(void*, ast_manager&, context_obj*&)> fresh_eh_t;
|
||||
typedef std::function<void(void*)> push_eh_t;
|
||||
typedef std::function<void(void*,unsigned)> pop_eh_t;
|
||||
typedef std::function<void(void*, callback*, expr*, unsigned)> register_created_eh_t;
|
||||
|
||||
|
||||
class plugin : public decl_plugin {
|
||||
public:
|
||||
|
||||
enum kind_t { OP_USER_PROPAGATE };
|
||||
|
||||
virtual ~plugin() {}
|
||||
|
||||
virtual decl_plugin* mk_fresh() { return alloc(plugin); }
|
||||
|
||||
family_id get_family_id() const { return m_family_id; }
|
||||
|
||||
sort* mk_sort(decl_kind k, unsigned num_parameters, parameter const* parameters) override {
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
func_decl* mk_func_decl(decl_kind k, unsigned num_parameters, parameter const* parameters,
|
||||
unsigned arity, sort* const* domain, sort* range) {
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class core {
|
||||
public:
|
||||
|
||||
|
@ -58,8 +83,25 @@ namespace user_propagator {
|
|||
throw default_exception("user-propagators are only supported on the SMT solver");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create uninterpreted function for the user propagator.
|
||||
* When expressions using the function are assigned values, generate a callback
|
||||
* into a register_declared_eh(user_ctx, solver_ctx, declared_expr, declare_id) with arguments
|
||||
* 1. context and callback context
|
||||
* 2. declared_expr: expression using function that was declared at top.
|
||||
* 3. declared_id: a unique identifier (unique within the current scope) to track the expression.
|
||||
*/
|
||||
virtual func_decl* user_propagate_declare(symbol const& name, unsigned n, sort* const* domain, sort* range) {
|
||||
throw default_exception("user-propagators are only supported on the SMT solver");
|
||||
}
|
||||
|
||||
virtual void user_propagate_register_created(register_created_eh_t& r) {
|
||||
throw default_exception("user-propagators are only supported on the SMT solver");
|
||||
}
|
||||
|
||||
virtual void user_propagate_clear() {
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue