3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 20:05:51 +00:00

fixes to dt_solver and related

This commit is contained in:
Nikolaj Bjorner 2021-02-27 11:03:20 -08:00
parent f7b1469462
commit 830f314a3f
20 changed files with 250 additions and 187 deletions

View file

@ -229,7 +229,9 @@ namespace euf {
return sat::constraint_base::obj_size(sizeof(th_propagation) + sizeof(sat::literal) * num_lits + sizeof(enode_pair) * num_eqs);
}
th_propagation::th_propagation(unsigned n_lits, sat::literal const* lits, unsigned n_eqs, enode_pair const* eqs) {
th_propagation::th_propagation(unsigned n_lits, sat::literal const* lits, unsigned n_eqs, enode_pair const* eqs, sat::literal c, enode_pair const& p) {
m_consequent = c;
m_eq = p;
m_num_literals = n_lits;
m_num_eqs = n_eqs;
m_literals = reinterpret_cast<literal*>(reinterpret_cast<char*>(this) + sizeof(th_propagation));
@ -237,36 +239,53 @@ namespace euf {
m_literals[i] = lits[i];
m_eqs = reinterpret_cast<enode_pair*>(reinterpret_cast<char*>(this) + sizeof(th_propagation) + sizeof(literal) * n_lits);
for (unsigned i = 0; i < n_eqs; ++i)
m_eqs[i] = eqs[i];
m_eqs[i] = eqs[i];
}
th_propagation* th_propagation::mk(th_euf_solver& th, sat::literal_vector const& lits, enode_pair_vector const& eqs) {
return mk(th, lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr());
}
th_propagation* th_propagation::mk(th_euf_solver& th, unsigned n_lits, sat::literal const* lits, unsigned n_eqs, enode_pair const* eqs) {
th_propagation* th_propagation::mk(th_euf_solver& th, unsigned n_lits, sat::literal const* lits, unsigned n_eqs, enode_pair const* eqs, sat::literal c, enode* x, enode* y) {
region& r = th.ctx.get_region();
void* mem = r.allocate(get_obj_size(n_lits, n_eqs));
sat::constraint_base::initialize(mem, &th);
return new (sat::constraint_base::ptr2mem(mem)) th_propagation(n_lits, lits, n_eqs, eqs);
return new (sat::constraint_base::ptr2mem(mem)) th_propagation(n_lits, lits, n_eqs, eqs, c, enode_pair(x, y));
}
th_propagation* th_propagation::mk(th_euf_solver& th, enode_pair_vector const& eqs) {
return mk(th, 0, nullptr, eqs.size(), eqs.c_ptr());
th_propagation* th_propagation::propagate(th_euf_solver& th, sat::literal_vector const& lits, enode_pair_vector const& eqs, sat::literal consequent) {
return mk(th, lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), consequent, nullptr, nullptr);
}
th_propagation* th_propagation::mk(th_euf_solver& th, sat::literal lit) {
return mk(th, 1, &lit, 0, nullptr);
th_propagation* th_propagation::propagate(th_euf_solver& th, sat::literal_vector const& lits, enode_pair_vector const& eqs, euf::enode* x, euf::enode* y) {
return mk(th, lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr(), sat::null_literal, x, y);
}
th_propagation* th_propagation::mk(th_euf_solver& th, sat::literal lit, euf::enode* x, euf::enode* y) {
th_propagation* th_propagation::propagate(th_euf_solver& th, sat::literal lit, euf::enode* x, euf::enode* y) {
return mk(th, 1, &lit, 0, nullptr, sat::null_literal, x, y);
}
th_propagation* th_propagation::conflict(th_euf_solver& th, sat::literal_vector const& lits, enode_pair_vector const& eqs) {
return conflict(th, lits.size(), lits.c_ptr(), eqs.size(), eqs.c_ptr());
}
th_propagation* th_propagation::conflict(th_euf_solver& th, unsigned n_lits, sat::literal const* lits, unsigned n_eqs, enode_pair const* eqs) {
return mk(th, n_lits, lits, n_eqs, eqs, sat::null_literal, nullptr, nullptr);
}
th_propagation* th_propagation::conflict(th_euf_solver& th, enode_pair_vector const& eqs) {
return conflict(th, 0, nullptr, eqs.size(), eqs.c_ptr());
}
th_propagation* th_propagation::conflict(th_euf_solver& th, sat::literal lit) {
return conflict(th, 1, &lit, 0, nullptr);
}
th_propagation* th_propagation::conflict(th_euf_solver& th, sat::literal lit, euf::enode* x, euf::enode* y) {
enode_pair eq(x, y);
return mk(th, 1, &lit, 1, &eq);
return conflict(th, 1, &lit, 1, &eq);
}
th_propagation* th_propagation::mk(th_euf_solver& th, euf::enode* x, euf::enode* y) {
th_propagation* th_propagation::conflict(th_euf_solver& th, euf::enode* x, euf::enode* y) {
enode_pair eq(x, y);
return mk(th, 0, nullptr, 1, &eq);
return conflict(th, 0, nullptr, 1, &eq);
}
std::ostream& th_propagation::display(std::ostream& out) const {
@ -274,6 +293,10 @@ namespace euf {
out << lit << " ";
for (auto eq : euf::th_propagation::eqs(*this))
out << eq.first->get_expr_id() << " == " << eq.second->get_expr_id() << " ";
if (m_consequent != sat::null_literal)
out << "--> " << m_consequent;
if (m_eq.first != nullptr)
out << "--> " << m_eq.first->get_expr_id() << " == " << m_eq.second->get_expr_id();
return out;
}