CRef Solver::updateLemmas() {
- Debug("minisat::lemmas") << "Solver::updateLemmas()" << std::endl;
+ Debug("minisat::lemmas") << "Solver::updateLemmas() begin" << std::endl;
CRef conflict = CRef_Undef;
lemma_lt lt(*this);
// Check for propagation and level to backtrack to
- for (int i = 0; i < lemmas.size(); ++ i)
- {
- // The current lemma
- vec<Lit>& lemma = lemmas[i];
- // If it's an empty lemma, we have a conflict at zero level
- if (lemma.size() == 0) {
- conflict = CRef_Lazy;
- backtrackLevel = 0;
- Debug("minisat::lemmas") << "Solver::updateLemmas(): found empty clause" << std::endl;
- continue;
- }
- // Sort the lemma to be able to attach
- sort(lemma, lt);
- // See if the lemma propagates something
- if (lemma.size() == 1 || value(lemma[1]) == l_False) {
- Debug("minisat::lemmas") << "found unit " << lemma.size() << std::endl;
- // This lemma propagates, see which level we need to backtrack to
- int currentBacktrackLevel = lemma.size() == 1 ? 0 : level(var(lemma[1]));
- // Even if the first literal is true, we should propagate it at this level (unless it's set at a lower level)
- if (value(lemma[0]) != l_True || level(var(lemma[0])) > currentBacktrackLevel) {
- if (currentBacktrackLevel < backtrackLevel) {
- backtrackLevel = currentBacktrackLevel;
+ int i = 0;
+ while (i < lemmas.size()) {
+ // We need this loop as when we backtrack, due to registration more lemmas could be added
+ for (; i < lemmas.size(); ++ i)
+ {
+ // The current lemma
+ vec<Lit>& lemma = lemmas[i];
+ // If it's an empty lemma, we have a conflict at zero level
+ if (lemma.size() == 0) {
+ conflict = CRef_Lazy;
+ backtrackLevel = 0;
+ Debug("minisat::lemmas") << "Solver::updateLemmas(): found empty clause" << std::endl;
+ continue;
+ }
+ // Sort the lemma to be able to attach
+ sort(lemma, lt);
+ // See if the lemma propagates something
+ if (lemma.size() == 1 || value(lemma[1]) == l_False) {
+ Debug("minisat::lemmas") << "found unit " << lemma.size() << std::endl;
+ // This lemma propagates, see which level we need to backtrack to
+ int currentBacktrackLevel = lemma.size() == 1 ? 0 : level(var(lemma[1]));
+ // Even if the first literal is true, we should propagate it at this level (unless it's set at a lower level)
+ if (value(lemma[0]) != l_True || level(var(lemma[0])) > currentBacktrackLevel) {
+ if (currentBacktrackLevel < backtrackLevel) {
+ backtrackLevel = currentBacktrackLevel;
+ }
}
}
}
- }
- // Pop so that propagation would be current
- Debug("minisat::lemmas") << "Solver::updateLemmas(): backtracking to " << backtrackLevel << " from " << decisionLevel() << std::endl;
- cancelUntil(backtrackLevel);
+ // Pop so that propagation would be current
+ Debug("minisat::lemmas") << "Solver::updateLemmas(): backtracking to " << backtrackLevel << " from " << decisionLevel() << std::endl;
+ cancelUntil(backtrackLevel);
+ }
// Last index in the trail
int backtrack_index = trail.size();
theoryConflict = true;
}
+ Debug("minisat::lemmas") << "Solver::updateLemmas() end" << std::endl;
+
return conflict;
}