6 #include "core/SolverTypes.h" 36 lits.push_back(mkLit(var,
false));
54 std::vector<CClause> result;
56 for (
unsigned i = 0; i < lits.size(); i++) {
58 result.push_back(unitClause);
75 std::vector<CClause> CClause::operator&(
const CClause &other) {
76 std::vector<CClause> result;
78 result.push_back(*
this);
79 result.push_back(other);
114 std::vector<Lit> thisLits = this->lits;
115 std::vector<Lit> otherLits = other.
getLits();
117 thisLits.insert(std::end(thisLits), std::begin(otherLits),
118 std::end(otherLits));
119 std::sort(thisLits.begin(), thisLits.end());
121 thisLits.erase(std::unique(thisLits.begin(), thisLits.end()), thisLits.end());
122 bool existBothPolarities =
false;
123 int indexLitBothPolarities = -1;
124 for (
unsigned i = 0; i < thisLits.size(); i++) {
125 for (
unsigned j = i + 1; j < thisLits.size(); j++) {
127 if (var(thisLits[i]) == var(thisLits[j])) {
128 existBothPolarities =
true;
129 indexLitBothPolarities = i;
133 if (existBothPolarities) {
138 if (existBothPolarities) {
140 result.
addLits(thisLits[indexLitBothPolarities]);
141 result.
addLits(~thisLits[indexLitBothPolarities]);
162 return (thisLHS | other);
179 std::vector<CClause> lhs = ~(*this);
180 std::vector<CClause> result;
182 for (
unsigned i = 0; i < lhs.size(); i++) {
183 CClause thisClause = lhs[i] | other;
184 result.push_back(thisClause);
202 return (thisLHS | other);
214 lits.push_back(mkLit(var1,
false));
226 lits.push_back(mkLit(var1,
false));
227 lits.push_back(mkLit(var2,
false));
241 lits.push_back(mkLit(var1,
false));
242 lits.push_back(mkLit(var2,
false));
243 lits.push_back(mkLit(var3,
false));
260 lits.push_back(lit1);
261 lits.push_back(lit2);
272 lits.push_back(lit1);
273 lits.push_back(lit2);
274 lits.push_back(lit3);
283 lits.insert(std::end(lits), std::begin(otherLits), std::end(otherLits));
297 for (Lit lit : lits) {
298 LOG_DEBUG(INFO) << (sign(lit) ?
"-" :
" ") << var(lit) <<
" ";
300 LOG_DEBUG(INFO) <<
"";
void clear()
Clears the clause by removing all the literals.
Class for representing a clause.
void createLitAndAdd(const Var &)
Creates a Lit, a literal, given a variable, a Var, and adds it to the clause.
CClause()
Constructs the CClause object, as an empty clause.
std::vector< Lit > getLits() const
Gets the literals in the clause.
std::vector< CClause > getClauses() const
Gets the clauses in this object.
std::vector< CClause > operator~()
Defines the operator to negate the clause in this object.
std::vector< CClause > operator>>(const CClause &)
Defines the operator to perform an implication with another clause.
void addClauses(const CClause &)
Adds a CClause to the set of clauses.
void printClause()
Displays the clause.
void addLits(const Lit &)
Adds a Lit, a literal, to the clause.
Class for representing a set of clauses.
CClause operator|(const CClause &)
Defines the operator to perform a disjunction of two clauses.