mirror of
https://github.com/Z3Prover/z3
synced 2025-04-13 04:28:17 +00:00
replace app by expr
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
0d71d85069
commit
9a0406d181
|
@ -27,7 +27,6 @@ Revision History:
|
|||
#include "ast/rewriter/var_subst.h"
|
||||
#include "ast/for_each_expr.h"
|
||||
#include "ast/factor_equivs.h"
|
||||
#include "qe/qe_term_graph.h"
|
||||
#include "ast/rewriter/expr_safe_replace.h"
|
||||
#include "ast/substitution/matcher.h"
|
||||
#include "ast/expr_functors.h"
|
||||
|
|
|
@ -171,7 +171,7 @@ namespace qe {
|
|||
|
||||
virtual ~arith_term_graph_plugin() {}
|
||||
|
||||
bool mk_eq_core (expr *_e1, expr *_e2, app_ref &res) {
|
||||
bool mk_eq_core (expr *_e1, expr *_e2, expr_ref &res) {
|
||||
expr *e1, *e2;
|
||||
e1 = _e1;
|
||||
e2 = _e2;
|
||||
|
@ -227,7 +227,7 @@ namespace qe {
|
|||
return m_arith.mk_ge(arg, mk_zero());
|
||||
}
|
||||
|
||||
bool mk_le_core (expr *arg1, expr * arg2, app_ref &result) {
|
||||
bool mk_le_core (expr *arg1, expr * arg2, expr_ref &result) {
|
||||
// t <= -1 ==> t < 0 ==> ! (t >= 0)
|
||||
rational n;
|
||||
if (m_arith.is_int (arg1) && m_arith.is_minus_one (arg2)) {
|
||||
|
@ -252,7 +252,7 @@ namespace qe {
|
|||
return m_arith.is_numeral (n, val) && val.is_one ();
|
||||
}
|
||||
|
||||
bool mk_ge_core (expr * arg1, expr * arg2, app_ref &result) {
|
||||
bool mk_ge_core (expr * arg1, expr * arg2, expr_ref &result) {
|
||||
// t >= 1 ==> t > 0 ==> ! (t <= 0)
|
||||
rational n;
|
||||
if (m_arith.is_int (arg1) && is_one (arg2)) {
|
||||
|
@ -271,8 +271,8 @@ namespace qe {
|
|||
return false;
|
||||
}
|
||||
|
||||
virtual app_ref process_lit (app *_lit) {
|
||||
app *lit = _lit;
|
||||
expr_ref process_lit (expr *_lit) override {
|
||||
expr *lit = _lit;
|
||||
expr *e1, *e2;
|
||||
|
||||
// strip negation
|
||||
|
@ -281,7 +281,7 @@ namespace qe {
|
|||
lit = to_app(to_app(lit)->get_arg(0));
|
||||
}
|
||||
|
||||
app_ref res(m);
|
||||
expr_ref res(m);
|
||||
res = lit;
|
||||
if (m.is_eq (lit, e1, e2)) {
|
||||
mk_eq_core(e1, e2, res);
|
||||
|
@ -295,7 +295,7 @@ namespace qe {
|
|||
|
||||
// restore negation
|
||||
if (is_neg) {
|
||||
res = m.mk_not(res);
|
||||
res = mk_not(m, res);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -314,27 +314,26 @@ namespace qe {
|
|||
reset();
|
||||
}
|
||||
|
||||
static family_id get_family_id(ast_manager &m, app *lit) {
|
||||
family_id fid = null_family_id;
|
||||
|
||||
expr *e1 = nullptr, *e2 = nullptr, *e3 = nullptr;
|
||||
// strip negation
|
||||
if (!m.is_not (lit, e1)) { e1 = lit; }
|
||||
static family_id get_family_id(ast_manager &m, expr *lit) {
|
||||
if (m.is_not(lit, lit))
|
||||
return get_family_id(m, lit);
|
||||
|
||||
expr *a = nullptr, *b = nullptr;
|
||||
// deal with equality using sort of range
|
||||
if (m.is_eq (e1, e2, e3)) {
|
||||
fid = get_sort (e2)->get_family_id();
|
||||
if (m.is_eq (lit, a, b)) {
|
||||
return get_sort (a)->get_family_id();
|
||||
}
|
||||
// extract family_id of top level app
|
||||
else if (is_app(lit)) {
|
||||
return to_app(lit)->get_decl()->get_family_id();
|
||||
}
|
||||
else {
|
||||
fid = to_app(e1)->get_decl()->get_family_id();
|
||||
return null_family_id;
|
||||
}
|
||||
}
|
||||
|
||||
return fid;
|
||||
}
|
||||
|
||||
void term_graph::add_lit(app *l) {
|
||||
app_ref lit(m);
|
||||
void term_graph::add_lit(expr *l) {
|
||||
expr_ref lit(m);
|
||||
|
||||
family_id fid = get_family_id (m, l);
|
||||
term_graph_plugin *pin = m_plugins.get_plugin(fid);
|
||||
|
@ -509,7 +508,7 @@ expr_ref term_graph::mk_app(expr *a) {
|
|||
|
||||
}
|
||||
|
||||
void term_graph::mk_equalities(term const &t, app_ref_vector &out) {
|
||||
void term_graph::mk_equalities(term const &t, expr_ref_vector &out) {
|
||||
SASSERT(t.is_root());
|
||||
expr_ref rep(mk_app(t), m);
|
||||
|
||||
|
@ -519,7 +518,7 @@ void term_graph::mk_equalities(term const &t, app_ref_vector &out) {
|
|||
}
|
||||
}
|
||||
|
||||
void term_graph::mk_all_equalities(term const &t, app_ref_vector &out) {
|
||||
void term_graph::mk_all_equalities(term const &t, expr_ref_vector &out) {
|
||||
mk_equalities(t, out);
|
||||
|
||||
for (term *it = &t.get_next(); it != &t; it = &it->get_next ()) {
|
||||
|
@ -569,6 +568,7 @@ void term_graph::pick_root (term &t) {
|
|||
r->mk_root();
|
||||
}
|
||||
}
|
||||
|
||||
/// Choose better roots for equivalence classes
|
||||
void term_graph::pick_roots() {
|
||||
for (term* t : m_terms) {
|
||||
|
@ -587,10 +587,10 @@ void term_graph::display(std::ostream &out) {
|
|||
}
|
||||
}
|
||||
|
||||
void term_graph::to_lits (app_ref_vector &lits, bool all_equalities) {
|
||||
void term_graph::to_lits (expr_ref_vector &lits, bool all_equalities) {
|
||||
pick_roots();
|
||||
|
||||
for (app * a : m_lits) {
|
||||
for (expr * a : m_lits) {
|
||||
if (is_internalized(a)) {
|
||||
lits.push_back (::to_app(mk_app(a)));
|
||||
}
|
||||
|
@ -606,16 +606,9 @@ void term_graph::to_lits (app_ref_vector &lits, bool all_equalities) {
|
|||
}
|
||||
}
|
||||
|
||||
void term_graph::to_lits (expr_ref_vector &lits, bool all_equalities) {
|
||||
app_ref_vector out(m);
|
||||
to_lits (out, all_equalities);
|
||||
for (app* a : out) {
|
||||
lits.push_back(a);
|
||||
}
|
||||
}
|
||||
|
||||
app_ref term_graph::to_app() {
|
||||
app_ref_vector lits(m);
|
||||
expr_ref term_graph::to_app() {
|
||||
expr_ref_vector lits(m);
|
||||
to_lits(lits);
|
||||
return mk_and(lits);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace qe {
|
|||
family_id get_family_id() const {return m_id;}
|
||||
|
||||
/// Process (and potentially augment) a literal
|
||||
virtual app_ref process_lit (app *lit) = 0;
|
||||
virtual expr_ref process_lit (expr *lit) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace qe {
|
|||
struct term_eq { bool operator()(term const* a, term const* b) const; };
|
||||
ast_manager & m;
|
||||
ptr_vector<term> m_terms;
|
||||
app_ref_vector m_lits; // NSB: expr_ref_vector?
|
||||
expr_ref_vector m_lits; // NSB: expr_ref_vector?
|
||||
u_map<term* > m_app2term;
|
||||
ast_ref_vector m_pinned;
|
||||
u_map<expr*> m_term2app;
|
||||
|
@ -74,25 +74,25 @@ namespace qe {
|
|||
expr_ref mk_app(term const &t);
|
||||
expr* mk_pure(term& t);
|
||||
expr_ref mk_app(expr *a);
|
||||
void mk_equalities(term const &t, app_ref_vector &out);
|
||||
void mk_all_equalities(term const &t, app_ref_vector &out);
|
||||
void mk_equalities(term const &t, expr_ref_vector &out);
|
||||
void mk_all_equalities(term const &t, expr_ref_vector &out);
|
||||
void display(std::ostream &out);
|
||||
|
||||
public:
|
||||
term_graph(ast_manager &m);
|
||||
~term_graph();
|
||||
|
||||
ast_manager& get_ast_manager() const { return m;}
|
||||
|
||||
void add_lit(app *lit); // NSB: replace by expr*
|
||||
void add_lits(expr_ref_vector const &lits) {
|
||||
for (expr* e : lits) add_lit(::to_app(e));
|
||||
}
|
||||
void add_eq(expr* a, expr* b);
|
||||
void add_lit(expr *lit);
|
||||
void add_lits(expr_ref_vector const &lits) { for (expr* e : lits) add_lit(e); }
|
||||
void add_eq(expr* a, expr* b) { internalize_eq(a, b); }
|
||||
|
||||
void reset();
|
||||
void to_lits(app_ref_vector &lits, bool all_equalities = false); // NSB: swap roles
|
||||
|
||||
// deprecate?
|
||||
void to_lits(expr_ref_vector &lits, bool all_equalities = false);
|
||||
app_ref to_app();
|
||||
expr_ref to_app();
|
||||
|
||||
/**
|
||||
* Return literals obtained by projecting added literals
|
||||
|
|
Loading…
Reference in a new issue