3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-12 06:00:53 +00:00

remove level of indirection for context and ast_manager in smt_theory (#4253)

* remove level of indirection for context and ast_manager in smt_theory

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add request by #4252

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* move to def

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* int

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-05-08 16:46:03 -07:00 committed by GitHub
parent 17b8db95c1
commit becf423c77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 750 additions and 1257 deletions

View file

@ -22,23 +22,15 @@ Revision History:
namespace smt {
void theory::init(context * ctx) {
SASSERT(m_context == 0);
m_context = ctx;
m_manager = &(ctx->get_manager());
}
void theory::reset_eh() {
m_var2enode.reset();
}
void theory::push_scope_eh() {
SASSERT(m_context);
m_var2enode_lim.push_back(m_var2enode.size());
}
void theory::pop_scope_eh(unsigned num_scopes) {
SASSERT(m_context);
unsigned scope_lvl = m_var2enode_lim.size();
SASSERT(num_scopes <= scope_lvl);
unsigned new_lvl = scope_lvl - num_scopes;
@ -109,19 +101,17 @@ namespace smt {
}
bool theory::is_relevant_and_shared(enode * n) const {
context & ctx = get_context();
return ctx.is_relevant(n) && ctx.is_shared(n);
}
bool theory::assume_eq(enode * n1, enode * n2) {
return get_context().assume_eq(n1, n2);
return ctx.assume_eq(n1, n2);
}
literal theory::mk_eq(expr * a, expr * b, bool gate_ctx) {
if (a == b) {
return true_literal;
}
context & ctx = get_context();
app_ref eq(ctx.mk_eq_atom(a, b), get_manager());
TRACE("mk_var_bug", tout << "mk_eq: " << eq->get_id() << " " << a->get_id() << " " << b->get_id() << "\n";
tout << mk_ll_pp(a, get_manager()) << "\n" << mk_ll_pp(b, get_manager()););
@ -130,7 +120,6 @@ namespace smt {
}
literal theory::mk_preferred_eq(expr* a, expr* b) {
context& ctx = get_context();
ctx.assume_eq(ensure_enode(a), ensure_enode(b));
literal lit = mk_eq(a, b, false);
ctx.force_phase(lit);
@ -138,7 +127,6 @@ namespace smt {
}
enode* theory::ensure_enode(expr* e) {
context& ctx = get_context();
if (!ctx.e_internalized(e)) {
ctx.internalize(e, false);
}
@ -147,22 +135,25 @@ namespace smt {
return n;
}
theory::theory(family_id fid):
theory::theory(context& ctx, family_id fid):
m_id(fid),
m_context(nullptr),
m_manager(nullptr) {
ctx(ctx),
m(ctx.get_manager()) {
}
theory::~theory() {
}
smt_params const& theory::get_fparams() const {
return ctx.get_fparams();
}
void theory::log_axiom_instantiation(literal_vector const& ls) {
ast_manager& m = get_manager();
expr_ref_vector fmls(m);
expr_ref tmp(m);
for (literal l : ls) {
get_context().literal2expr(l, tmp);
ctx.literal2expr(l, tmp);
fmls.push_back(tmp);
}
log_axiom_instantiation(mk_or(fmls));
@ -196,8 +187,8 @@ namespace smt {
enode *orig = std::get<0>(n);
enode *substituted = std::get<1>(n);
if (orig != nullptr) {
quantifier_manager::log_justification_to_root(out, orig, already_visited, get_context(), get_manager());
quantifier_manager::log_justification_to_root(out, substituted, already_visited, get_context(), get_manager());
quantifier_manager::log_justification_to_root(out, orig, already_visited, ctx, get_manager());
quantifier_manager::log_justification_to_root(out, substituted, already_visited, ctx, get_manager());
}
}
out << "[new-match] " << static_cast<void *>(nullptr) << " " << family_name << "#" << axiom_id << " " << family_name << "#" << pattern_id;
@ -221,7 +212,7 @@ namespace smt {
}
theory_var theory::get_th_var(expr* e) const {
return get_th_var(get_context().get_enode(e));
return get_th_var(ctx.get_enode(e));
}
};