mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 03:27:52 +00:00
add EUF plugin framework.
plugin setting allows adding equality saturation within the E-graph propagation without involving externalizing theory solver dispatch. It makes equality saturation independent of SAT integration. Add a special relation operator to support ad-hoc AC symbols.
This commit is contained in:
parent
5784c2da79
commit
b52fd8d954
28 changed files with 3063 additions and 68 deletions
71
src/ast/euf/euf_arith_plugin.cpp
Normal file
71
src/ast/euf/euf_arith_plugin.cpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*++
|
||||
Copyright (c) 2023 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
euf_arith_plugin.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
plugin structure for arithetic
|
||||
|
||||
Author:
|
||||
|
||||
Nikolaj Bjorner (nbjorner) 2023-11-11
|
||||
|
||||
--*/
|
||||
|
||||
#include "ast/euf/euf_arith_plugin.h"
|
||||
#include "ast/euf/euf_egraph.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace euf {
|
||||
|
||||
arith_plugin::arith_plugin(egraph& g) :
|
||||
plugin(g),
|
||||
a(g.get_manager()),
|
||||
m_add(g, get_id(), OP_ADD),
|
||||
m_mul(g, get_id(), OP_MUL) {
|
||||
std::function<void(void)> uadd = [&]() { m_undo.push_back(undo_t::undo_add); };
|
||||
m_add.set_undo(uadd);
|
||||
std::function<void(void)> umul = [&]() { m_undo.push_back(undo_t::undo_mul); };
|
||||
m_mul.set_undo(umul);
|
||||
}
|
||||
|
||||
void arith_plugin::register_node(enode* n) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
void arith_plugin::merge_eh(enode* n1, enode* n2) {
|
||||
m_add.merge_eh(n1, n2);
|
||||
m_mul.merge_eh(n1, n2);
|
||||
}
|
||||
|
||||
void arith_plugin::propagate() {
|
||||
m_add.propagate();
|
||||
m_mul.propagate();
|
||||
}
|
||||
|
||||
void arith_plugin::undo() {
|
||||
auto k = m_undo.back();
|
||||
m_undo.pop_back();
|
||||
switch (k) {
|
||||
case undo_t::undo_add:
|
||||
m_add.undo();
|
||||
break;
|
||||
case undo_t::undo_mul:
|
||||
m_mul.undo();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& arith_plugin::display(std::ostream& out) const {
|
||||
out << "add\n";
|
||||
m_add.display(out);
|
||||
out << "mul\n";
|
||||
m_mul.display(out);
|
||||
return out;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue