3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-07-31 16:33:18 +00:00

fixup finite domain search

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2024-10-16 20:41:20 -07:00
parent 6143070157
commit 8ababafe42
2 changed files with 20 additions and 30 deletions

View file

@ -313,6 +313,7 @@ namespace sls {
// assign fresh values to uninterpeted nodes // assign fresh values to uninterpeted nodes
for (euf::enode* n : deps.top_sorted()) { for (euf::enode* n : deps.top_sorted()) {
TRACE("dt", tout << g->bpp(n) << "\n");
SASSERT(n->is_root()); SASSERT(n->is_root());
expr* e = n->get_expr(); expr* e = n->get_expr();
if (!dt.is_datatype(e)) if (!dt.is_datatype(e))
@ -321,24 +322,11 @@ namespace sls {
if (m_values.get(id, nullptr)) if (m_values.get(id, nullptr))
continue; continue;
auto con = get_constructor(n); auto con = get_constructor(n);
if (con) if (!con) {
continue; m_values.setx(id, m_model->get_fresh_value(e->get_sort()));
m_values.setx(id, m_model->get_fresh_value(e->get_sort())); TRACE("dt", tout << "Fresh interpretation " << g->bpp(n) << " <- " << mk_bounded_pp(m_values.get(id), m) << "\n");
TRACE("dt", tout << "Fresh interpretation " << g->bpp(n) << " <- " << mk_bounded_pp(m_values.get(id), m) << "\n");
}
// finally populate values to other nodes.
for (euf::enode* n : deps.top_sorted()) {
SASSERT(n->is_root());
unsigned id = n->get_id();
expr* e = n->get_expr();
if (!dt.is_datatype(e))
continue;
if (m_values.get(id))
continue;
euf::enode* con = get_constructor(n);
if (!con)
continue; continue;
}
auto f = con->get_decl(); auto f = con->get_decl();
args.reset(); args.reset();
for (auto arg : euf::enode_args(con)) { for (auto arg : euf::enode_args(con)) {
@ -388,12 +376,15 @@ namespace sls {
svector<color_t> color; svector<color_t> color;
unsigned_vector dfsnum; unsigned_vector dfsnum;
svector<std::tuple<unsigned, euf::enode*, unsigned>> todo; svector<std::tuple<unsigned, euf::enode*, unsigned>> todo;
obj_map<sort, ptr_vector<expr>> sorts;
for (auto n : g->nodes()) { for (auto n : g->nodes()) {
if (!n->is_root()) if (!n->is_root())
continue; continue;
expr* e = n->get_expr(); expr* e = n->get_expr();
if (!dt.is_datatype(e)) if (!dt.is_datatype(e))
continue; continue;
sort* s = e->get_sort();
sorts.insert_if_not_there(s, ptr_vector<expr>()).push_back(e);
auto c = color.get(e->get_id(), white); auto c = color.get(e->get_id(), white);
SASSERT(c != grey); SASSERT(c != grey);
@ -458,13 +449,14 @@ namespace sls {
} }
// for (auto const& [s, elems] : sorts) {
// sort_size sz = dt.et_datatype_size(s); auto sz = s->get_num_elements();
// if (sz.is_finite())
// - sz.size() < |T of sort s| if (!sz.is_finite() || sz.size() >= elems.size())
// - ensure that there are at most sz.size() distinct elements. continue;
// - not distinct(t1, ..., tn) where n = sz.size() + 1 ctx.add_constraint(m.mk_not(m.mk_distinct((unsigned)sz.size() + 1, elems.data())));
// }
return false; return false;
} }

View file

@ -433,14 +433,12 @@ namespace sls {
auto n = to_app(e)->get_num_args(); auto n = to_app(e)->get_num_args();
expr_ref_vector eqs(m); expr_ref_vector eqs(m);
for (unsigned i = 0; i < n; ++i) { for (unsigned i = 0; i < n; ++i) {
auto arg = to_app(e)->get_arg(i); auto a = m_g->find(to_app(e)->get_arg(i));
auto a = ctx.get_value(arg);
for (unsigned j = i + 1; j < n; ++j) { for (unsigned j = i + 1; j < n; ++j) {
auto argb = to_app(e)->get_arg(j); auto b = m_g->find(to_app(e)->get_arg(j));
auto b = ctx.get_value(argb); if (a->get_root() == b->get_root())
if (a == b)
goto done_distinct; goto done_distinct;
eqs.push_back(m.mk_eq(arg, argb)); eqs.push_back(m.mk_eq(a->get_expr(), b->get_expr()));
} }
} }
// distinct(a, b, c) or a = b or a = c or b = c // distinct(a, b, c) or a = b or a = c or b = c