3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-26 10:35:33 +00:00

more ematching

This commit is contained in:
Nikolaj Bjorner 2021-01-29 13:39:14 -08:00
parent 41a4d102f4
commit 4af9132f2e
12 changed files with 263 additions and 108 deletions

View file

@ -286,6 +286,10 @@ namespace euf {
m_updates.push_back(update_record(n, update_record::value_assignment()));
}
void egraph::set_lbl_hash(enode* n) {
NOT_IMPLEMENTED_YET();
}
void egraph::pop(unsigned num_scopes) {
if (num_scopes <= m_num_scopes) {
m_num_scopes -= num_scopes;
@ -654,6 +658,27 @@ namespace euf {
explain_todo(justifications);
}
template <typename T>
unsigned egraph::explain_diseq(ptr_vector<T>& justifications, enode* a, enode* b) {
enode* ra = a->get_root(), * rb = b->get_root();
SASSERT(ra != rb);
if (ra->interpreted() && rb->interpreted()) {
explain_eq(justifications, a, ra);
explain_eq(justifications, b, rb);
return UINT_MAX;
}
expr_ref eq(m.mk_eq(a->get_expr(), b->get_expr()), m);
m_tmp_eq->m_args[0] = a;
m_tmp_eq->m_args[1] = b;
m_tmp_eq->m_expr = eq;
SASSERT(m_tmp_eq->num_args() == 2);
enode* r = m_table.find(m_tmp_eq);
SASSERT(r && r->get_root()->value() == l_false);
explain_eq(justifications, r, r->get_root());
return r->get_root()->bool_var();
}
template <typename T>
void egraph::explain_todo(ptr_vector<T>& justifications) {
for (unsigned i = 0; i < m_todo.size(); ++i) {
@ -771,10 +796,12 @@ namespace euf {
template void euf::egraph::explain(ptr_vector<int>& justifications);
template void euf::egraph::explain_todo(ptr_vector<int>& justifications);
template void euf::egraph::explain_eq(ptr_vector<int>& justifications, enode* a, enode* b);
template unsigned euf::egraph::explain_diseq(ptr_vector<int>& justifications, enode* a, enode* b);
template void euf::egraph::explain(ptr_vector<size_t>& justifications);
template void euf::egraph::explain_todo(ptr_vector<size_t>& justifications);
template void euf::egraph::explain_eq(ptr_vector<size_t>& justifications, enode* a, enode* b);
template unsigned euf::egraph::explain_diseq(ptr_vector<size_t>& justifications, enode* a, enode* b);

View file

@ -267,6 +267,9 @@ namespace euf {
void next_literal() { force_push(); SASSERT(m_new_lits_qhead < m_new_lits.size()); m_new_lits_qhead++; }
void next_th_eq() { force_push(); SASSERT(m_new_th_eqs_qhead < m_new_th_eqs.size()); m_new_th_eqs_qhead++; }
void set_lbl_hash(enode* n);
void add_th_var(enode* n, theory_var v, theory_id id);
void set_th_propagates_diseqs(theory_id id);
void set_merge_enabled(enode* n, bool enable_merge);
@ -285,6 +288,8 @@ namespace euf {
void explain(ptr_vector<T>& justifications);
template <typename T>
void explain_eq(ptr_vector<T>& justifications, enode* a, enode* b);
template <typename T>
unsigned explain_diseq(ptr_vector<T>& justifications, enode* a, enode* b);
enode_vector const& nodes() const { return m_nodes; }
ast_manager& get_manager() { return m; }

View file

@ -205,9 +205,11 @@ namespace euf {
bool children_are_roots() const;
enode* get_next() const { return m_next; }
bool has_lbl_hash() const { UNREACHABLE(); return false; } // TODO
unsigned char get_lbl_hash() const { UNREACHABLE(); return 0; } // TOD0
void set_lbl_hash(egraph& e) { UNREACHABLE(); }
bool has_lbl_hash() const { return m_lbl_hash >= 0; }
unsigned char get_lbl_hash() const {
SASSERT(m_lbl_hash >= 0 && static_cast<unsigned>(m_lbl_hash) < approx_set_traits<unsigned long long>::capacity);
return static_cast<unsigned char>(m_lbl_hash);
}
approx_set & get_lbls() { return m_lbls; }
approx_set & get_plbls() { return m_plbls; }
const approx_set & get_lbls() const { return m_lbls; }