3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-19 17:50:23 +00:00

prepare release notes

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-10-28 17:42:16 -05:00
parent 43d9159a74
commit 0f0287d129
21 changed files with 144 additions and 67 deletions

View file

@ -20,6 +20,7 @@ Revision History:
#include "ast/ast_pp_util.h"
#include "ast/ast_smt2_pp.h"
#include "ast/ast_smt_pp.h"
#include "ast/recfun_decl_plugin.h"
void ast_pp_util::collect(expr* e) {
coll.visit(e);
@ -49,7 +50,14 @@ void ast_pp_util::display_decls(std::ostream& out) {
ast_smt2_pp(out, f, m_env) << "\n";
}
}
SASSERT(coll.get_num_preds() == 0);
vector<std::pair<func_decl*, expr*>> recfuns;
recfun::util u(m);
func_decl_ref_vector funs = u.get_rec_funs();
if (funs.empty()) return;
for (func_decl * f : funs) {
recfuns.push_back(std::make_pair(f, u.get_def(f).get_rhs()));
}
ast_smt2_pp_recdefs(out, recfuns, m_env);
}
void ast_pp_util::remove_decl(func_decl* f) {

View file

@ -31,7 +31,7 @@ class ast_pp_util {
decl_collector coll;
ast_pp_util(ast_manager& m): m(m), m_env(m), coll(m, false) {}
ast_pp_util(ast_manager& m): m(m), m_env(m), coll(m) {}
void collect(expr* e);

View file

@ -1163,6 +1163,33 @@ public:
unregister_var_names(f->get_arity());
}
// format set of mutually recursive definitions
void operator()(vector<std::pair<func_decl*, expr*>> const& funs, format_ref & r) {
format_ref_vector decls(m()), bodies(m());
format_ref r1(m()), r2(m());
for (auto const& p : funs) {
unsigned len;
func_decl* f = p.first;
expr* e = p.second;
format * fname = m_env.pp_fdecl_name(f, len);
register_var_names(f->get_arity());
format * args[3];
args[0] = fname;
args[1] = pp_var_args(f->get_arity(), f->get_domain());
args[2] = m_env.pp_sort(f->get_range());
decls.push_back(mk_seq1<format**, f2f>(m(), args, args+3, f2f(), ""));
process(e, r);
bodies.push_back(r);
unregister_var_names(f->get_arity());
}
r1 = mk_seq1<format*const*, f2f>(m(), decls.begin(), decls.end(), f2f(), "");
r2 = mk_seq1<format*const*, f2f>(m(), bodies.begin(), bodies.end(), f2f(), "");
format * args[2];
args[0] = r1;
args[1] = r2;
r = mk_seq1<format**, f2f>(m(), args, args+2, f2f(), "define-rec-funs");
}
};
@ -1275,6 +1302,16 @@ std::ostream & ast_smt2_pp(std::ostream & out, symbol const& s, bool is_skolem,
return out;
}
std::ostream & ast_smt2_pp_recdefs(std::ostream & out, vector<std::pair<func_decl*, expr*>> const& funs, smt2_pp_environment & env, params_ref const & p) {
ast_manager & m = env.get_manager();
format_ref r(fm(m));
smt2_printer pr(env, p);
pr(funs, r);
pp(out, r.get(), m, p);
return out;
}
mk_ismt2_pp::mk_ismt2_pp(ast * t, ast_manager & m, params_ref const & p, unsigned indent, unsigned num_vars, char const * var_prefix):
m_ast(t),
m_manager(m),

View file

