3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-27 10:55:50 +00:00

model refactor (#4723)

* refactor model fixing

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* missing cond macro

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* file

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* file

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add macros dependency

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* deps and debug

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* add dependency to normal forms

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* na

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* build issues

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* compile

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* fix leal regression

* complete model fixer

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* fold back private functionality to model_finder

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>

* avoid duplicate fixed callbacks

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2020-10-05 14:13:05 -07:00 committed by GitHub
parent 6cc52e04c3
commit fa58a36b9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 2060 additions and 1494 deletions

View file

@ -107,6 +107,11 @@ namespace euf {
enode* n = enode::mk(m_region, f, num_args, args);
m_nodes.push_back(n);
m_exprs.push_back(f);
if (is_app(f) && num_args > 0) {
unsigned id = to_app(f)->get_decl()->get_decl_id();
m_decl2enodes.reserve(id+1);
m_decl2enodes[id].push_back(n);
}
m_expr2enode.setx(f->get_id(), n, nullptr);
push_node(n);
for (unsigned i = 0; i < num_args; ++i)
@ -114,9 +119,15 @@ namespace euf {
return n;
}
enode_vector const& egraph::enodes_of(func_decl* f) {
unsigned id = f->get_decl_id();
if (id < m_decl2enodes.size())
return m_decl2enodes[id];
return m_empty_enodes;
}
enode_bool_pair egraph::insert_table(enode* p) {
auto rc = m_table.insert(p);
enode* p_other = rc.first;
p->m_cg = rc.first;
return rc;
}
@ -338,6 +349,8 @@ namespace euf {
m_expr2enode[e->get_id()] = nullptr;
n->~enode();
if (is_app(e) && n->num_args() > 0)
m_decl2enodes[to_app(e)->get_decl()->get_decl_id()].pop_back();
m_nodes.pop_back();
m_exprs.pop_back();
};

View file

@ -141,7 +141,7 @@ namespace euf {
tag(tag_t::is_value_assignment), r1(n), n1(nullptr), qhead(0) {}
};
ast_manager& m;
svector<to_merge> m_to_merge;
svector<to_merge> m_to_merge;
etable m_table;
region m_region;
svector<update_record> m_updates;
@ -150,6 +150,8 @@ namespace euf {
enode* m_tmp_eq { nullptr };
enode_vector m_nodes;
expr_ref_vector m_exprs;
vector<enode_vector> m_decl2enodes;
enode_vector m_empty_enodes;
unsigned m_num_scopes { 0 };
bool m_inconsistent { false };
enode *m_n1 { nullptr };
@ -214,6 +216,7 @@ namespace euf {
~egraph();
enode* find(expr* f) { return m_expr2enode.get(f->get_id(), nullptr); }
enode* mk(expr* f, unsigned n, enode *const* args);
enode_vector const& enodes_of(func_decl* f);
void push() { ++m_num_scopes; }
void pop(unsigned num_scopes);

View file

@ -22,7 +22,7 @@ namespace euf {
// one table per func_decl implementation
unsigned etable::cg_hash::operator()(enode * n) const {
SASSERT(decl(n)->is_flat_associative() || n->num_args() >= 3);
SASSERT(n->get_decl()->is_flat_associative() || n->num_args() >= 3);
unsigned a, b, c;
a = b = 0x9e3779b9;
c = 11;
@ -50,7 +50,7 @@ namespace euf {
}
bool etable::cg_eq::operator()(enode * n1, enode * n2) const {
SASSERT(decl(n1) == decl(n2));
SASSERT(n1->get_decl() == n2->get_decl());
unsigned num = n1->num_args();
if (num != n2->num_args()) {
return false;
@ -96,7 +96,7 @@ namespace euf {
}
unsigned etable::set_table_id(enode * n) {
func_decl * f = decl(n);
func_decl * f = n->get_decl();
unsigned tid;
decl_info d(f, n->num_args());
if (!m_func_decl2id.find(d, tid)) {

View file

@ -24,8 +24,6 @@ namespace euf {
// one table per function symbol
static func_decl* decl(enode* n) { return n->get_decl(); }
/**
\brief Congruence table.
@ -45,7 +43,7 @@ namespace euf {
bool operator()(enode * n1, enode * n2) const {
SASSERT(n1->num_args() == 1);
SASSERT(n2->num_args() == 1);
SASSERT(decl(n1) == decl(n2));
SASSERT(n1->get_decl() == n2->get_decl());
return get_root(n1, 0) == get_root(n2, 0);
}
};
@ -63,7 +61,7 @@ namespace euf {
bool operator()(enode * n1, enode * n2) const {
SASSERT(n1->num_args() == 2);
SASSERT(n2->num_args() == 2);
SASSERT(decl(n1) == decl(n2));
SASSERT(n1->get_decl() == n2->get_decl());
return
get_root(n1, 0) == get_root(n2, 0) &&
get_root(n1, 1) == get_root(n2, 1);
@ -90,7 +88,7 @@ namespace euf {
SASSERT(n1->num_args() == 2);
SASSERT(n2->num_args() == 2);
SASSERT(decl(n1) == decl(n2));
SASSERT(n1->get_decl() == n2->get_decl());
enode* c1_1 = get_root(n1, 0);
enode* c1_2 = get_root(n1, 1);
enode* c2_1 = get_root(n2, 0);