bool integrity_checker::check_clause(clause const & c) const { SASSERT(!c.was_removed()); for (unsigned i = 0; i < c.size(); i++) { SASSERT(c[i].var() <= s.num_vars()); CTRACE("sat_bug", s.was_eliminated(c[i].var()), tout << "l: " << c[i].var() << "\n"; tout << "c: " << c << "\n"; s.display(tout);); SASSERT(!s.was_eliminated(c[i].var())); }
/** * Évalue la valeur de vérité d'une clause selon une interprétation donnée. * @param cl La clause à évaluer. * @param interpretation L'interprétation selon laquelle la clause sera évaluée. * @return -1 si la clause est évaluée à FAUX. 1 si elle est évaluée à VRAI. 0 si elle est indéterminée. * @see forme_conj_est_satisfaite(const forme_conjonctive&, const short int*) */ short int clause_est_satisfaite(const clause &cl, const short int *interpretation) { bool indetermine = false; for(clause::const_iterator it=cl.begin(); it!=cl.end(); it++) { unsigned int indice = abs(*it) - 1; int litteral = *it * interpretation[indice]; if(litteral > 0) { return 1; } else if(litteral == 0) { indetermine = true; } } return (indetermine ? 0 : -1); }
void clause_set::insert(clause & c) { unsigned id = c.id(); m_id2pos.reserve(id+1, UINT_MAX); if (m_id2pos[id] != UINT_MAX) return; // already in the set unsigned pos = m_set.size(); m_id2pos[id] = pos; m_set.push_back(&c); CASSERT("clause_set", check_invariant()); }
void clause_set::erase(clause & c) { unsigned id = c.id(); if (id >= m_id2pos.size()) return; unsigned pos = m_id2pos[id]; if (pos == UINT_MAX) return; m_id2pos[id] = UINT_MAX; unsigned last_pos = m_set.size() - 1; if (pos != last_pos) { clause * last_c = m_set[last_pos]; m_set[pos] = last_c; m_id2pos[last_c->id()] = pos; } m_set.pop_back(); CASSERT("clause_set", check_invariant()); }
bool compareBySize(const clause &a, const clause &b) { return a.size() < b.size(); }
void bceq::use_list::erase(clause& c) { unsigned sz = c.size(); for (unsigned i = 0; i < sz; i++) { m_clauses[c[i].index()].erase(&c); } }
void bceq::use_list::insert(clause& c) { unsigned sz = c.size(); for (unsigned i = 0; i < sz; i++) { m_clauses[c[i].index()].push_back(&c); } }