This class is used to manipulate CNF clauses. More...
#include <clause.h>
Public Member Functions | |
Clause () | |
Builds an empty Clause instance. | |
void | addLit (int) |
Adds the code of the literal given as an argument to the Clause. | |
std::string | toString () |
Puts all the literals in a one line std::string. | |
bool | restriction (std::vector< int >) |
Applies the restriction corresponding to the assign assignment to the clause. | |
Private Attributes | |
std::vector< int > | literals |
The codes of the variables of the clause. |
This class is used to manipulate CNF clauses.
A CNF clause consist of the disjunction of an arbitrary number of literals. This class makes it easier to use these in coordination with the minisat2 program.
Clause::Clause | ( | ) |
Builds an empty Clause instance.
Definition at line 18 of file clause.cpp.
void Clause::addLit | ( | int | code | ) |
Adds the code of the literal given as an argument to the Clause.
Definition at line 23 of file clause.cpp.
bool Clause::restriction | ( | std::vector< int > | assign | ) |
Applies the restriction corresponding to the assign assignment to the clause.
For each element of the assign std::vector, checks if it is in the variables of this clause. If no literal of the assignment is in the clause, does nothing. If one of the literals is present and negated, removes it. If there is no litteral left in the clause, ends the program: the formula is unsatisfiable, no need to ask minisat2.
Definition at line 40 of file clause.cpp.
std::string Clause::toString | ( | ) |
Puts all the literals in a one line std::string.
The aim of this method is to write a line of a DIMACS formatted file corresponding to this disjunction.
Definition at line 28 of file clause.cpp.
std::vector<int> cnf::Clause::literals [private] |