mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 17:45:32 +00:00
Refactor handling of term registration and enhance distinct handling in sls_euf_plugin
This commit is contained in:
parent
633ea63a62
commit
c9bd8d59ac
2 changed files with 30 additions and 2 deletions
|
@ -446,6 +446,7 @@ namespace sls {
|
|||
auto visit = [&](expr* e) {
|
||||
m_allterms.setx(e->get_id(), e);
|
||||
ensure_plugin(e);
|
||||
register_term(e);
|
||||
};
|
||||
if (is_visited(e))
|
||||
return;
|
||||
|
@ -468,7 +469,6 @@ namespace sls {
|
|||
}
|
||||
if (m.is_bool(e))
|
||||
mk_literal(e);
|
||||
register_term(e);
|
||||
visit(e);
|
||||
}
|
||||
else {
|
||||
|
@ -479,7 +479,6 @@ namespace sls {
|
|||
else {
|
||||
expr_ref _e(e, m);
|
||||
m_todo.pop_back();
|
||||
register_term(e);
|
||||
visit(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -227,8 +227,37 @@ namespace sls {
|
|||
}
|
||||
else
|
||||
m_values.insert(t);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto lit : ctx.root_literals()) {
|
||||
if (!ctx.is_true(lit))
|
||||
lit.neg();
|
||||
auto e = ctx.atom(lit.var());
|
||||
if (lit.sign() && e && m.is_distinct(e)) {
|
||||
auto n = to_app(e)->get_num_args();
|
||||
expr_ref_vector eqs(m);
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
auto arg = to_app(e)->get_arg(i);
|
||||
auto a = ctx.get_value(arg);
|
||||
for (unsigned j = i + 1; j < n; ++j) {
|
||||
auto argb = to_app(e)->get_arg(j);
|
||||
auto b = ctx.get_value(argb);
|
||||
if (a == b)
|
||||
goto done_distinct;
|
||||
eqs.push_back(m.mk_eq(arg, argb));
|
||||
}
|
||||
}
|
||||
// distinct(a, b, c) or a = b or a = c or b = c
|
||||
eqs.push_back(e);
|
||||
ctx.add_constraint(m.mk_or(eqs));
|
||||
new_constraint = true;
|
||||
done_distinct:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return new_constraint;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue