pub struct Dpll<Config: SolverConfig + Clone = DefaultConfig> {
pub trail: Trail<Config::Literal, Config::LiteralStorage>,
pub assignment: Config::Assignment,
pub decision_level: DecisionLevel,
pub cnf: Cnf<Config::Literal, Config::LiteralStorage>,
pub selector: Config::VariableSelector,
pub propagator: Config::Propagator,
}Expand description
Represents a DPLL SAT solver.
This struct encapsulates the state of the solver, including the CNF formula,
current assignment, decision level, and components for propagation and
variable selection. It is generic over Config, which defines the specific
types and strategies used by the solver.
Fields§
§trail: Trail<Config::Literal, Config::LiteralStorage>The trail of assignments and decisions made by the solver. It’s used by the propagator to manage assignments and detect conflicts.
assignment: Config::AssignmentThe current assignment of truth values to variables.
decision_level: DecisionLevelThe current decision level in the DPLL search tree. Incremented each time a new variable is chosen for branching.
cnf: Cnf<Config::Literal, Config::LiteralStorage>The Conjunctive Normal Form (CNF) formula being solved.
selector: Config::VariableSelectorThe variable selection heuristic. Used to pick the next unassigned variable for a decision.
propagator: Config::PropagatorThe unit propagator. Responsible for performing unit propagation based on the current assignment.
Trait Implementations§
Source§impl<Config: Clone + SolverConfig + Clone> Clone for Dpll<Config>where
Config::Literal: Clone,
Config::LiteralStorage: Clone,
Config::Assignment: Clone,
Config::VariableSelector: Clone,
Config::Propagator: Clone,
impl<Config: Clone + SolverConfig + Clone> Clone for Dpll<Config>where
Config::Literal: Clone,
Config::LiteralStorage: Clone,
Config::Assignment: Clone,
Config::VariableSelector: Clone,
Config::Propagator: Clone,
Source§impl<Config: Debug + SolverConfig + Clone> Debug for Dpll<Config>where
Config::Literal: Debug,
Config::LiteralStorage: Debug,
Config::Assignment: Debug,
Config::VariableSelector: Debug,
Config::Propagator: Debug,
impl<Config: Debug + SolverConfig + Clone> Debug for Dpll<Config>where
Config::Literal: Debug,
Config::LiteralStorage: Debug,
Config::Assignment: Debug,
Config::VariableSelector: Debug,
Config::Propagator: Debug,
Source§impl<Config: SolverConfig + Clone> Solver<Config> for Dpll<Config>
impl<Config: SolverConfig + Clone> Solver<Config> for Dpll<Config>
Source§fn solve(&mut self) -> Option<Solutions>
fn solve(&mut self) -> Option<Solutions>
Attempts to solve the SAT formula.
This method implements the core DPLL algorithm:
- It first performs unit propagation (
self.propagate()). - Then, it checks if the formula is already satisfied (
self.is_sat()). If so, it returns the current assignment. - It checks if the formula is unsatisfiable (
self.is_unsat()) due to a conflict. If so, it returnsNone. - If the formula is neither satisfied nor unsatisfiable, it selects an unassigned
variable using
self.selector.pick(). - It increments the decision level.
- It creates two branches: one where the chosen variable is assigned
true, and one where it’s assignedfalse. These branches are explored recursively by callingsolve()on cloned solver states. - If the ‘true’ branch finds a solution, it’s returned.
- Otherwise, if the ‘false’ branch finds a solution, it’s returned.
- If neither branch finds a solution, the formula is unsatisfiable from the
current state, and
Noneis returned.
§Returns
Some(Solutions): If the formula is satisfiable, containing the satisfying assignment.None: If the formula is unsatisfiable.
Source§fn solutions(&self) -> Solutions
fn solutions(&self) -> Solutions
Returns the current satisfying assignment if the formula is SAT.
This method should typically be called after solve() returns Some(...).
It retrieves the model (variable assignments) from the assignment component.
Variables not assigned a value in the model might be “don’t care” variables.
Source§fn stats(&self) -> SolutionStats
fn stats(&self) -> SolutionStats
Returns statistics about the solving process.
Note: Some statistics, like propagations, might be estimations or
specific to this simple DPLL implementation rather than a general count
of propagation steps.
conflicts, restarts, learnt_clauses, removed_clauses are currently placeholders.
Source§fn debug(&mut self)
fn debug(&mut self)
Placeholder for a debugging function.
Currently, this function is not implemented and will panic if called.
Source§fn from_parts<L: Literal, S: LiteralStorage<L>>(
cnf: Cnf<L, S>,
assignment: Config::Assignment,
_manager: Config::ClauseManager,
propagator: Config::Propagator,
_restarter: Config::Restarter,
selector: Config::VariableSelector,
) -> Self
fn from_parts<L: Literal, S: LiteralStorage<L>>( cnf: Cnf<L, S>, assignment: Config::Assignment, _manager: Config::ClauseManager, propagator: Config::Propagator, _restarter: Config::Restarter, selector: Config::VariableSelector, ) -> Self
Auto Trait Implementations§
impl<Config> Freeze for Dpll<Config>where
<Config as SolverConfig>::Assignment: Freeze,
<Config as SolverConfig>::VariableSelector: Freeze,
<Config as SolverConfig>::Propagator: Freeze,
impl<Config> RefUnwindSafe for Dpll<Config>where
<Config as SolverConfig>::Assignment: RefUnwindSafe,
<Config as SolverConfig>::VariableSelector: RefUnwindSafe,
<Config as SolverConfig>::Propagator: RefUnwindSafe,
<Config as SolverConfig>::LiteralStorage: RefUnwindSafe,
<Config as SolverConfig>::Literal: RefUnwindSafe,
impl<Config = DefaultConfig> !Send for Dpll<Config>
impl<Config = DefaultConfig> !Sync for Dpll<Config>
impl<Config> Unpin for Dpll<Config>where
<Config as SolverConfig>::Assignment: Unpin,
<Config as SolverConfig>::VariableSelector: Unpin,
<Config as SolverConfig>::Propagator: Unpin,
<Config as SolverConfig>::Literal: Unpin,
<Config as SolverConfig>::LiteralStorage: Unpin,
impl<Config> UnwindSafe for Dpll<Config>where
<Config as SolverConfig>::Assignment: UnwindSafe,
<Config as SolverConfig>::VariableSelector: UnwindSafe,
<Config as SolverConfig>::Propagator: UnwindSafe,
<Config as SolverConfig>::LiteralStorage: RefUnwindSafe + UnwindSafe,
<Config as SolverConfig>::Literal: UnwindSafe + RefUnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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