Struct rustsat::instances::Cnf

source ·
pub struct Cnf { /* private fields */ }
Expand description

Simple type representing a CNF formula. Other than SatInstance<VM>, this type only supports clauses and does have an internal variable manager.

Implementations§

source§

impl Cnf

source

pub fn new() -> Cnf

Creates a new Cnf

source

pub fn with_capacity(capacity: usize) -> Cnf

Creates a new Cnf with a given capacity of clauses

source

pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Tries to reserve memory for at least additional new clauses

source

pub fn shrink_to_fit(&mut self)

Shrinks the allocated memory of the Cnf to fit the number of clauses

source

pub fn capacity(&self) -> usize

Gets the capacity of the Cnf

source

pub fn add_clause(&mut self, clause: Clause)

Adds a clause to the CNF

source

pub fn add_unit(&mut self, unit: Lit)

Adds a unit clause to the CNF

source

pub fn add_binary(&mut self, lit1: Lit, lit2: Lit)

Adds a binary clause to the CNF

source

pub fn add_ternary(&mut self, lit1: Lit, lit2: Lit, lit3: Lit)

Adds a ternary clause to the CNF

source

pub fn is_empty(&self) -> bool

Checks if the CNF is empty

source

pub fn len(&self) -> usize

Returns the number of clauses in the instance

source

pub fn add_lit_impl_lit(&mut self, a: Lit, b: Lit)

source

pub fn add_lit_impl_clause(&mut self, a: Lit, b: &[Lit])

source

pub fn add_lit_impl_cube(&mut self, a: Lit, b: &[Lit])

Adds an implication of form a -> (b1 & b2 & … & bm)

source

pub fn add_cube_impl_lit(&mut self, a: &[Lit], b: Lit)

source

pub fn add_clause_impl_lit(&mut self, a: &[Lit], b: Lit)

Adds an implication of form (a1 | a2 | … | an) -> b

source

pub fn add_cube_impl_clause(&mut self, a: &[Lit], b: &[Lit])

source

pub fn add_clause_impl_clause(&mut self, a: &[Lit], b: &[Lit])

Adds an implication of form (a1 | a2 | … | an) -> (b1 | b2 | … | bm)

source

pub fn add_clause_impl_cube(&mut self, a: &[Lit], b: &[Lit])

Adds an implication of form (a1 | a2 | … | an) -> (b1 & b2 & … & bm)

source

pub fn add_cube_impl_cube(&mut self, a: &[Lit], b: &[Lit])

Adds an implication of form (a1 & a2 & … & an) -> (b1 & b2 & … & bm)

source

pub fn join(self, other: Cnf) -> Cnf

Joins the current CNF with another one. Like Cnf::extend but consumes the object and returns a new object.

source

pub fn iter(&self) -> Iter<'_, Clause>

Returns an iterator over references to the clauses

source

pub fn iter_mut(&mut self) -> IterMut<'_, Clause>

Returns an iterator over mutable references to the clauses

source

pub fn normalize(self) -> Self

Normalizes the CNF. This includes normalizing and sorting the clauses, removing duplicates and tautologies. Comparing two normalized CNFs is equal to comparing sets of sets of literals.

source

pub fn sanitize(self) -> Self

Sanitizes the CNF by removing tautologies, removing redundant literals, etc.

Trait Implementations§

source§

impl Clone for Cnf

source§

fn clone(&self) -> Cnf

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 CollectClauses for Cnf

source§

fn n_clauses(&self) -> usize

Gets the number of clauses in the collection
source§

impl Debug for Cnf

source§

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

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

impl Default for Cnf

source§

fn default() -> Cnf

Returns the “default value” for a type. 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 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 Index<usize> for Cnf

§

type Output = Clause

The returned type after indexing.
source§

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

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

impl IntoIterator for Cnf

§

type Item = Clause

The type of the elements being iterated over.
§

type IntoIter = IntoIter<Clause>

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 PartialEq for Cnf

source§

fn eq(&self, other: &Cnf) -> 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 Eq for Cnf

source§

impl StructuralEq for Cnf

source§

impl StructuralPartialEq for Cnf

Auto Trait Implementations§

§

impl RefUnwindSafe for Cnf

§

impl Send for Cnf

§

impl Sync for Cnf

§

impl Unpin for Cnf

§

impl UnwindSafe for Cnf

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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> ClsIter for Iwhere I: IntoIterator<Item = Clause>,