3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-28 10:51:28 +00:00

update for equivalences

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-07-28 10:30:23 -07:00
parent 6dbfdf3e9c
commit b2b2c636f8
5 changed files with 68 additions and 8 deletions

View file

@ -1739,6 +1739,25 @@ namespace sat {
SASSERT(validate_unit_propagation(p, r, l));
}
bool ba_solver::is_extended_binary(ext_justification_idx idx, literal_vector & r) {
constraint const& c = index2constraint(idx);
switch (c.tag()) {
case card_t: {
card const& ca = c.to_card();
if (ca.size() == ca.k() + 1 && ca.lit() == null_literal) {
r.reset();
for (literal l : ca) r.push_back(l);
return true;
}
else {
return false;
}
}
default:
return false;
}
}
void ba_solver::simplify(xor& x) {
// no-op
}
@ -2004,17 +2023,39 @@ namespace sat {
/**
\brief Lex on (glue, size)
*/
struct constraint_glue_lt {
struct constraint_glue_psm_lt {
bool operator()(ba_solver::constraint const * c1, ba_solver::constraint const * c2) const {
return
(c1->glue() < c2->glue()) ||
(c1->glue() == c2->glue() && c1->size() < c2->size());
(c1->glue() == c2->glue() &&
(c1->psm() < c2->psm() ||
(c1->psm() == c2->psm() && c1->size() < c2->size())));
}
};
void ba_solver::update_psm(constraint& c) const {
unsigned r = 0;
switch (c.tag()) {
case card_t:
for (literal l : c.to_card()) {
if (s().m_phase[l.var()] == (l.sign() ? NEG_PHASE : POS_PHASE)) ++r;
}
break;
case pb_t:
for (wliteral l : c.to_pb()) {
if (s().m_phase[l.second.var()] == (l.second.sign() ? NEG_PHASE : POS_PHASE)) ++r;
}
break;
default:
break;
}
c.set_psm(r);
}
void ba_solver::gc() {
std::stable_sort(m_learned.begin(), m_learned.end(), constraint_glue_lt());
gc_half("glue");
for (auto & c : m_learned) update_psm(*c);
std::stable_sort(m_learned.begin(), m_learned.end(), constraint_glue_psm_lt());
gc_half("glue-psm");
cleanup_constraints(m_learned, true);
}