From 918a5b9e8c1c93bc32129afc2612ffa11bb2d9db Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sun, 21 Oct 2018 13:15:51 -0700 Subject: [PATCH] updates to recfun_decl_plugin Signed-off-by: Nikolaj Bjorner --- src/ast/recfun_decl_plugin.cpp | 107 +++++++++++++-------------------- src/ast/recfun_decl_plugin.h | 6 +- 2 files changed, 44 insertions(+), 69 deletions(-) diff --git a/src/ast/recfun_decl_plugin.cpp b/src/ast/recfun_decl_plugin.cpp index cdd1cec92..6ee0ddc39 100644 --- a/src/ast/recfun_decl_plugin.cpp +++ b/src/ast/recfun_decl_plugin.cpp @@ -33,26 +33,32 @@ namespace recfun { family_id fid, def * d, std::string & name, + unsigned case_index, sort_ref_vector const & arg_sorts, - unsigned num_guards, expr ** guards, expr* rhs) + expr_ref_vector const& guards, + expr* rhs) : m_pred(m), - m_guards(m, num_guards, guards), + m_guards(guards), m_rhs(expr_ref(rhs,m)), m_def(d) { - func_decl_info info(fid, OP_FUN_CASE_PRED); + parameter p(case_index); + func_decl_info info(fid, OP_FUN_CASE_PRED, 1, &p); m_pred = m.mk_func_decl(symbol(name.c_str()), arg_sorts.size(), arg_sorts.c_ptr(), m.mk_bool_sort(), info); } def::def(ast_manager &m, family_id fid, symbol const & s, unsigned arity, sort* const * domain, sort* range) : m(m), m_name(s), - m_domain(m, arity, domain), m_range(range, m), m_vars(m), m_cases(), - m_decl(m), m_fid(fid), m_macro(false) + m_domain(m, arity, domain), + m_range(range, m), m_vars(m), m_cases(), + m_decl(m), + m_fid(fid), + m_macro(false) { SASSERT(arity == get_arity()); func_decl_info info(fid, OP_FUN_DEFINED); - m_decl = m.mk_func_decl(m_name, arity, domain, range, info); + m_decl = m.mk_func_decl(s, arity, domain, range, info); } // does `e` contain any `ite` construct? @@ -101,6 +107,8 @@ namespace recfun { ite_lst const * to_split; // `ite` terms to make a choice on unfold_lst const * to_unfold; // terms yet to unfold + branch(unfold_lst const * to_unfold): + path(nullptr), to_split(nullptr), to_unfold(to_unfold) {} branch(choice_lst const * path, ite_lst const * to_split, unfold_lst const * to_unfold) : path(path), to_split(to_split), to_unfold(to_unfold) {} branch(branch const & from) : @@ -110,14 +118,12 @@ namespace recfun { // state for computing cases from the RHS of a functions' definition class case_state { region m_reg; - ast_manager & m_manager; vector m_branches; public: - case_state(ast_manager & m) : m_reg(), m_manager(m), m_branches() {} + case_state() : m_reg(), m_branches() {} bool empty() const { return m_branches.empty(); } - ast_manager & m() const { return m_manager; } region & reg() { return m_reg; } branch pop_branch() { @@ -128,7 +134,6 @@ namespace recfun { void push_branch(branch const & b) { m_branches.push_back(b); } - unfold_lst const * cons_unfold(expr * e, unfold_lst const * next) { return new (reg()) unfold_lst{e, next}; } @@ -149,7 +154,7 @@ namespace recfun { }; //