@ -105,6 +105,8 @@ std::ostream & ast_smt2_pp(std::ostream & out, sort * s, smt2_pp_environment & e
std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0, char const* cmd = "declare-fun");
std::ostream & ast_smt2_pp(std::ostream & out, func_decl * f, expr* e, smt2_pp_environment & env, params_ref const & p = params_ref(), unsigned indent = 0, char const* cmd = "define-fun");
std::ostream & ast_smt2_pp(std::ostream & out, symbol const& s, bool is_skolem, smt2_pp_environment & env, params_ref const& p = params_ref());
std::ostream & ast_smt2_pp_recdefs(std::ostream & out, vector<std::pair<func_decl*, expr*>> const& funs, smt2_pp_environment & env, params_ref const & p = params_ref());
/**
\brief Internal wrapper (for debugging purposes only)

View file

@ -980,14 +980,6 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
}
}
for (unsigned i = 0; i < decls.get_num_preds(); ++i) {
func_decl* d = decls.get_pred_decls()[i];
if (!(*m_is_declared)(d)) {
smt_printer p(strm, m, ql, rn, m_logic, true, true, m_simplify_implies, 0);
p(d);
strm << "\n";
}
}
#endif
for (expr* a : m_assumptions) {

View file

@ -50,18 +50,14 @@ void decl_collector::visit_func(func_decl * n) {
if (!m_visited.is_marked(n)) {
family_id fid = n->get_family_id();
if (fid == null_family_id) {
if (m_sep_preds && is_bool(n->get_range()))
m_preds.push_back(n);
else
m_decls.push_back(n);
m_decls.push_back(n);
}
m_visited.mark(n, true);
}
}
decl_collector::decl_collector(ast_manager & m, bool preds):
decl_collector::decl_collector(ast_manager & m):
m_manager(m),
m_sep_preds(preds),
m_dt_util(m) {
m_basic_fid = m_manager.get_basic_family_id();
m_dt_fid = m_dt_util.get_family_id();

View file

@ -26,10 +26,8 @@ Revision History:
class decl_collector {
ast_manager & m_manager;
bool m_sep_preds;
ptr_vector<sort> m_sorts;
ptr_vector<func_decl> m_decls;
ptr_vector<func_decl> m_preds;
ast_mark m_visited;
family_id m_basic_fid;
family_id m_dt_fid;
@ -46,8 +44,7 @@ class decl_collector {
public:
// if preds == true, then predicates are stored in a separate collection.
decl_collector(ast_manager & m, bool preds = true);
decl_collector(ast_manager & m);
ast_manager & m() { return m_manager; }
void visit_func(func_decl* n);
@ -59,11 +56,9 @@ public:
unsigned get_num_sorts() const { return m_sorts.size(); }
unsigned get_num_decls() const { return m_decls.size(); }
unsigned get_num_preds() const { return m_preds.size(); }
sort * const * get_sorts() const { return m_sorts.c_ptr(); }
func_decl * const * get_func_decls() const { return m_decls.c_ptr(); }
func_decl * const * get_pred_decls() const { return m_preds.c_ptr(); }
};
#endif

View file

@ -369,7 +369,7 @@ namespace recfun {
}
namespace decl {
plugin::plugin() : decl_plugin(), m_defs(), m_case_defs(), m_def_block() {}
plugin::plugin() : decl_plugin(), m_defs(), m_case_defs() {}
plugin::~plugin() { finalize(); }
void plugin::finalize() {

View file

@ -143,9 +143,8 @@ namespace recfun {
typedef obj_map<func_decl, case_def*> case_def_map;
mutable scoped_ptr<util> m_util;
def_map m_defs; // function->def
case_def_map m_case_defs; // case_pred->def
svector<symbol> m_def_block;
def_map m_defs; // function->def
case_def_map m_case_defs; // case_pred->def
ast_manager & m() { return *m_manager; }
public:
@ -206,8 +205,11 @@ namespace recfun {
ast_manager & m() { return m_manager; }
th_rewriter & get_th_rewriter() { return m_th_rw; }
decl::plugin& get_plugin() { return *m_plugin; }
bool is_case_pred(expr * e) const { return is_app_of(e, m_fid, OP_FUN_CASE_PRED); }
bool is_defined(expr * e) const { return is_app_of(e, m_fid, OP_FUN_DEFINED); }
bool is_defined(func_decl* f) const { return is_decl_of(f, m_fid, OP_FUN_DEFINED); }
bool is_depth_limit(expr * e) const { return is_app_of(e, m_fid, OP_DEPTH_LIMIT); }
bool owns_app(app * e) const { return e->get_family_id() == m_fid; }
@ -242,11 +244,6 @@ namespace recfun {
app_ref mk_depth_limit_pred(unsigned d);
decl::plugin& get_plugin() { return *m_plugin; }
};
}
typedef recfun::def recfun_def;
typedef recfun::case_def recfun_case_def;
typedef recfun::decl::plugin recfun_decl_plugin;
typedef recfun::util recfun_util;

View file

@ -42,7 +42,7 @@ void reg_decl_plugins(ast_manager & m) {
m.register_plugin(symbol("datatype"), alloc(datatype_decl_plugin));
}
if (!m.get_plugin(m.mk_family_id(symbol("recfun")))) {
m.register_plugin(symbol("recfun"), alloc(recfun_decl_plugin));
m.register_plugin(symbol("recfun"), alloc(recfun::decl::plugin));
}
if (!m.get_plugin(m.mk_family_id(symbol("datalog_relation")))) {
m.register_plugin(symbol("datalog_relation"), alloc(datalog::dl_decl_plugin));