cnf::Clause Class Reference

This class is used to manipulate CNF clauses. More...

#include <clause.h>

List of all members.

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.

Detailed Description

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.

Definition at line 24 of file clause.h.


Constructor & Destructor Documentation

Clause::Clause ( )

Builds an empty Clause instance.

Definition at line 18 of file clause.cpp.


Member Function Documentation

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.

Returns:
1 if one of the literals is present and is not negated (the clause is true), 0 otherwise.

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.


Member Data Documentation

std::vector<int> cnf::Clause::literals [private]

The codes of the variables of the clause.

If the literal is negated, it contains the opposite of its code instead of its code according to the DIMACS encoding.

Definition at line 33 of file clause.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Defines