3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-21 21:33:39 +00:00

add a predicate for depth limit assumptions

This commit is contained in:
Simon Cruanes 2017-12-06 13:01:54 +01:00
parent d5e134dd94
commit 06e0b12700
3 changed files with 67 additions and 2 deletions

View file

@ -342,7 +342,7 @@ namespace recfun {
*/
util::util(ast_manager & m, family_id id)
: m_manager(m), m_family_id(id), m_th_rw(m), m_plugin(0) {
: m_manager(m), m_family_id(id), m_th_rw(m), m_plugin(0), m_dlimit_map() {
m_plugin = dynamic_cast<decl::plugin*>(m.get_plugin(m_family_id));
}
@ -354,6 +354,15 @@ namespace recfun {
d.set_definition(n_vars, vars, rhs);
}
// get or create predicate for depth limit
depth_limit_pred_ref util::get_depth_limit_pred(unsigned d) {
depth_limit_pred * pred = nullptr;
if (! m_dlimit_map.find(d, pred)) {
pred = alloc(depth_limit_pred, m(), m_family_id, d);
m_dlimit_map.insert(d, pred);
}
return depth_limit_pred_ref(pred, *this);
}
// used to know which `app` are from this theory
struct is_imm_pred : is_immediate_pred {
@ -387,6 +396,17 @@ namespace recfun {
d->compute_cases(is_i, u->get_th_rewriter(), n_vars, vars, rhs);
}
depth_limit_pred::depth_limit_pred(ast_manager & m, family_id fid, unsigned d)
: m_name_buf(), m_name(""), m_depth(d), m_decl(m) {
// build name, then build decl
std::ostringstream tmpname(m_name_buf);
tmpname << "depth_limit_" << d;
m_name = symbol(m_name_buf.c_str());
parameter params[1] = { parameter(d) };
func_decl_info info(fid, OP_DEPTH_LIMIT, 1, params);
m_decl = m.mk_func_decl(m_name, 0, ((sort*const *)nullptr), m.mk_bool_sort(), info);
}
namespace decl {
plugin::plugin() : decl_plugin(), m_defs(), m_case_defs(), m_def_block() {}
plugin::~plugin() { finalize(); }
@ -424,6 +444,13 @@ namespace recfun {
}
}
app_ref plugin::mk_depth_limit_pred(unsigned d) {
depth_limit_pred_ref p = u().get_depth_limit_pred(d);
app_ref res(m());
m().mk_app(p->get_decl(), 0, nullptr, res);
return res;
}
def* plugin::mk_def(symbol const& name, unsigned n, sort ** params, sort * range,
unsigned n_vars, var ** vars, expr * rhs) {
SASSERT(! m_defs.contains(name));