Variable
A variable has an unsigned integer as its value. A variable can also be treated as an unsigned integer.- Constructors
- Static member variables
We can construct a variable via a default constructor, a copy constructor, or a constructor that takes in an unsigned integer.
const static Variable start is the minimum variable. const static Variable under is the only undefined variable with the value unsigned(-1) and each valid variable should has a less value.
Literal
A literal has an unsigned integer as its value and it can also be treated as an unsigned integer. For example, if x1 has value 1, the literal x1 has value 3 and not x1 has value 2.- Constructors
Variable Var()bool Sign()bool NSign()const Literal operator ~()
We can construct a variable via a default constructor, a copy constructor, a constructor that takes in an unsigned integer, or a constructor that takes in a variable and a sign.
This function returns the variable of the literal.
This function returns the sign of the literal, where true means positive and false means negative.
This function returns the negation of the sign of the literal.
This function returns the negated literal
Clause
We remark that the member Literal * _lits must be managed outside.
Clause(Literal lit)Clause(Literal lit0, Literal lit1)Clause(const Literal * lits, unsigned size)Clause(const vector& lits) - Copy constructor
- Destructor
Clause Copy()void Free()unsigned Size()void Shrink(unsigned size)Literal & operator [] ( unsigned i )Literal & Last_Lit()void Erase_Lit(unsigned i)void Swap_Lits(unsigned i, unsigned j)void Swap(Clause & clause)void Sort(QSorter & sorter)void Sort(const unsigned * var_rank)void Display(ostream & out)
Create a unit clause.
Create a binary clause.
Create a clause with a given size.
Create a clause with literals in the given vector.
The output clause shares the address of _lits with the input clause.
The destruction does not free the memory for _lits. Call Free() if you want to free it.
Returns a copied clause with reallocated memory for _lits
Free the memory for _lits.
Returns the number of literals.
Reduce the number of literals given by size.
Returns the i-th literal.
Returns the last literal.
Erase the i-th literal and move the last to the position i.
Swap two literals at positions i and j.
Swap the literals of two clauses.
Sort the literals wrt the unsigned values of the variables.
Sort the literals wrt the variable rank as var_rank
Display the clause.
CNF formula
CNF_Formula(Variable max_var)CNF_Formula(istream & fin)void Add_Unary_Clause( Literal lit )void Add_Binary_Clause( Literal lit0, Literal lit1 )void Add_Ternary_Clause( Literal lit0, Literal lit1, Literal lit2 )void Add_Clause( Clause & cl )void Input_Clause( Clause & cl )Variable Max_Var() constunsigned Num_Clauses() constClause & operator [] ( unsigned i )
Create an empty CNF formula with a stated maximum variable.
Create a CNF formula from a file in DIMACS format.
Add an unary clause with the literal given by lit.
Add a binary clause with the literals given by lit0 and lit1.
Add a ternary clause with the literals given by lit0, lit1 and lit2.
Add a clause, where the memory for storing literals will be reallocate.
Input a clause, where the memory of _lits will be used by the CNF formula.
Return the admitted maximum variable.
Return the number of clauses.
Returns the i-th clause.