pub struct Lit { /* private fields */ }
Expand description
A boolean literal.
A literal is a variable or the negation of a variable.
Conceptually a literal consists of a Var
and a bool
indicating whether the literal
represents the variable (positive literal) or its negation (negative literal).
Internally a literal is represented as an integer that is two times the index of its variable
when it is positive or one more when it is negative. This integer is called the code
of the
literal.
The restriction on the range of allowed indices for Var
also applies to Lit
.
Implementations§
Source§impl Lit
impl Lit
Sourcepub fn from_var(var: Var, polarity: bool) -> Lit
pub fn from_var(var: Var, polarity: bool) -> Lit
Creates a literal from a Var
and a bool
that is true
when the literal is positive.
Sourcepub fn from_index(index: usize, polarity: bool) -> Lit
pub fn from_index(index: usize, polarity: bool) -> Lit
Create a literal from a variable index and a bool
that is true
when the literal is
positive.
Sourcepub fn from_dimacs(number: isize) -> Lit
pub fn from_dimacs(number: isize) -> Lit
Creates a literal from an integer.
The absolute value is used as 1-based index, the sign of the integer is used as sign of the literal.
Sourcepub fn to_dimacs(self) -> isize
pub fn to_dimacs(self) -> isize
1-based Integer representation of the literal, opposite of from_dimacs
.
Sourcepub fn is_negative(self) -> bool
pub fn is_negative(self) -> bool
Whether the literal is negative, i.e. a negated variable.
Sourcepub fn is_positive(self) -> bool
pub fn is_positive(self) -> bool
Whether the literal is positive, i.e. a non-negated variable.