/** @brief Helper function for replace_set() */ bool VarReplacer::handleUpdatedClause(Clause& c, const Lit origLit1, const Lit origLit2, const Lit origLit3) { bool satisfied = false; std::sort(c.getData(), c.getData() + c.size()); Lit p; uint32_t i, j; const uint32_t origSize = c.size(); for (i = j = 0, p = lit_Undef; i != origSize; i++) { if (solver.value(c[i]) == l_True || c[i] == ~p) { satisfied = true; break; } else if (solver.value(c[i]) != l_False && c[i] != p) c[j++] = p = c[i]; } c.shrink(i - j); c.setChanged(); solver.detachModifiedClause(origLit1, origLit2, origLit3, origSize, &c); #ifdef VERBOSE_DEBUG cout << "clause after replacing: "; c.plainPrint(); #endif if (satisfied) return true; switch(c.size()) { case 0: solver.ok = false; return true; case 1 : solver.uncheckedEnqueue(c[0]); solver.ok = (solver.propagate<false>().isNULL()); return true; case 2: solver.attachBinClause(c[0], c[1], c.learnt()); solver.numNewBin++; solver.dataSync->signalNewBinClause(c); return true; default: solver.attachClause(c); return false; } assert(false); return false; }
/** @brief Helper function for replace_set() */ const bool VarReplacer::handleUpdatedClause(Clause& c, const Lit origLit1, const Lit origLit2, const Lit origLit3) { bool satisfied = false; std::sort(c.getData(), c.getData() + c.size()); Lit p; uint32_t i, j; const uint32_t origSize = c.size(); for (i = j = 0, p = lit_Undef; i != origSize; i++) { if (solver.value(c[i]) == l_True || c[i] == ~p) { satisfied = true; break; } else if (solver.value(c[i]) != l_False && c[i] != p) c[j++] = p = c[i]; } c.shrink(i - j); c.setStrenghtened(); solver.detachModifiedClause(origLit1, origLit2, origLit3, origSize, &c); if (satisfied) return true; switch(c.size()) { case 0: solver.ok = false; return true; case 1 : solver.uncheckedEnqueue(c[0]); solver.ok = (solver.propagate().isNULL()); return true; default: solver.attachClause(c); return false; } assert(false); return false; }