pub struct Clause { /* private fields */ }
Expand description

Type representing a clause. Wrapper around a std collection to allow for changing the data structure. Optional clauses as sets will be included in the future.

Implementations§

source§

impl Clause

source

pub fn new() -> Self

Creates a new empty clause

source

pub fn lits(&self) -> &[Lit]

Gets the clause as a slice of literals

source

pub fn len(&self) -> usize

Gets the length of the clause

source

pub fn is_empty(&self) -> bool

Checks if the clause is empty

source

pub fn evaluate(&self, assignment: &Assignment) -> TernaryVal

Evaluates a clause under a given assignment

source

pub fn iter(&self) -> impl Iterator<Item = &Lit>

Gets an iterator over the clause

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Lit>

Gets a mutable iterator over the clause

source

pub fn drain<R: RangeBounds<usize>>(&mut self, range: R) -> Drain<'_, Lit>

source

pub fn normalize(self) -> Option<Self>

Normalizes the clause. This includes sorting the literals, removing duplicates and removing the entire clause if it is a tautology. Comparing two normalized clauses checks their logical equivalence.

source

pub fn sanitize(self) -> Option<Self>

Sanitizes the clause. This includes removing duplicates and removing the entire clause if it is a tautology. This preserves the order of the literals in the clause.

source

pub fn is_sat(&self, assign: &Assignment) -> bool

source§

impl Clause

source

pub fn is_unit(&self) -> bool

Checks if the clause is a unit clause

source

pub fn is_binary(&self) -> bool

Checks if the clause is binary

source

pub fn add(&mut self, lit: Lit)

Adds a literal to the clause

source

pub fn remove(&mut self, lit: &Lit) -> bool

Removes the first occurrence of a literal from the clause Returns true if an occurrence was found

source

pub fn remove_thorough(&mut self, lit: &Lit) -> bool

Removes all occurrences of a literal from the clause

Trait Implementations§

source§

impl Clone for Clause

source§

fn clone(&self) -> Clause

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 Clause

Clauses can be printed with the Debug trait

source§

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

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

impl Default for Clause

source§

fn default() -> Clause

Returns the “default value” for a type. Read more
source§

impl Display for Clause

Clauses can be printed with the Display trait

source§

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

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

impl Extend<Clause> for Cnf

source§

fn extend<Iter: IntoIterator<Item = Clause>>(&mut self, iter: Iter)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl Extend<Lit> for Clause

source§

fn extend<T: IntoIterator<Item = Lit>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl From<&[Lit]> for Clause

source§

fn from(value: &[Lit]) -> Self

Converts to this type from the input type.
source§

impl<const N: usize> From<[Lit; N]> for Clause

source§

fn from(value: [Lit; N]) -> Self

Converts to this type from the input type.
source§

impl FromIterator<Clause> for Cnf

source§

fn from_iter<T: IntoIterator<Item = Clause>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<VM: ManageVars + Default> FromIterator<Clause> for SatInstance<VM>

source§

fn from_iter<T: IntoIterator<Item = Clause>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl FromIterator<Lit> for Clause

source§

fn from_iter<T: IntoIterator<Item = Lit>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for Clause

source§

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

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 Index<usize> for Clause

§

type Output = Lit

The returned type after indexing.
source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl IndexMut<usize> for Clause

source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
source§

impl<'a> IntoIterator for &'a Clause

§

type Item = &'a Lit

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, Lit>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a> IntoIterator for &'a mut Clause

§

type Item = &'a mut Lit

The type of the elements being iterated over.
§

type IntoIter = IterMut<'a, Lit>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for Clause

§

type Item = Lit

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Lit>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl Ord for Clause

source§

fn cmp(&self, other: &Clause) -> 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 + PartialOrd,

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

impl PartialEq for Clause

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Clause

source§

fn partial_cmp(&self, other: &Clause) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Clause

source§

impl StructuralEq for Clause

Auto Trait Implementations§

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

§

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§

default 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>,

§

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>,

§

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<I> LitIter for I
where I: IntoIterator<Item = Lit>,