mirror of
https://github.com/Z3Prover/z3
synced 2025-07-20 03:12:03 +00:00
fixing cce
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9f9ae4427d
commit
00a401260e
1 changed files with 46 additions and 44 deletions
|
@ -971,16 +971,16 @@ namespace sat {
|
||||||
// Resolve intersection
|
// Resolve intersection
|
||||||
// Find literals that are in the intersection of all resolvents with l.
|
// Find literals that are in the intersection of all resolvents with l.
|
||||||
//
|
//
|
||||||
void ri(literal l, literal_vector& inter) {
|
bool ri(literal l, literal_vector& inter) {
|
||||||
if (!process_var(l.var())) return;
|
if (!process_var(l.var())) return false;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (watched & w : s.get_wlist(~l)) {
|
for (watched & w : s.get_wlist(l)) {
|
||||||
if (w.is_binary_non_learned_clause()) {
|
if (w.is_binary_non_learned_clause()) {
|
||||||
literal lit = w.get_literal();
|
literal lit = w.get_literal();
|
||||||
if (s.is_marked(~lit)) continue;
|
if (s.is_marked(~lit) && lit != ~l) continue;
|
||||||
if (!first) {
|
if (!first) {
|
||||||
inter.reset();
|
inter.reset();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
inter.push_back(lit);
|
inter.push_back(lit);
|
||||||
|
@ -992,7 +992,7 @@ namespace sat {
|
||||||
bool tautology = false;
|
bool tautology = false;
|
||||||
clause & c = it.curr();
|
clause & c = it.curr();
|
||||||
for (literal lit : c) {
|
for (literal lit : c) {
|
||||||
if (s.is_marked(~lit)) {
|
if (s.is_marked(~lit) && lit != ~l) {
|
||||||
tautology = true;
|
tautology = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1017,56 +1017,58 @@ namespace sat {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inter.shrink(j);
|
inter.shrink(j);
|
||||||
if (j == 0) return;
|
if (j == 0) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it.next();
|
it.next();
|
||||||
}
|
}
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
literal_vector m_added;
|
||||||
|
literal_vector m_intersection;
|
||||||
|
|
||||||
|
bool cla(literal lit) {
|
||||||
|
bool is_tautology = false;
|
||||||
|
for (literal l : m_added) s.mark_visited(l);
|
||||||
|
unsigned num_iterations = 0, sz;
|
||||||
|
do {
|
||||||
|
++num_iterations;
|
||||||
|
sz = m_added.size();
|
||||||
|
for (unsigned i = 0; i < m_added.size(); ++i) {
|
||||||
|
if (ri(m_added[i], m_intersection) && m_added[i] == lit) {
|
||||||
|
is_tautology = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (literal l : m_intersection) {
|
||||||
|
if (!s.is_marked(l)) {
|
||||||
|
s.mark_visited(l);
|
||||||
|
m_added.push_back(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_intersection.reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (m_added.size() > sz && !is_tautology);
|
||||||
|
for (literal l : m_added) s.unmark_visited(l);
|
||||||
|
m_intersection.reset();
|
||||||
|
m_added.reset();
|
||||||
|
if (is_tautology) std::cout << "taut: " << num_iterations << "\n";
|
||||||
|
return is_tautology;
|
||||||
}
|
}
|
||||||
|
|
||||||
// perform covered clause elimination.
|
// perform covered clause elimination.
|
||||||
// first extract the covered literal addition (CLA).
|
// first extract the covered literal addition (CLA).
|
||||||
// then check whether the CLA is blocked.
|
// then check whether the CLA is blocked.
|
||||||
bool cce(clause& c, literal lit) {
|
bool cce(clause& c, literal lit) {
|
||||||
for (literal l : c) s.mark_visited(l);
|
for (literal l : c) m_added.push_back(l);
|
||||||
literal_vector added, lits;
|
return cla(lit);
|
||||||
for (literal l : c) added.push_back(l);
|
|
||||||
for (unsigned i = 0; i < added.size(); ++i) {
|
|
||||||
ri(added[i], lits);
|
|
||||||
for (literal l : lits) {
|
|
||||||
if (!s.is_marked(l)) {
|
|
||||||
s.mark_visited(l);
|
|
||||||
added.push_back(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lits.reset();
|
|
||||||
}
|
|
||||||
s.unmark_visited(lit);
|
|
||||||
bool is_tautology = (added.size() > c.size()) && all_tautology(lit);
|
|
||||||
for (literal l : added) s.unmark_visited(l);
|
|
||||||
return is_tautology;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cce(literal lit, literal l2) {
|
bool cce(literal lit, literal l2) {
|
||||||
literal_vector added, lits;
|
m_added.push_back(lit);
|
||||||
s.mark_visited(lit);
|
m_added.push_back(l2);
|
||||||
s.mark_visited(l2);
|
return cla(lit);
|
||||||
added.push_back(lit);
|
|
||||||
added.push_back(l2);
|
|
||||||
for (unsigned i = 0; i < added.size(); ++i) {
|
|
||||||
ri(added[i], lits);
|
|
||||||
for (literal l : lits) {
|
|
||||||
if (!s.is_marked(l)) {
|
|
||||||
s.mark_visited(l);
|
|
||||||
added.push_back(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lits.reset();
|
|
||||||
}
|
|
||||||
s.unmark_visited(lit);
|
|
||||||
bool is_tautology = added.size() > 2 && all_tautology(lit);
|
|
||||||
for (literal l : added) s.unmark_visited(l);
|
|
||||||
return is_tautology;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(literal l) {
|
void process(literal l) {
|
||||||
|
@ -1086,9 +1088,9 @@ namespace sat {
|
||||||
SASSERT(c.contains(l));
|
SASSERT(c.contains(l));
|
||||||
s.mark_all_but(c, l);
|
s.mark_all_but(c, l);
|
||||||
if (all_tautology(l)) {
|
if (all_tautology(l)) {
|
||||||
|
s.unmark_all(c);
|
||||||
block_clause(c, l, new_entry);
|
block_clause(c, l, new_entry);
|
||||||
s.m_num_blocked_clauses++;
|
s.m_num_blocked_clauses++;
|
||||||
s.unmark_all(c);
|
|
||||||
}
|
}
|
||||||
else if (cce(c, l)) {
|
else if (cce(c, l)) {
|
||||||
block_clause(c, l, new_entry);
|
block_clause(c, l, new_entry);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue