mirror of
https://github.com/Z3Prover/z3
synced 2025-06-16 02:46:16 +00:00
New style of json dump based on lemmas at pob
This commit is contained in:
parent
5072a2a869
commit
bfa472faec
4 changed files with 156 additions and 127 deletions
|
@ -441,7 +441,7 @@ void derivation::premise::set_summary (expr * summary, bool must,
|
||||||
lemma::lemma (ast_manager &manager, expr * body, unsigned lvl) :
|
lemma::lemma (ast_manager &manager, expr * body, unsigned lvl) :
|
||||||
m_ref_count(0), m(manager),
|
m_ref_count(0), m(manager),
|
||||||
m_body(body, m), m_cube(m),
|
m_body(body, m), m_cube(m),
|
||||||
m_zks(m), m_bindings(m), m_lvl(lvl),
|
m_zks(m), m_bindings(m), m_lvl(lvl), m_init_lvl(m_lvl),
|
||||||
m_pob(nullptr), m_ctp(nullptr), m_external(false) {
|
m_pob(nullptr), m_ctp(nullptr), m_external(false) {
|
||||||
SASSERT(m_body);
|
SASSERT(m_body);
|
||||||
normalize(m_body, m_body);
|
normalize(m_body, m_body);
|
||||||
|
@ -450,7 +450,7 @@ lemma::lemma (ast_manager &manager, expr * body, unsigned lvl) :
|
||||||
lemma::lemma(pob_ref const &p) :
|
lemma::lemma(pob_ref const &p) :
|
||||||
m_ref_count(0), m(p->get_ast_manager()),
|
m_ref_count(0), m(p->get_ast_manager()),
|
||||||
m_body(m), m_cube(m),
|
m_body(m), m_cube(m),
|
||||||
m_zks(m), m_bindings(m), m_lvl(p->level()),
|
m_zks(m), m_bindings(m), m_lvl(p->level()), m_init_lvl(m_lvl),
|
||||||
m_pob(p), m_ctp(nullptr), m_external(false) {
|
m_pob(p), m_ctp(nullptr), m_external(false) {
|
||||||
SASSERT(m_pob);
|
SASSERT(m_pob);
|
||||||
m_pob->get_skolems(m_zks);
|
m_pob->get_skolems(m_zks);
|
||||||
|
@ -461,7 +461,7 @@ lemma::lemma(pob_ref const &p, expr_ref_vector &cube, unsigned lvl) :
|
||||||
m_ref_count(0),
|
m_ref_count(0),
|
||||||
m(p->get_ast_manager()),
|
m(p->get_ast_manager()),
|
||||||
m_body(m), m_cube(m),
|
m_body(m), m_cube(m),
|
||||||
m_zks(m), m_bindings(m), m_lvl(p->level()),
|
m_zks(m), m_bindings(m), m_lvl(p->level()), m_init_lvl(m_lvl),
|
||||||
m_pob(p), m_ctp(nullptr), m_external(false)
|
m_pob(p), m_ctp(nullptr), m_external(false)
|
||||||
{
|
{
|
||||||
if (m_pob) {
|
if (m_pob) {
|
||||||
|
|
|
@ -114,7 +114,8 @@ class lemma {
|
||||||
expr_ref_vector m_cube;
|
expr_ref_vector m_cube;
|
||||||
app_ref_vector m_zks;
|
app_ref_vector m_zks;
|
||||||
app_ref_vector m_bindings;
|
app_ref_vector m_bindings;
|
||||||
unsigned m_lvl;
|
unsigned m_lvl; // current level of the lemma
|
||||||
|
unsigned m_init_lvl; // level at which lemma was created
|
||||||
pob_ref m_pob;
|
pob_ref m_pob;
|
||||||
model_ref m_ctp; // counter-example to pushing
|
model_ref m_ctp; // counter-example to pushing
|
||||||
bool m_external;
|
bool m_external;
|
||||||
|
@ -150,6 +151,7 @@ public:
|
||||||
|
|
||||||
bool is_inductive() const {return is_infty_level(m_lvl);}
|
bool is_inductive() const {return is_infty_level(m_lvl);}
|
||||||
unsigned level () const {return m_lvl;}
|
unsigned level () const {return m_lvl;}
|
||||||
|
unsigned init_level() const {return m_init_lvl;}
|
||||||
void set_level (unsigned lvl);
|
void set_level (unsigned lvl);
|
||||||
app_ref_vector& get_bindings() {return m_bindings;}
|
app_ref_vector& get_bindings() {return m_bindings;}
|
||||||
bool has_binding(app_ref_vector const &binding);
|
bool has_binding(app_ref_vector const &binding);
|
||||||
|
|
|
@ -24,7 +24,7 @@ Notes:
|
||||||
|
|
||||||
namespace spacer {
|
namespace spacer {
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, ast *t, ast_manager &m) {
|
static std::ostream &json_marshal(std::ostream &out, ast *t, ast_manager &m) {
|
||||||
|
|
||||||
mk_epp pp = mk_epp(t, m);
|
mk_epp pp = mk_epp(t, m);
|
||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
|
@ -66,14 +66,17 @@ namespace spacer {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, lemma *l) {
|
static std::ostream &json_marshal(std::ostream &out, lemma *l) {
|
||||||
out << R"({"level":")" << l->level() << R"(", "expr":)";
|
out << "{"
|
||||||
|
<< R"("init_level":")" << l->init_level()
|
||||||
|
<< R"(", "level":")" << l->level()
|
||||||
|
<< R"(", "expr":)";
|
||||||
json_marshal(out, l->get_expr(), l->get_ast_manager());
|
json_marshal(out, l->get_expr(), l->get_ast_manager());
|
||||||
out << "}";
|
out << "}";
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, const lemma_ref_vector &lemmas) {
|
static std::ostream &json_marshal(std::ostream &out, const lemma_ref_vector &lemmas) {
|
||||||
|
|
||||||
std::ostringstream ls;
|
std::ostringstream ls;
|
||||||
for (auto l:lemmas) {
|
for (auto l:lemmas) {
|
||||||
|
@ -95,25 +98,54 @@ namespace spacer {
|
||||||
m_relations[p];
|
m_relations[p];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &spacer::json_marshaller::marshal(std::ostream &out) const {
|
void json_marshaller::marshal_lemmas_old(std::ostream &out) const {
|
||||||
std::ostringstream nodes;
|
|
||||||
std::ostringstream edges;
|
|
||||||
std::ostringstream lemmas;
|
|
||||||
|
|
||||||
unsigned pob_id = 0;
|
unsigned pob_id = 0;
|
||||||
for (auto &pob_map:m_relations) {
|
for (auto &pob_map:m_relations) {
|
||||||
std::ostringstream pob_lemmas;
|
std::ostringstream pob_lemmas;
|
||||||
for (auto &depth_lemmas : pob_map.second) {
|
for (auto &depth_lemmas : pob_map.second) {
|
||||||
pob_lemmas << ((unsigned)pob_lemmas.tellp() == 0 ? "" : ",") << "\"" << depth_lemmas.first << "\":";
|
pob_lemmas << ((unsigned)pob_lemmas.tellp() == 0 ? "" : ",")
|
||||||
|
<< "\"" << depth_lemmas.first << "\":";
|
||||||
json_marshal(pob_lemmas, depth_lemmas.second);
|
json_marshal(pob_lemmas, depth_lemmas.second);
|
||||||
}
|
}
|
||||||
if (pob_lemmas.tellp()) {
|
if (pob_lemmas.tellp()) {
|
||||||
lemmas << ((unsigned)lemmas.tellp() == 0 ? "" : ",\n");
|
out << ((unsigned)out.tellp() == 0 ? "" : ",\n");
|
||||||
lemmas << "\"" << pob_id << "\":{" << pob_lemmas.str() << "}";
|
out << "\"" << pob_id << "\":{" << pob_lemmas.str() << "}";
|
||||||
}
|
}
|
||||||
pob_id++;
|
pob_id++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void json_marshaller::marshal_lemmas_new(std::ostream &out) const {
|
||||||
|
unsigned pob_id = 0;
|
||||||
|
for (auto &pob_map:m_relations) {
|
||||||
|
std::ostringstream pob_lemmas;
|
||||||
|
pob *n = pob_map.first;
|
||||||
|
for (auto *l : n->lemmas()) {
|
||||||
|
pob_lemmas << ((unsigned)pob_lemmas.tellp() == 0 ? "" : ",")
|
||||||
|
<< "\"0\":";
|
||||||
|
lemma_ref_vector lemmas_vec;
|
||||||
|
lemmas_vec.push_back(l);
|
||||||
|
json_marshal(pob_lemmas, lemmas_vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pob_lemmas.tellp()) {
|
||||||
|
out << ((unsigned)out.tellp() == 0 ? "" : ",\n");
|
||||||
|
out << "\"" << pob_id << "\":{" << pob_lemmas.str() << "}";
|
||||||
|
}
|
||||||
|
pob_id++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream &json_marshaller::marshal(std::ostream &out) const {
|
||||||
|
std::ostringstream nodes;
|
||||||
|
std::ostringstream edges;
|
||||||
|
std::ostringstream lemmas;
|
||||||
|
|
||||||
|
if (m_old_style)
|
||||||
|
marshal_lemmas_old(lemmas);
|
||||||
|
else
|
||||||
|
marshal_lemmas_new(lemmas);
|
||||||
|
|
||||||
|
unsigned pob_id = 0;
|
||||||
unsigned depth = 0;
|
unsigned depth = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
double root_expand_time = m_ctx->get_root().get_expand_time(depth);
|
double root_expand_time = m_ctx->get_root().get_expand_time(depth);
|
||||||
|
|
|
@ -32,26 +32,21 @@ class ast_manager;
|
||||||
namespace spacer {
|
namespace spacer {
|
||||||
|
|
||||||
class lemma;
|
class lemma;
|
||||||
|
|
||||||
typedef sref_vector<lemma> lemma_ref_vector;
|
typedef sref_vector<lemma> lemma_ref_vector;
|
||||||
|
|
||||||
class context;
|
class context;
|
||||||
|
|
||||||
class pob;
|
class pob;
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, ast *t, ast_manager &m);
|
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, lemma *l);
|
|
||||||
|
|
||||||
std::ostream &json_marshal(std::ostream &out, lemma_ref_vector &lemmas);
|
|
||||||
|
|
||||||
|
|
||||||
class json_marshaller {
|
class json_marshaller {
|
||||||
context *m_ctx;
|
context *m_ctx;
|
||||||
|
bool m_old_style;
|
||||||
std::map<pob*, std::map<unsigned, lemma_ref_vector>> m_relations;
|
std::map<pob*, std::map<unsigned, lemma_ref_vector>> m_relations;
|
||||||
|
|
||||||
|
void marshal_lemmas_old(std::ostream &out) const;
|
||||||
|
void marshal_lemmas_new(std::ostream &out) const;
|
||||||
public:
|
public:
|
||||||
json_marshaller(context *ctx) : m_ctx(ctx) {}
|
json_marshaller(context *ctx, bool old_style = false) :
|
||||||
|
m_ctx(ctx), m_old_style(old_style) {}
|
||||||
|
|
||||||
void register_lemma(lemma *l);
|
void register_lemma(lemma *l);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue