pub struct Solver { /* private fields */ }
Expand description
Solver object representing an instance of the boolean satisfiability problem.
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn add_clause<I: IntoIterator<Item = Bool>>(&mut self, lits: I)
pub fn add_clause<I: IntoIterator<Item = Bool>>(&mut self, lits: I)
Add a clause to the SAT instance (assert the disjunction of the given literals).
Sourcepub fn solve<'a>(&'a mut self) -> Result<Model<'a>, ()>
pub fn solve<'a>(&'a mut self) -> Result<Model<'a>, ()>
Solve the SAT instance, returning a solution (Model
) if the
instance is satisfiable, or returning an Err(())
if the problem
is unsatisfiable.
Sourcepub fn solve_under_assumptions<'a, I: IntoIterator<Item = Bool>>(
&'a mut self,
lits: I,
) -> Result<Model<'a>, ()>
pub fn solve_under_assumptions<'a, I: IntoIterator<Item = Bool>>( &'a mut self, lits: I, ) -> Result<Model<'a>, ()>
Solve the SAT instance under given assumptions, returning a solution (Model
) if the
instance is satisfiable, or returning an Err(())
if the problem
is unsatisfiable.
The conjunction of the given literals are temporarily added to the SAT instance, so the result is the same as if each literal was added as a clause, but the solver object can be re-used afterwards and does then not contain these assumptions. This interface can be used to build SAT instances incrementally.
Sourcepub fn and_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
pub fn and_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
Return a literal representing the conjunction of the given booleans.
Sourcepub fn or_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
pub fn or_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
Return a literal representing the disjunctino of the given booleans.
Sourcepub fn assert_at_most_one(&mut self, xs: impl Iterator<Item = Bool>)
pub fn assert_at_most_one(&mut self, xs: impl Iterator<Item = Bool>)
Assert that at most one of the given booleans can be true.
Sourcepub fn assert_exactly_one<I: IntoIterator<Item = Bool>>(&mut self, xs: I)
pub fn assert_exactly_one<I: IntoIterator<Item = Bool>>(&mut self, xs: I)
Assert that exactly one of the given booleans is set to true.
Sourcepub fn implies(&mut self, a: Bool, b: Bool) -> Bool
pub fn implies(&mut self, a: Bool, b: Bool) -> Bool
Returns a literal representing the truth value of the implication a -> b
.
Sourcepub fn equiv(&mut self, a: Bool, b: Bool) -> Bool
pub fn equiv(&mut self, a: Bool, b: Bool) -> Bool
Returns a literal representing whether the two given booleans have the same value.
Sourcepub fn assert_parity<I: IntoIterator<Item = Bool>>(&mut self, xs: I, x: bool)
pub fn assert_parity<I: IntoIterator<Item = Bool>>(&mut self, xs: I, x: bool)
Assert that the odd parity bit of the given list of booleans has the given value.
Sourcepub fn assert_parity_or<I: IntoIterator<Item = Bool>, J: IntoIterator<Item = Bool>>(
&mut self,
prefix: I,
xs: J,
c: bool,
)
pub fn assert_parity_or<I: IntoIterator<Item = Bool>, J: IntoIterator<Item = Bool>>( &mut self, prefix: I, xs: J, c: bool, )
Assert that the odd parity bit of the given list of booleans has the given value,
except if any of the values in prefix
are true.
Sourcepub fn xor_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
pub fn xor_literal<I: IntoIterator<Item = Bool>>(&mut self, xs: I) -> Bool
Returns a Bool
which represents the odd parity bit for the
given sequence of Bool
values.
Sourcepub fn not_equal<T: ModelEq>(&mut self, a: &T, b: &T)
pub fn not_equal<T: ModelEq>(&mut self, a: &T, b: &T)
Assert the non-equality of the given objects.
Sourcepub fn greater_than<T: ModelOrd>(&mut self, a: &T, b: &T)
pub fn greater_than<T: ModelOrd>(&mut self, a: &T, b: &T)
Assert a > b
.
Sourcepub fn greater_than_equal<T: ModelOrd>(&mut self, a: &T, b: &T)
pub fn greater_than_equal<T: ModelOrd>(&mut self, a: &T, b: &T)
Assert a >= b
.
Sourcepub fn less_than_equal<T: ModelOrd>(&mut self, a: &T, b: &T)
pub fn less_than_equal<T: ModelOrd>(&mut self, a: &T, b: &T)
Assert a <= b
.
Sourcepub fn greater_than_or<T: ModelOrd, I: IntoIterator<Item = Bool>>(
&mut self,
prefix: I,
a: &T,
b: &T,
)
pub fn greater_than_or<T: ModelOrd, I: IntoIterator<Item = Bool>>( &mut self, prefix: I, a: &T, b: &T, )
Assert a > b
unless any of the booleans in the given prefix
are true.
Sourcepub fn greater_than_equal_or<T: ModelOrd, I: IntoIterator<Item = Bool>>(
&mut self,
prefix: I,
a: &T,
b: &T,
)
pub fn greater_than_equal_or<T: ModelOrd, I: IntoIterator<Item = Bool>>( &mut self, prefix: I, a: &T, b: &T, )
Assert a >= b
unless any of the booleans in the given prefix
are true.
Sourcepub fn less_than_or<T: ModelOrd, I: IntoIterator<Item = Bool>>(
&mut self,
prefix: I,
a: &T,
b: &T,
)
pub fn less_than_or<T: ModelOrd, I: IntoIterator<Item = Bool>>( &mut self, prefix: I, a: &T, b: &T, )
Assert a < b
unless any of the booleans in the given prefix
are true.
Sourcepub fn less_than_equal_or<T: ModelOrd, I: IntoIterator<Item = Bool>>(
&mut self,
prefix: I,
a: &T,
b: &T,
)
pub fn less_than_equal_or<T: ModelOrd, I: IntoIterator<Item = Bool>>( &mut self, prefix: I, a: &T, b: &T, )
Assert a <= b
unless any of the booleans in the given prefix
are true.
Sourcepub fn num_assigns(&self) -> isize
pub fn num_assigns(&self) -> isize
Return the number of assignments to variables made in the solver instance.
Sourcepub fn num_clauses(&self) -> isize
pub fn num_clauses(&self) -> isize
Return the number of clauses in the solver instance.
Sourcepub fn num_learnts(&self) -> isize
pub fn num_learnts(&self) -> isize
Return the number of learnt clauses in the solver instance.
Sourcepub fn num_free_vars(&self) -> isize
pub fn num_free_vars(&self) -> isize
Return the number of free variables in the solver instance.
Sourcepub fn solver_name(&self) -> &'static str
pub fn solver_name(&self) -> &'static str
Name and version of SAT solver.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Solver
impl RefUnwindSafe for Solver
impl !Send for Solver
impl !Sync for Solver
impl Unpin for Solver
impl UnwindSafe for Solver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more