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

formatting. no change to code

This commit is contained in:
Arie Gurfinkel 2018-06-11 22:44:11 -07:00
parent 6d79b19170
commit 0f799eb2ae

View file

@ -626,21 +626,21 @@ namespace qe {
expr_ref_vector m_pinned; // tracks expr in the maps expr_ref_vector m_pinned; // tracks expr in the maps
expr* mk_pure(term const& t) { expr* mk_pure(term const& t) {
expr* e = nullptr; expr* e = nullptr;
if (m_term2app.find(t.get_id(), e)) return e; if (m_term2app.find(t.get_id(), e)) return e;
e = t.get_expr(); e = t.get_expr();
if (!is_app(e)) return nullptr; if (!is_app(e)) return nullptr;
app* a = ::to_app(e); app* a = ::to_app(e);
expr_ref_buffer kids(m); expr_ref_buffer kids(m);
for (term* ch : term::children(t)) { for (term* ch : term::children(t)) {
if (!m_root2rep.find(ch->get_root().get_id(), e)) return nullptr; if (!m_root2rep.find(ch->get_root().get_id(), e)) return nullptr;
kids.push_back(e); kids.push_back(e);
} }
expr* pure = m.mk_app(a->get_decl(), kids.size(), kids.c_ptr()); expr* pure = m.mk_app(a->get_decl(), kids.size(), kids.c_ptr());
m_pinned.push_back(pure); m_pinned.push_back(pure);
m_term2app.insert(t.get_id(), pure); m_term2app.insert(t.get_id(), pure);
return pure; return pure;
} }
bool is_better_rep(expr *t1, expr *t2) { bool is_better_rep(expr *t1, expr *t2) {
if (!t2) return t1 != nullptr; if (!t2) return t1 != nullptr;
@ -648,34 +648,34 @@ namespace qe {
} }
void purify() { void purify() {
// - propagate representatives up over parents. // - propagate representatives up over parents.
// use work-list + marking to propagate. // use work-list + marking to propagate.
// - produce equalities over represented classes. // - produce equalities over represented classes.
// - produce other literals over represented classes // - produce other literals over represented classes
// (walk disequalities in m_lits and represent // (walk disequalities in m_lits and represent
// lhs/rhs over decls or excluding decls) // lhs/rhs over decls or excluding decls)
ptr_vector<term> worklist; ptr_vector<term> worklist;
for (term * t : m_tg.m_terms) { for (term * t : m_tg.m_terms) {
worklist.push_back(t); worklist.push_back(t);
t->set_mark(true); t->set_mark(true);
} }
while (!worklist.empty()) { while (!worklist.empty()) {
term* t = worklist.back(); term* t = worklist.back();
worklist.pop_back(); worklist.pop_back();
t->set_mark(false); t->set_mark(false);
if (m_term2app.contains(t->get_id())) if (m_term2app.contains(t->get_id()))
continue; continue;
if (!t->is_theory() && is_projected(*t)) if (!t->is_theory() && is_projected(*t))
continue; continue;
expr* pure = mk_pure(*t); expr* pure = mk_pure(*t);
if (!pure) continue; if (!pure) continue;
m_term2app.insert(t->get_id(), pure); m_term2app.insert(t->get_id(), pure);
expr* rep = nullptr; expr* rep = nullptr;
// ensure that the root has a representative // ensure that the root has a representative
m_root2rep.find(t->get_root().get_id(), rep); m_root2rep.find(t->get_root().get_id(), rep);
// update rep with pure if it is better // update rep with pure if it is better
@ -686,9 +686,9 @@ namespace qe {
if (!p->is_marked()) { if (!p->is_marked()) {
p->set_mark(true); p->set_mark(true);
worklist.push_back(p); worklist.push_back(p);
} }
} }
} }
} }
// Here we could also walk equivalence classes that // Here we could also walk equivalence classes that
@ -698,16 +698,16 @@ namespace qe {
// and can be mined using other means, such as theory // and can be mined using other means, such as theory
// aware core minimization // aware core minimization
m_tg.reset_marks(); m_tg.reset_marks();
} }
void solve() { void solve() {
ptr_vector<term> worklist; ptr_vector<term> worklist;
for (term * t : m_tg.m_terms) { for (term * t : m_tg.m_terms) {
// skip pure terms // skip pure terms
if (m_term2app.contains(t->get_id())) continue; if (m_term2app.contains(t->get_id())) continue;
worklist.push_back(t); worklist.push_back(t);
t->set_mark(true); t->set_mark(true);
} }
while (!worklist.empty()) { while (!worklist.empty()) {
term* t = worklist.back(); term* t = worklist.back();
@ -728,15 +728,15 @@ namespace qe {
m_root2rep.insert(t->get_root().get_id(), pure); m_root2rep.insert(t->get_root().get_id(), pure);
for (term * p : term::parents(t->get_root())) { for (term * p : term::parents(t->get_root())) {
SASSERT(!m_term2app.contains(p->get_id())); SASSERT(!m_term2app.contains(p->get_id()));
if (!p->is_marked()) { if (!p->is_marked()) {
p->set_mark(true); p->set_mark(true);
worklist.push_back(p); worklist.push_back(p);
}
}
} }
} }
}
}
m_tg.reset_marks(); m_tg.reset_marks();
} }
bool find_app(term &t, expr *&res) { bool find_app(term &t, expr *&res) {
return m_root2rep.find(t.get_root().get_id(), res); return m_root2rep.find(t.get_root().get_id(), res);
@ -744,7 +744,7 @@ namespace qe {
bool find_app(expr *lit, expr *&res) { bool find_app(expr *lit, expr *&res) {
return m_root2rep.find(m_tg.get_term(lit)->get_root().get_id(), res); return m_root2rep.find(m_tg.get_term(lit)->get_root().get_id(), res);
} }
void mk_lits(expr_ref_vector &res) { void mk_lits(expr_ref_vector &res) {
expr *e = nullptr; expr *e = nullptr;
@ -752,7 +752,7 @@ namespace qe {
if (!m.is_eq(lit) && find_app(lit, e)) if (!m.is_eq(lit) && find_app(lit, e))
res.push_back(e); res.push_back(e);
} }
} }
void mk_pure_equalities(const term &t, expr_ref_vector &res) { void mk_pure_equalities(const term &t, expr_ref_vector &res) {
SASSERT(t.is_root()); SASSERT(t.is_root());
@ -812,16 +812,16 @@ namespace qe {
} }
bool is_solved_eq(expr *_lhs, expr* _rhs) { bool is_solved_eq(expr *_lhs, expr* _rhs) {
if (!is_app(_lhs) || !is_app(_rhs)) return false; if (!is_app(_lhs) || !is_app(_rhs)) return false;
app *lhs, *rhs; app *lhs, *rhs;
lhs = ::to_app(_lhs); lhs = ::to_app(_lhs);
rhs = ::to_app(_rhs); rhs = ::to_app(_rhs);
if (rhs->get_num_args() > 0) return false; if (rhs->get_num_args() > 0) return false;
if (rhs->get_family_id() != null_family_id) return false; if (rhs->get_family_id() != null_family_id) return false;
return !occurs(rhs, lhs); return !occurs(rhs, lhs);
} }
public: public:
projector(term_graph &tg) : m_tg(tg), m(m_tg.m), m_pinned(m) {} projector(term_graph &tg) : m_tg(tg), m(m_tg.m), m_pinned(m) {}
@ -832,7 +832,7 @@ namespace qe {
m_root2rep.reset(); m_root2rep.reset();
m_decls.reset(); m_decls.reset();
m_pinned.reset(); m_pinned.reset();
} }
expr_ref_vector project(func_decl_ref_vector const &decls, bool exclude) { expr_ref_vector project(func_decl_ref_vector const &decls, bool exclude) {
expr_ref_vector res(m); expr_ref_vector res(m);
m_exclude = exclude; m_exclude = exclude;
@ -842,7 +842,7 @@ namespace qe {
mk_pure_equalities(res); mk_pure_equalities(res);
reset(); reset();
return res; return res;
} }
expr_ref_vector solve(func_decl_ref_vector const &decls, bool exclude) { expr_ref_vector solve(func_decl_ref_vector const &decls, bool exclude) {
expr_ref_vector res(m); expr_ref_vector res(m);
m_exclude = exclude; m_exclude = exclude;
@ -854,7 +854,7 @@ namespace qe {
return res; return res;
} }
}; };
} }
expr_ref_vector term_graph::project(func_decl_ref_vector const& decls, bool exclude) { expr_ref_vector term_graph::project(func_decl_ref_vector const& decls, bool exclude) {
projector p(*this); projector p(*this);