mirror of
https://github.com/Z3Prover/z3
synced 2025-08-05 02:40:24 +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
|
@ -27,9 +27,9 @@ Revision History:
|
|||
|
||||
namespace smt {
|
||||
|
||||
theory_array_full::theory_array_full(ast_manager & m, theory_array_params & params) :
|
||||
theory_array(m, params),
|
||||
m_sort2epsilon(m) {}
|
||||
theory_array_full::theory_array_full(context& ctx) :
|
||||
theory_array(ctx),
|
||||
m_sort2epsilon(ctx.get_manager()) {}
|
||||
|
||||
theory_array_full::~theory_array_full() {
|
||||
std::for_each(m_var_data_full.begin(), m_var_data_full.end(), delete_proc<var_data_full>());
|
||||
|
@ -37,7 +37,7 @@ namespace smt {
|
|||
}
|
||||
|
||||
theory* theory_array_full::mk_fresh(context* new_ctx) {
|
||||
return alloc(theory_array_full, new_ctx->get_manager(), new_ctx->get_fparams());
|
||||
return alloc(theory_array_full, *new_ctx);
|
||||
}
|
||||
|
||||
void theory_array_full::add_map(theory_var v, enode* s) {
|
||||
|
@ -133,7 +133,7 @@ namespace smt {
|
|||
// call set_prop_upward on array arguments.
|
||||
//
|
||||
void theory_array_full::set_prop_upward(enode * n) {
|
||||
TRACE("array", tout << mk_pp(n->get_owner(), get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_pp(n->get_owner(), m) << "\n";);
|
||||
if (is_store(n)) {
|
||||
set_prop_upward(n->get_arg(0)->get_th_var(get_id()));
|
||||
}
|
||||
|
@ -246,11 +246,10 @@ namespace smt {
|
|||
}
|
||||
|
||||
bool theory_array_full::internalize_term(app * n) {
|
||||
context & ctx = get_context();
|
||||
if (ctx.e_internalized(n)) {
|
||||
return true;
|
||||
}
|
||||
TRACE("array", tout << mk_pp(n, get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_pp(n, m) << "\n";);
|
||||
|
||||
if (is_store(n) || is_select(n)) {
|
||||
return theory_array::internalize_term(n);
|
||||
|
@ -345,8 +344,8 @@ namespace smt {
|
|||
add_as_array(v1, n);
|
||||
}
|
||||
TRACE("array",
|
||||
tout << mk_pp(get_enode(v1)->get_owner(), get_manager()) << "\n";
|
||||
tout << mk_pp(get_enode(v2)->get_owner(), get_manager()) << "\n";
|
||||
tout << mk_pp(get_enode(v1)->get_owner(), m) << "\n";
|
||||
tout << mk_pp(get_enode(v2)->get_owner(), m) << "\n";
|
||||
tout << "merge in\n"; display_var(tout, v2);
|
||||
tout << "after merge\n"; display_var(tout, v1););
|
||||
}
|
||||
|
@ -355,7 +354,7 @@ namespace smt {
|
|||
SASSERT(v != null_theory_var);
|
||||
v = find(v);
|
||||
var_data* d = m_var_data[v];
|
||||
TRACE("array", tout << "v" << v << " " << mk_pp(get_enode(v)->get_owner(), get_manager()) << " "
|
||||
TRACE("array", tout << "v" << v << " " << mk_pp(get_enode(v)->get_owner(), m) << " "
|
||||
<< d->m_prop_upward << " " << m_params.m_array_delay_exp_axiom << "\n";);
|
||||
for (enode * store : d->m_stores) {
|
||||
SASSERT(is_store(store));
|
||||
|
@ -369,7 +368,7 @@ namespace smt {
|
|||
|
||||
void theory_array_full::add_parent_select(theory_var v, enode * s) {
|
||||
TRACE("array",
|
||||
tout << v << " select parent: " << mk_pp(s->get_owner(), get_manager()) << "\n";
|
||||
tout << v << " select parent: " << mk_pp(s->get_owner(), m) << "\n";
|
||||
display_var(tout, v);
|
||||
);
|
||||
theory_array::add_parent_select(v,s);
|
||||
|
@ -394,12 +393,11 @@ namespace smt {
|
|||
}
|
||||
|
||||
void theory_array_full::relevant_eh(app* n) {
|
||||
TRACE("array", tout << mk_pp(n, get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_pp(n, m) << "\n";);
|
||||
theory_array::relevant_eh(n);
|
||||
if (!is_default(n) && !is_select(n) && !is_map(n) && !is_const(n) && !is_as_array(n)){
|
||||
return;
|
||||
}
|
||||
context & ctx = get_context();
|
||||
if (!ctx.e_internalized(n)) ctx.internalize(n, false);;
|
||||
enode* node = ctx.get_enode(n);
|
||||
if (is_select(n)) {
|
||||
|
@ -455,8 +453,6 @@ namespace smt {
|
|||
SASSERT(map->get_num_args() > 0);
|
||||
func_decl* f = to_func_decl(map->get_decl()->get_parameter(0).get_ast());
|
||||
|
||||
context& ctx = get_context();
|
||||
ast_manager& m = get_manager();
|
||||
|
||||
TRACE("array_map_bug", tout << "invoked instantiate_select_map_axiom\n";
|
||||
tout << sl->get_owner_id() << " " << mp->get_owner_id() << "\n";
|
||||
|
@ -470,8 +466,8 @@ namespace smt {
|
|||
|
||||
m_stats.m_num_map_axiom++;
|
||||
TRACE("array",
|
||||
tout << mk_bounded_pp(mp->get_owner(), get_manager()) << "\n";
|
||||
tout << mk_bounded_pp(sl->get_owner(), get_manager()) << "\n";);
|
||||
tout << mk_bounded_pp(mp->get_owner(), m) << "\n";
|
||||
tout << mk_bounded_pp(sl->get_owner(), m) << "\n";);
|
||||
unsigned num_args = select->get_num_args();
|
||||
unsigned num_arrays = map->get_num_args();
|
||||
ptr_buffer<expr> args1, args2;
|
||||
|
@ -518,12 +514,10 @@ namespace smt {
|
|||
SASSERT(is_map(mp));
|
||||
|
||||
app* map = mp->get_owner();
|
||||
ast_manager& m = get_manager();
|
||||
context& ctx = get_context();
|
||||
if (!ctx.add_fingerprint(this, m_default_map_fingerprint, 1, &mp)) {
|
||||
return false;
|
||||
}
|
||||
TRACE("array", tout << mk_bounded_pp(map, get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_bounded_pp(map, m) << "\n";);
|
||||
|
||||
m_stats.m_num_default_map_axiom++;
|
||||
|
||||
|
@ -544,13 +538,12 @@ namespace smt {
|
|||
|
||||
|
||||
bool theory_array_full::instantiate_default_const_axiom(enode* cnst) {
|
||||
context& ctx = get_context();
|
||||
if (!ctx.add_fingerprint(this, m_default_const_fingerprint, 1, &cnst)) {
|
||||
return false;
|
||||
}
|
||||
m_stats.m_num_default_const_axiom++;
|
||||
SASSERT(is_const(cnst));
|
||||
TRACE("array", tout << mk_bounded_pp(cnst->get_owner(), get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_bounded_pp(cnst->get_owner(), m) << "\n";);
|
||||
expr* val = cnst->get_arg(0)->get_owner();
|
||||
expr* def = mk_default(cnst->get_owner());
|
||||
ctx.internalize(def, false);
|
||||
|
@ -565,20 +558,19 @@ namespace smt {
|
|||
bool theory_array_full::instantiate_default_as_array_axiom(enode* arr) {
|
||||
return false;
|
||||
#if 0
|
||||
context& ctx = get_context();
|
||||
if (!ctx.add_fingerprint(this, m_default_as_array_fingerprint, 1, &arr)) {
|
||||
return false;
|
||||
}
|
||||
m_stats.m_num_default_as_array_axiom++;
|
||||
SASSERT(is_as_array(arr));
|
||||
TRACE("array", tout << mk_bounded_pp(arr->get_owner(), get_manager()) << "\n";);
|
||||
TRACE("array", tout << mk_bounded_pp(arr->get_owner(), m) << "\n";);
|
||||
expr* def = mk_default(arr->get_owner());
|
||||
func_decl * f = array_util(get_manager()).get_as_array_func_decl(arr->get_owner());
|
||||
func_decl * f = array_util(m).get_as_array_func_decl(arr->get_owner());
|
||||
ptr_vector<expr> args;
|
||||
for (unsigned i = 0; i < f->get_arity(); ++i) {
|
||||
args.push_back(mk_epsilon(f->get_domain(i)));
|
||||
}
|
||||
expr_ref val(get_manager().mk_app(f, args.size(), args.c_ptr()), get_manager());
|
||||
expr_ref val(m.mk_app(f, args.size(), args.c_ptr()), m);
|
||||
ctx.internalize(def, false);
|
||||
ctx.internalize(val.get(), false);
|
||||
return try_assign_eq(val.get(), def);
|
||||
|
@ -587,7 +579,7 @@ namespace smt {
|
|||
|
||||
bool theory_array_full::has_large_domain(app* array_term) {
|
||||
SASSERT(is_array_sort(array_term));
|
||||
sort* s = get_manager().get_sort(array_term);
|
||||
sort* s = m.get_sort(array_term);
|
||||
unsigned dim = get_dimension(s);
|
||||
parameter const * params = s->get_info()->get_parameters();
|
||||
rational sz(1);
|
||||
|
@ -613,7 +605,6 @@ namespace smt {
|
|||
SASSERT(is_const(cnst));
|
||||
SASSERT(is_select(select));
|
||||
SASSERT(cnst->get_num_args() == 1);
|
||||
context& ctx = get_context();
|
||||
unsigned num_args = select->get_num_args();
|
||||
if (!ctx.add_fingerprint(cnst, cnst->get_owner_id(), select->get_num_args() - 1, select->get_args() + 1)) {
|
||||
return false;
|
||||
|
@ -628,10 +619,10 @@ namespace smt {
|
|||
expr * sel = mk_select(sel_args.size(), sel_args.c_ptr());
|
||||
expr * val = cnst->get_owner()->get_arg(0);
|
||||
TRACE("array", tout << "new select-const axiom...\n";
|
||||
tout << "const: " << mk_bounded_pp(cnst->get_owner(), get_manager()) << "\n";
|
||||
tout << "select: " << mk_bounded_pp(select->get_owner(), get_manager()) << "\n";
|
||||
tout << " sel/const: " << mk_bounded_pp(sel, get_manager()) << "\n";
|
||||
tout << "value: " << mk_bounded_pp(val, get_manager()) << "\n";
|
||||
tout << "const: " << mk_bounded_pp(cnst->get_owner(), m) << "\n";
|
||||
tout << "select: " << mk_bounded_pp(select->get_owner(), m) << "\n";
|
||||
tout << " sel/const: " << mk_bounded_pp(sel, m) << "\n";
|
||||
tout << "value: " << mk_bounded_pp(val, m) << "\n";
|
||||
tout << "#" << sel->get_id() << " = #" << val->get_id() << "\n";
|
||||
);
|
||||
|
||||
|
@ -648,7 +639,6 @@ namespace smt {
|
|||
SASSERT(is_as_array(arr->get_owner()));
|
||||
SASSERT(is_select(select));
|
||||
SASSERT(arr->get_num_args() == 0);
|
||||
context& ctx = get_context();
|
||||
unsigned num_args = select->get_num_args();
|
||||
if (!ctx.add_fingerprint(arr, arr->get_owner_id(), select->get_num_args() - 1, select->get_args() + 1)) {
|
||||
return false;
|
||||
|
@ -661,13 +651,13 @@ namespace smt {
|
|||
sel_args.push_back(select->get_owner()->get_arg(i));
|
||||
}
|
||||
expr * sel = mk_select(sel_args.size(), sel_args.c_ptr());
|
||||
func_decl * f = array_util(get_manager()).get_as_array_func_decl(arr->get_owner());
|
||||
expr_ref val(get_manager().mk_app(f, sel_args.size()-1, sel_args.c_ptr()+1), get_manager());
|
||||
func_decl * f = array_util(m).get_as_array_func_decl(arr->get_owner());
|
||||
expr_ref val(m.mk_app(f, sel_args.size()-1, sel_args.c_ptr()+1), m);
|
||||
TRACE("array", tout << "new select-as-array axiom...\n";
|
||||
tout << "as-array: " << mk_bounded_pp(arr->get_owner(), get_manager()) << "\n";
|
||||
tout << "select: " << mk_bounded_pp(select->get_owner(), get_manager()) << "\n";
|
||||
tout << " sel/as-array: " << mk_bounded_pp(sel, get_manager()) << "\n";
|
||||
tout << "value: " << mk_bounded_pp(val.get(), get_manager()) << "\n";
|
||||
tout << "as-array: " << mk_bounded_pp(arr->get_owner(), m) << "\n";
|
||||
tout << "select: " << mk_bounded_pp(select->get_owner(), m) << "\n";
|
||||
tout << " sel/as-array: " << mk_bounded_pp(sel, m) << "\n";
|
||||
tout << "value: " << mk_bounded_pp(val.get(), m) << "\n";
|
||||
tout << "#" << sel->get_id() << " = #" << val->get_id() << "\n";
|
||||
);
|
||||
|
||||
|
@ -681,8 +671,6 @@ namespace smt {
|
|||
SASSERT(is_store(store));
|
||||
SASSERT(store->get_num_args() >= 3);
|
||||
app* store_app = store->get_owner();
|
||||
context& ctx = get_context();
|
||||
ast_manager& m = get_manager();
|
||||
if (!ctx.add_fingerprint(this, m_default_store_fingerprint, store->get_num_args(), store->get_args())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -729,7 +717,7 @@ namespace smt {
|
|||
if (m_sort2epsilon.find(s, eps)) {
|
||||
return eps;
|
||||
}
|
||||
eps = get_manager().mk_fresh_const("epsilon", s);
|
||||
eps = m.mk_fresh_const("epsilon", s);
|
||||
m_trail_stack.push(
|
||||
ast2ast_trail<theory_array, sort, app>(m_sort2epsilon, s, eps));
|
||||
return eps;
|
||||
|
@ -756,7 +744,7 @@ namespace smt {
|
|||
while (!m_eqsv.empty()) {
|
||||
literal eq = m_eqsv.back();
|
||||
m_eqsv.pop_back();
|
||||
get_context().mark_as_relevant(eq);
|
||||
ctx.mark_as_relevant(eq);
|
||||
assert_axiom(eq);
|
||||
r = FC_CONTINUE;
|
||||
}
|
||||
|
@ -788,8 +776,8 @@ namespace smt {
|
|||
|
||||
bool theory_array_full::try_assign_eq(expr* v1, expr* v2) {
|
||||
TRACE("array",
|
||||
tout << mk_bounded_pp(v1, get_manager()) << "\n==\n"
|
||||
<< mk_bounded_pp(v2, get_manager()) << "\n";);
|
||||
tout << mk_bounded_pp(v1, m) << "\n==\n"
|
||||
<< mk_bounded_pp(v2, m) << "\n";);
|
||||
|
||||
if (m_eqs.contains(v1, v2)) {
|
||||
return false;
|
||||
|
@ -797,10 +785,10 @@ namespace smt {
|
|||
else {
|
||||
m_eqs.insert(v1, v2, true);
|
||||
literal eq(mk_eq(v1, v2, true));
|
||||
if (get_manager().has_trace_stream()) log_axiom_instantiation(get_context().bool_var2expr(eq.var()));
|
||||
get_context().mark_as_relevant(eq);
|
||||
if (m.has_trace_stream()) log_axiom_instantiation(ctx.bool_var2expr(eq.var()));
|
||||
ctx.mark_as_relevant(eq);
|
||||
assert_axiom(eq);
|
||||
if (get_manager().has_trace_stream()) get_manager().trace_stream() << "[end-of-instance]\n";
|
||||
if (m.has_trace_stream()) m.trace_stream() << "[end-of-instance]\n";
|
||||
|
||||
// m_eqsv.push_back(eq);
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue