From 9c91698201948a17bc2ffa98f8f8a352f2d1f35b Mon Sep 17 00:00:00 2001 From: Nikolaj Bjorner Date: Sat, 4 Sep 2021 18:03:15 -0700 Subject: [PATCH] #5532 --- src/sat/smt/array_axioms.cpp | 4 ++-- src/sat/smt/array_diagnostics.cpp | 2 +- src/sat/smt/array_internalize.cpp | 9 +++++---- src/sat/smt/array_model.cpp | 2 +- src/sat/smt/array_solver.h | 3 ++- src/sat/smt/q_model_fixer.cpp | 8 ++++++++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/sat/smt/array_axioms.cpp b/src/sat/smt/array_axioms.cpp index c34b8ae1715..01db4a219ba 100644 --- a/src/sat/smt/array_axioms.cpp +++ b/src/sat/smt/array_axioms.cpp @@ -570,7 +570,7 @@ namespace array { expr* e2 = var2expr(v2); if (e1->get_sort() != e2->get_sort()) continue; - if (have_different_model_values(v1, v2)) + if (must_have_different_model_values(v1, v2)) continue; if (ctx.get_egraph().are_diseq(var2enode(v1), var2enode(v2))) continue; @@ -600,7 +600,7 @@ namespace array { r->mark1(); to_unmark.push_back(r); } - TRACE("array", tout << "collecting shared vars...\n" << unsigned_vector(roots.size(), (unsigned*)roots.data()) << "\n";); + TRACE("array", tout << "collecting shared vars...\n"; for (auto v : roots) tout << ctx.bpp(var2enode(v)) << "\n";); for (auto* n : to_unmark) n->unmark1(); } diff --git a/src/sat/smt/array_diagnostics.cpp b/src/sat/smt/array_diagnostics.cpp index f28cc47b428..c1230ea7f1f 100644 --- a/src/sat/smt/array_diagnostics.cpp +++ b/src/sat/smt/array_diagnostics.cpp @@ -24,7 +24,7 @@ namespace array { out << "array\n"; for (unsigned i = 0; i < get_num_vars(); ++i) { auto& d = get_var_data(i); - out << var2enode(i)->get_expr_id() << " " << (d.m_prop_upward?"up":"fx") << " " << mk_bounded_pp(var2expr(i), m, 2) << "\n"; + out << "v" << i << ": " << var2enode(i)->get_expr_id() << " " << (d.m_prop_upward?"up":"fx") << " " << mk_bounded_pp(var2expr(i), m, 2) << "\n"; display_info(out, "parent lambdas", d.m_parent_lambdas); display_info(out, "parent select", d.m_parent_selects); display_info(out, "lambdas", d.m_lambdas); diff --git a/src/sat/smt/array_internalize.cpp b/src/sat/smt/array_internalize.cpp index 55496a72960..7e3f94b8472 100644 --- a/src/sat/smt/array_internalize.cpp +++ b/src/sat/smt/array_internalize.cpp @@ -75,10 +75,11 @@ namespace array { } void solver::internalize_lambda(euf::enode* n) { - set_prop_upward(n); - if (!a.is_store(n->get_expr())) - push_axiom(default_axiom(n)); - add_lambda(n->get_th_var(get_id()), n); + SASSERT(is_lambda(n->get_expr()) || a.is_const(n->get_expr()) || a.is_as_array(n->get_expr())); + theory_var v = n->get_th_var(get_id()); + push_axiom(default_axiom(n)); + add_lambda(v, n); + set_prop_upward(v); } void solver::internalize_select(euf::enode* n) { diff --git a/src/sat/smt/array_model.cpp b/src/sat/smt/array_model.cpp index f8d16cc2502..1cdd27a1186 100644 --- a/src/sat/smt/array_model.cpp +++ b/src/sat/smt/array_model.cpp @@ -116,7 +116,7 @@ namespace array { } - bool solver::have_different_model_values(theory_var v1, theory_var v2) { + bool solver::must_have_different_model_values(theory_var v1, theory_var v2) { euf::enode* else1 = nullptr, * else2 = nullptr; euf::enode* n1 = var2enode(v1), *n2 = var2enode(v2); euf::enode* r1 = n1->get_root(), * r2 = n2->get_root(); diff --git a/src/sat/smt/array_solver.h b/src/sat/smt/array_solver.h index 06f58794976..20eaa037338 100644 --- a/src/sat/smt/array_solver.h +++ b/src/sat/smt/array_solver.h @@ -222,7 +222,7 @@ namespace array { euf::enode_vector m_defaults; // temporary field for model construction ptr_vector m_else_values; // svector m_parents; // temporary field for model construction - bool have_different_model_values(theory_var v1, theory_var v2); + bool must_have_different_model_values(theory_var v1, theory_var v2); void collect_defaults(); void mg_merge(theory_var u, theory_var v); theory_var mg_find(theory_var n); @@ -262,6 +262,7 @@ namespace array { euf::theory_var mk_var(euf::enode* n) override; void apply_sort_cnstr(euf::enode* n, sort* s) override; bool is_shared(theory_var v) const override; + bool enable_self_propagate() const override { return true; } void merge_eh(theory_var, theory_var, theory_var v1, theory_var v2); void after_merge_eh(theory_var r1, theory_var r2, theory_var v1, theory_var v2) {} diff --git a/src/sat/smt/q_model_fixer.cpp b/src/sat/smt/q_model_fixer.cpp index 41b6f31fb3b..f9e1d8ae20f 100644 --- a/src/sat/smt/q_model_fixer.cpp +++ b/src/sat/smt/q_model_fixer.cpp @@ -90,6 +90,14 @@ namespace q { univ.append(residue); add_projection_functions(mdl, univ); + for (unsigned i = mdl.get_num_functions(); i-- > 0; ) { + func_decl* f = mdl.get_function(i); + func_interp* fi = mdl.get_func_interp(f); + if (fi->is_partial()) + fi->set_else(fi->get_max_occ_result()); + if (fi->is_partial()) + fi->set_else(mdl.get_some_value(f->get_range())); + } TRACE("q", tout << "end: " << mdl << "\n";); }