clingo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Public Member Functions | Static Public Member Functions | List of all members
Clasp::Literal Class Reference

A literal is a variable or its negation. More...

#include <literal.h>

Collaboration diagram for Clasp::Literal:
Collaboration graph

Public Member Functions

 Literal ()
 The default constructor creates the positive literal of the special sentinel var. More...
 
 Literal (Var var, bool sign)
 Creates a literal of the variable var with sign s. More...
 
uint32 index () const
 Returns the unique index of this literal. More...
 
uint32 & asUint ()
 
uint32 asUint () const
 
Var var () const
 Returns the variable of the literal. More...
 
bool sign () const
 Returns the sign of the literal. More...
 
void swap (Literal &other)
 
void watch ()
 Sets the watched-flag of this literal. More...
 
void clearWatch ()
 Clears the watched-flag of this literal. More...
 
bool watched () const
 Returns true if the watched-flag of this literal is set. More...
 
Literal operator~ () const
 Returns the complimentary literal of this literal. More...
 
bool operator== (const Literal &rhs) const
 Equality-Comparison for literals. More...
 

Static Public Member Functions

static Literal fromIndex (uint32 idx)
 Creates a literal from an index. More...
 
static Literal fromRep (uint32 rep)
 Creates a literal from an unsigned integer. More...
 

Detailed Description

A literal is a variable or its negation.

A literal is determined by two things: a sign and a variable index.

Implementation:
A literal's state is stored in a single 32-bit integer as follows:
  • 30-bits : var-index
  • 1-bit : sign, 1 if negative, 0 if positive
  • 1-bit : watch-flag

Constructor & Destructor Documentation

Clasp::Literal::Literal ( )
inline

The default constructor creates the positive literal of the special sentinel var.

Clasp::Literal::Literal ( Var  var,
bool  sign 
)
inline

Creates a literal of the variable var with sign s.

Parameters
varThe literal's variable.
strue if new literal should be negative.
Precondition
var < varMax

Member Function Documentation

uint32& Clasp::Literal::asUint ( )
inline
uint32 Clasp::Literal::asUint ( ) const
inline
void Clasp::Literal::clearWatch ( )
inline

Clears the watched-flag of this literal.

static Literal Clasp::Literal::fromIndex ( uint32  idx)
inlinestatic

Creates a literal from an index.

Precondition
idx < 2^31

Here is the call graph for this function:

static Literal Clasp::Literal::fromRep ( uint32  rep)
inlinestatic

Creates a literal from an unsigned integer.

Here is the call graph for this function:

uint32 Clasp::Literal::index ( ) const
inline

Returns the unique index of this literal.

Note
The watch-flag is ignored and thus the index of a literal can be stored in 31-bits.
bool Clasp::Literal::operator== ( const Literal rhs) const
inline

Equality-Comparison for literals.

Two Literals p and q are equal, iff

  • they both refer to the same variable
  • they have the same sign

Here is the call graph for this function:

Literal Clasp::Literal::operator~ ( ) const
inline

Returns the complimentary literal of this literal.

The complementary Literal of a Literal is a Literal referring to the same variable but with inverted sign.

Here is the call graph for this function:

bool Clasp::Literal::sign ( ) const
inline

Returns the sign of the literal.

Returns
true if the literal is negative. Otherwise false.
void Clasp::Literal::swap ( Literal other)
inline

Here is the call graph for this function:

Var Clasp::Literal::var ( ) const
inline

Returns the variable of the literal.

void Clasp::Literal::watch ( )
inline

Sets the watched-flag of this literal.

bool Clasp::Literal::watched ( ) const
inline

Returns true if the watched-flag of this literal is set.


The documentation for this class was generated from the following file: