mirror of
https://github.com/Z3Prover/z3
synced 2025-08-19 09:40:20 +00:00
speed-up handling of cnf input to inc_sat_solver
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9bd4050e0c
commit
b8d18c6c6d
7 changed files with 133 additions and 57 deletions
|
@ -78,6 +78,7 @@ namespace sat {
|
|||
}
|
||||
|
||||
void cleaner::cleanup_clauses(clause_vector & cs) {
|
||||
tmp_clause tmp;
|
||||
clause_vector::iterator it = cs.begin();
|
||||
clause_vector::iterator it2 = it;
|
||||
clause_vector::iterator end = cs.end();
|
||||
|
@ -88,12 +89,10 @@ namespace sat {
|
|||
CTRACE("sat_cleaner_frozen", c.frozen(), tout << c << "\n";);
|
||||
unsigned sz = c.size();
|
||||
unsigned i = 0, j = 0;
|
||||
bool sat = false;
|
||||
m_cleanup_counter += sz;
|
||||
for (; i < sz; i++) {
|
||||
switch (s.value(c[i])) {
|
||||
case l_true:
|
||||
sat = true;
|
||||
goto end_loop;
|
||||
case l_false:
|
||||
m_elim_literals++;
|
||||
|
@ -108,9 +107,9 @@ namespace sat {
|
|||
}
|
||||
end_loop:
|
||||
CTRACE("sat_cleaner_frozen", c.frozen(),
|
||||
tout << "sat: " << sat << ", new_size: " << j << "\n";
|
||||
tout << "sat: " << (i < sz) << ", new_size: " << j << "\n";
|
||||
tout << mk_lits_pp(j, c.begin()) << "\n";);
|
||||
if (sat) {
|
||||
if (i < sz) {
|
||||
m_elim_clauses++;
|
||||
s.del_clause(c);
|
||||
}
|
||||
|
@ -119,33 +118,37 @@ namespace sat {
|
|||
CTRACE("sat_cleaner_bug", new_sz < 2, tout << "new_sz: " << new_sz << "\n";
|
||||
if (c.size() > 0) tout << "unit: " << c[0] << "\n";
|
||||
s.display_watches(tout););
|
||||
if (new_sz == 0) {
|
||||
switch (new_sz) {
|
||||
case 0:
|
||||
s.set_conflict(justification());
|
||||
s.del_clause(c);
|
||||
}
|
||||
else if (new_sz == 1) {
|
||||
break;
|
||||
case 1:
|
||||
s.assign(c[0], justification());
|
||||
s.del_clause(c);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
case 2:
|
||||
SASSERT(s.value(c[0]) == l_undef && s.value(c[1]) == l_undef);
|
||||
if (new_sz == 2) {
|
||||
TRACE("cleanup_bug", tout << "clause became binary: " << c[0] << " " << c[1] << "\n";);
|
||||
s.mk_bin_clause(c[0], c[1], c.is_learned());
|
||||
s.del_clause(c);
|
||||
TRACE("cleanup_bug", tout << "clause became binary: " << c[0] << " " << c[1] << "\n";);
|
||||
s.mk_bin_clause(c[0], c[1], c.is_learned());
|
||||
s.del_clause(c);
|
||||
break;
|
||||
default:
|
||||
SASSERT(s.value(c[0]) == l_undef && s.value(c[1]) == l_undef);
|
||||
if (s.m_config.m_drat && new_sz < i) {
|
||||
tmp.set(c.size(), c.begin(), c.is_learned());
|
||||
}
|
||||
else {
|
||||
c.shrink(new_sz);
|
||||
*it2 = *it;
|
||||
it2++;
|
||||
if (!c.frozen()) {
|
||||
s.attach_clause(c);
|
||||
}
|
||||
if (s.m_config.m_drat) {
|
||||
// for optimization, could also report deletion
|
||||
// of previous version of clause.
|
||||
s.m_drat.add(c, true);
|
||||
}
|
||||
c.shrink(new_sz);
|
||||
*it2 = *it;
|
||||
it2++;
|
||||
if (!c.frozen()) {
|
||||
s.attach_clause(c);
|
||||
}
|
||||
if (s.m_config.m_drat && new_sz < i) {
|
||||
// for optimization, could also report deletion
|
||||
// of previous version of clause.
|
||||
s.m_drat.add(c, true);
|
||||
s.m_drat.del(*tmp.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue