3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-22 16:45:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2023-11-20 15:54:00 -08:00
parent cbefe74219
commit 6a572543b4
2 changed files with 26 additions and 2 deletions

View file

@ -254,7 +254,7 @@ namespace euf {
sort(ml);
sort(mr);
for (unsigned i = ml.size(); i-- > 0;) {
if (ml[i] == mr[i])
if (ml[i]->root_id() == mr[i]->root_id())
continue;
if (ml[i]->root_id() < mr[i]->root_id())
std::swap(e.l, e.r);
@ -480,7 +480,7 @@ namespace euf {
bool has_two = false;
for (auto n : m)
if (n->root->eqs.size() > max_use)
max_n = n->root, max_use = n->root->eqs.size(), has_two |= max_n != nullptr;
has_two |= max_n && (max_n != n->root), max_n = n->root, max_use = n->root->eqs.size();
m_eq_occurs.reset();
for (auto n : m)
if (n->root != max_n && has_two)

View file

@ -45,9 +45,33 @@ static void test1() {
std::cout << g << "\n";
}
static void test2() {
ast_manager m;
reg_decl_plugins(m);
euf::egraph g(m);
g.add_plugins();
arith_util a(m);
sort_ref I(a.mk_int(), m);
expr_ref x(m.mk_const("x", I), m);
expr_ref y(m.mk_const("y", I), m);
auto* nx = get_node(g, a.mk_add(x, y));
auto* ny = get_node(g, a.mk_add(y, x));
TRACE("plugin", tout << "before merge\n" << g << "\n");
g.merge(nx, get_node(g, x), nullptr);
g.merge(ny, get_node(g, y), nullptr);
TRACE("plugin", tout << "before propagate\n" << g << "\n");
g.propagate();
TRACE("plugin", tout << "after propagate\n" << g << "\n");
SASSERT(get_node(g, x)->get_root() == get_node(g, y)->get_root());
g.merge(get_node(g, a.mk_add(x, a.mk_add(y, y))), get_node(g, a.mk_add(y, x)), nullptr);
g.propagate();
std::cout << g << "\n";
}
void tst_euf_arith_plugin() {
enable_trace("plugin");
test1();
test2();
}