mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 01:25:31 +00:00
adding SMT2 log file for solver interaction #867
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
b6c13340bd
commit
f6f3ca1507
9 changed files with 159 additions and 28 deletions
|
@ -38,32 +38,63 @@ void ast_pp_util::collect(expr_ref_vector const& es) {
|
|||
|
||||
void ast_pp_util::display_decls(std::ostream& out) {
|
||||
ast_smt_pp pp(m);
|
||||
coll.order_deps();
|
||||
bool first = m_num_decls == 0;
|
||||
coll.order_deps(m_num_sorts);
|
||||
unsigned n = coll.get_num_sorts();
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
for (unsigned i = m_num_sorts; i < n; ++i) {
|
||||
pp.display_ast_smt2(out, coll.get_sorts()[i], 0, 0, nullptr);
|
||||
}
|
||||
m_num_sorts = n;
|
||||
n = coll.get_num_decls();
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
for (unsigned i = m_num_decls; i < n; ++i) {
|
||||
func_decl* f = coll.get_func_decls()[i];
|
||||
if (f->get_family_id() == null_family_id && !m_removed.contains(f)) {
|
||||
ast_smt2_pp(out, f, m_env) << "\n";
|
||||
}
|
||||
}
|
||||
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()));
|
||||
m_num_decls = n;
|
||||
if (first) {
|
||||
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);
|
||||
}
|
||||
ast_smt2_pp_recdefs(out, recfuns, m_env);
|
||||
}
|
||||
|
||||
void ast_pp_util::remove_decl(func_decl* f) {
|
||||
m_removed.insert(f);
|
||||
}
|
||||
|
||||
std::ostream& ast_pp_util::display_expr(std::ostream& out, expr* f, bool neat) {
|
||||
if (neat) {
|
||||
ast_smt2_pp(out, f, m_env);
|
||||
}
|
||||
else {
|
||||
ast_smt_pp ll_smt2_pp(m);
|
||||
ll_smt2_pp.display_expr_smt2(out, f);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void ast_pp_util::display_assert(std::ostream& out, expr* f, bool neat) {
|
||||
display_expr(out << "(assert ", f, neat) << ")\n";
|
||||
}
|
||||
|
||||
void ast_pp_util::display_assert_and_track(std::ostream& out, expr* f, expr* t, bool neat) {
|
||||
if (neat) {
|
||||
ast_smt2_pp(out << "(assert (=> ", t, m_env) << " ";
|
||||
ast_smt2_pp(out, f, m_env) << "))\n";
|
||||
}
|
||||
else {
|
||||
ast_smt_pp ll_smt2_pp(m);
|
||||
ll_smt2_pp.display_expr_smt2(out << "(assert (=> ", t); out << " ";
|
||||
ll_smt2_pp.display_expr_smt2(out, f); out << "))\n";
|
||||
}
|
||||
}
|
||||
|
||||
void ast_pp_util::display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat) {
|
||||
if (neat) {
|
||||
|
|
|
@ -27,11 +27,13 @@ class ast_pp_util {
|
|||
ast_manager& m;
|
||||
obj_hashtable<func_decl> m_removed;
|
||||
smt2_pp_environment_dbg m_env;
|
||||
unsigned m_num_sorts, m_num_decls;
|
||||
|
||||
public:
|
||||
|
||||
decl_collector coll;
|
||||
|
||||
ast_pp_util(ast_manager& m): m(m), m_env(m), coll(m) {}
|
||||
ast_pp_util(ast_manager& m): m(m), m_env(m), coll(m), m_num_sorts(0), m_num_decls(0) {}
|
||||
|
||||
void collect(expr* e);
|
||||
|
||||
|
@ -45,6 +47,12 @@ class ast_pp_util {
|
|||
|
||||
void display_asserts(std::ostream& out, expr_ref_vector const& fmls, bool neat = true);
|
||||
|
||||
void display_assert(std::ostream& out, expr* f, bool neat = true);
|
||||
|
||||
void display_assert_and_track(std::ostream& out, expr* f, expr* t, bool neat = true);
|
||||
|
||||
std::ostream& display_expr(std::ostream& out, expr* f, bool neat = true);
|
||||
|
||||
smt2_pp_environment& env() { return m_env; }
|
||||
};
|
||||
|
||||
|
|
|
@ -957,7 +957,7 @@ void ast_smt_pp::display_smt2(std::ostream& strm, expr* n) {
|
|||
#if 0
|
||||
decls.display_decls(strm);
|
||||
#else
|
||||
decls.order_deps();
|
||||
decls.order_deps(0);
|
||||
ast_mark sort_mark;
|
||||
for (sort* s : decls.get_sorts()) {
|
||||
if (!(*m_is_declared)(s)) {
|
||||
|
|
|
@ -113,11 +113,14 @@ void decl_collector::visit(ast* n) {
|
|||
}
|
||||
}
|
||||
|
||||
void decl_collector::order_deps() {
|
||||
void decl_collector::order_deps(unsigned n) {
|
||||
top_sort<sort> st;
|
||||
for (sort * s : m_sorts) st.insert(s, collect_deps(s));
|
||||
for (unsigned i = n; i < m_sorts.size(); ++i) {
|
||||
sort* s = m_sorts.get(i);
|
||||
st.insert(s, collect_deps(s));
|
||||
}
|
||||
st.topological_sort();
|
||||
m_sorts.reset();
|
||||
m_sorts.shrink(n);
|
||||
for (sort* s : st.top_sorted()) m_sorts.push_back(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
void visit(unsigned n, expr* const* es);
|
||||
void visit(expr_ref_vector const& es);
|
||||
|
||||
void order_deps();
|
||||
void order_deps(unsigned n);
|
||||
|
||||
unsigned get_num_sorts() const { return m_sorts.size(); }
|
||||
unsigned get_num_decls() const { return m_decls.size(); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue