mirror of
https://github.com/Z3Prover/z3
synced 2025-06-29 09:28:45 +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:
parent
17b8db95c1
commit
becf423c77
57 changed files with 750 additions and 1257 deletions
|
@ -24,12 +24,14 @@ Revision History:
|
|||
|
||||
namespace smt {
|
||||
|
||||
theory_array::theory_array(ast_manager & m, theory_array_params & params):
|
||||
theory_array_base(m),
|
||||
m_params(params),
|
||||
theory_array::theory_array(context& ctx):
|
||||
theory_array_base(ctx),
|
||||
m_params(ctx.get_fparams()),
|
||||
m_find(*this),
|
||||
m_trail_stack(*this),
|
||||
m_final_check_idx(0) {
|
||||
if (!ctx.relevancy())
|
||||
m_params.m_array_laziness = 0;
|
||||
}
|
||||
|
||||
theory_array::~theory_array() {
|
||||
|
@ -37,17 +39,11 @@ namespace smt {
|
|||
m_var_data.reset();
|
||||
}
|
||||
|
||||
void theory_array::init(context * ctx) {
|
||||
theory_array_base::init(ctx);
|
||||
if (!ctx->relevancy())
|
||||
m_params.m_array_laziness = 0;
|
||||
}
|
||||
|
||||
void theory_array::merge_eh(theory_var v1, theory_var v2, theory_var, theory_var) {
|
||||
// v1 is the new root
|
||||
TRACE("array",
|
||||
tout << "merging v" << v1 << " v" << v2 << "\n"; display_var(tout, v1);
|
||||
tout << mk_pp(get_enode(v1)->get_owner(), get_manager()) << " <- " << mk_pp(get_enode(v2)->get_owner(), get_manager()) << "\n";);
|
||||
tout << mk_pp(get_enode(v1)->get_owner(), m) << " <- " << mk_pp(get_enode(v2)->get_owner(), m) << "\n";);
|
||||
SASSERT(v1 == find(v1));
|
||||
var_data * d1 = m_var_data[v1];
|
||||
var_data * d2 = m_var_data[v2];
|
||||
|
@ -67,8 +63,6 @@ namespace smt {
|
|||
}
|
||||
|
||||
theory_var theory_array::mk_var(enode * n) {
|
||||
ast_manager& m = get_manager();
|
||||
context& ctx = get_context();
|
||||
theory_var r = theory_array_base::mk_var(n);
|
||||
VERIFY(r == static_cast<theory_var>(m_find.mk_var()));
|
||||
SASSERT(r == static_cast<int>(m_var_data.size()));
|
||||
|
@ -95,7 +89,7 @@ namespace smt {
|
|||
v = find(v);
|
||||
var_data * d = m_var_data[v];
|
||||
d->m_parent_selects.push_back(s);
|
||||
TRACE("array", tout << v << " " << mk_pp(s->get_owner(), get_manager()) << " " << mk_pp(get_enode(v)->get_owner(), get_manager()) << "\n";);
|
||||
TRACE("array", tout << v << " " << mk_pp(s->get_owner(), m) << " " << mk_pp(get_enode(v)->get_owner(), m) << "\n";);
|
||||
m_trail_stack.push(push_back_trail<theory_array, enode *, false>(d->m_parent_selects));
|
||||
for (enode* n : d->m_stores) {
|
||||
instantiate_axiom2a(s, n);
|
||||
|
@ -202,7 +196,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
void theory_array::instantiate_axiom1(enode * store) {
|
||||
TRACE("array", tout << "axiom 1:\n" << mk_bounded_pp(store->get_owner(), get_manager()) << "\n";);
|
||||
TRACE("array", tout << "axiom 1:\n" << mk_bounded_pp(store->get_owner(), m) << "\n";);
|
||||
SASSERT(is_store(store));
|
||||
m_stats.m_num_axiom1++;
|
||||
assert_store_axiom1(store);
|
||||
|
@ -244,8 +238,7 @@ namespace smt {
|
|||
// Internalize the term. If it has already been internalized, return false.
|
||||
//
|
||||
bool theory_array::internalize_term_core(app * n) {
|
||||
TRACE("array_bug", tout << mk_bounded_pp(n, get_manager()) << "\n";);
|
||||
context & ctx = get_context();
|
||||
TRACE("array_bug", tout << mk_bounded_pp(n, m) << "\n";);
|
||||
unsigned num_args = n->get_num_args();
|
||||
for (unsigned i = 0; i < num_args; i++)
|
||||
ctx.internalize(n->get_arg(i), false);
|
||||
|
@ -256,7 +249,7 @@ namespace smt {
|
|||
if (!is_attached_to_var(e))
|
||||
mk_var(e);
|
||||
|
||||
if (get_manager().is_bool(n)) {
|
||||
if (m.is_bool(n)) {
|
||||
bool_var bv = ctx.mk_bool_var(n);
|
||||
ctx.set_var_theory(bv, get_id());
|
||||
ctx.set_enode_flag(bv, true);
|
||||
|
@ -270,11 +263,10 @@ namespace smt {
|
|||
found_unsupported_op(n);
|
||||
return false;
|
||||
}
|
||||
TRACE("array_bug", tout << mk_bounded_pp(n, get_manager()) << "\n";);
|
||||
TRACE("array_bug", tout << mk_bounded_pp(n, m) << "\n";);
|
||||
if (!internalize_term_core(n)) {
|
||||
return true;
|
||||
}
|
||||
context & ctx = get_context();
|
||||
enode * arg0 = ctx.get_enode(n->get_arg(0));
|
||||
if (!is_attached_to_var(arg0))
|
||||
mk_var(arg0);
|
||||
|
@ -315,8 +307,8 @@ namespace smt {
|
|||
v2 = find(v2);
|
||||
var_data * d1 = m_var_data[v1];
|
||||
TRACE("ext", tout << "extensionality: " << d1->m_is_array << "\n"
|
||||
<< mk_bounded_pp(get_enode(v1)->get_owner(), get_manager(), 5) << "\n"
|
||||
<< mk_bounded_pp(get_enode(v2)->get_owner(), get_manager(), 5) << "\n";);
|
||||
<< mk_bounded_pp(get_enode(v1)->get_owner(), m, 5) << "\n"
|
||||
<< mk_bounded_pp(get_enode(v2)->get_owner(), m, 5) << "\n";);
|
||||
|
||||
if (d1->m_is_array) {
|
||||
SASSERT(m_var_data[v2]->m_is_array);
|
||||
|
@ -327,12 +319,11 @@ namespace smt {
|
|||
void theory_array::relevant_eh(app * n) {
|
||||
if (m_params.m_array_laziness == 0)
|
||||
return;
|
||||
if (get_manager().is_ite(n)) {
|
||||
TRACE("array", tout << "relevant ite " << mk_pp(n, get_manager()) << "\n";);
|
||||
if (m.is_ite(n)) {
|
||||
TRACE("array", tout << "relevant ite " << mk_pp(n, m) << "\n";);
|
||||
}
|
||||
if (!is_store(n) && !is_select(n))
|
||||
return;
|
||||
context & ctx = get_context();
|
||||
if (!ctx.e_internalized(n)) ctx.internalize(n, false);
|
||||
enode * arg = ctx.get_enode(n->get_arg(0));
|
||||
theory_var v_arg = arg->get_th_var(get_id());
|
||||
|
@ -399,7 +390,7 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
bool should_giveup = m_found_unsupported_op || has_propagate_up_trail();
|
||||
if (r == FC_DONE && should_giveup && !get_context().get_fparams().m_array_fake_support)
|
||||
if (r == FC_DONE && should_giveup && !ctx.get_fparams().m_array_fake_support)
|
||||
r = FC_GIVEUP;
|
||||
CTRACE("array", r != FC_DONE || m_found_unsupported_op, tout << r << "\n";);
|
||||
return r;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue