Struct Lit

Source
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

Source

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.

Source

pub fn positive(var: Var) -> Lit

Create a positive literal from a Var.

Source

pub fn negative(var: Var) -> Lit

Create a negative literal from a Var.

Source

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.

Source

pub fn from_code(code: usize) -> Lit

Create a literal with the given encoding.

Source

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.

Source

pub fn to_dimacs(self) -> isize

1-based Integer representation of the literal, opposite of from_dimacs.

Source

pub fn index(self) -> usize

0-based index of the literal’s variable.

Source

pub fn var(self) -> Var

The literal’s variable.

Source

pub fn is_negative(self) -> bool

Whether the literal is negative, i.e. a negated variable.

Source

pub fn is_positive(self) -> bool

Whether the literal is positive, i.e. a non-negated variable.

Source

pub fn code(self) -> usize

Two times the variable’s index for positive literals and one more for negative literals.

This is also the internal encoding.

Source

pub fn map_var(self, f: impl FnOnce(Var) -> Var) -> Lit

Apply a function to the variable of the literal, without changing the polarity.

Trait Implementations§

Source§

impl BitXor<bool> for Lit

Source§

type Output = Lit

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: bool) -> Lit

Performs the ^ operation. Read more
Source§

impl Clone for Lit

Source§

fn clone(&self) -> Lit

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lit

Uses the 1-based DIMACS CNF encoding.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Display for Lit

Uses the 1-based DIMACS CNF encoding.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl From<Var> for Lit

Source§

fn from(var: Var) -> Lit

Converts to this type from the input type.
Source§

impl Hash for Lit

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Not for Lit

Source§

type Output = Lit

The resulting type after applying the ! operator.
Source§

fn not(self) -> Lit

Performs the unary ! operation. Read more
Source§

impl Ord for Lit

Source§

fn cmp(&self, other: &Lit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Lit

Source§

fn eq(&self, other: &Lit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Lit

Source§

fn partial_cmp(&self, other: &Lit) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Lit

Source§

impl Eq for Lit

Source§

impl StructuralPartialEq for Lit

Auto Trait Implementations§

§

impl Freeze for Lit

§

impl RefUnwindSafe for Lit

§

impl Send for Lit

§

impl Sync for Lit

§

impl Unpin for Lit

§

impl UnwindSafe for Lit

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<Reference, Outer, OuterFieldType, Inner> HasPart<Nested<Outer, Inner>> for Reference
where Reference: HasPart<Outer> + ?Sized, Outer: Part<PartType = Field<OuterFieldType>>, Inner: Part, OuterFieldType: HasPart<Inner, RawTarget = OuterFieldType> + PartialRefTarget + ?Sized,

Source§

unsafe fn part_ptr( ptr: *const <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::Ptr

Given a constant pointer to a target, produce a constant pointer to a part of it. Read more
Source§

unsafe fn part_ptr_mut( ptr: *mut <Reference as PartialRefTarget>::RawTarget, ) -> <<Inner as Part>::PartType as PartType>::PtrMut

Given a mutable pointer to a target, produce a mutable pointer to a part of it. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V