pub struct Solver { /* private fields */ }Expand description
The CDCL solver.
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn subsume(&mut self) -> bool
pub fn subsume(&mut self) -> bool
Run one subsumption + self-subsuming-resolution round over the learned clauses (Phase 4
inprocessing). Returns false if it proves the formula UNSAT. Verdict-invariant.
Sourcepub fn subsumptions(&self) -> u64
pub fn subsumptions(&self) -> u64
Learned clauses deleted or strengthened by subsumption during this solver’s life.
Sourcepub fn set_inprocess(&mut self, on: bool)
pub fn set_inprocess(&mut self, on: bool)
Enable or disable the between-restart inprocessing schedule (default on). For A/B benchmarking; verdict-invariant either way.
Sourcepub fn set_inprocess_interval(&mut self, conflicts: u64)
pub fn set_inprocess_interval(&mut self, conflicts: u64)
Set the conflict interval between inprocessing rounds (default INPROCESS_INTERVAL).
Tuning / test knob; verdict-invariant.
Sourcepub fn vivify(&mut self) -> bool
pub fn vivify(&mut self) -> bool
Run one vivification round over the learned clauses, strengthening each shortenable clause
in place (Phase 2 inprocessing). Returns false if vivification proves the formula UNSAT.
Verdict-invariant; intended to be scheduled at decision level 0 between restarts.
Sourcepub fn vivifications(&self) -> u64
pub fn vivifications(&self) -> u64
Learned clauses strengthened by vivification during this solver’s life. Pure observability.
Sourcepub fn probe(&mut self) -> bool
pub fn probe(&mut self) -> bool
Run one failed-literal probing round (Phase 3 inprocessing): try each phase of each free
variable as a level-0 assumption; if propagation conflicts, the opposite literal is a forced
unit, learned permanently. Returns false if probing proves the formula UNSAT.
Verdict-invariant; scheduled at decision level 0.
Sourcepub fn probes(&self) -> u64
pub fn probes(&self) -> u64
Units derived by failed-literal probing during this solver’s life. Pure observability.
Sourcepub fn set_restart_mode(&mut self, mode: RestartMode)
pub fn set_restart_mode(&mut self, mode: RestartMode)
Select the restart heuristic (default RestartMode::Glucose). Search-order only — a
verdict is unaffected, so this is for A/B tuning.
Sourcepub fn restart_mode(&self) -> RestartMode
pub fn restart_mode(&self) -> RestartMode
The restart heuristic in force.
Sourcepub fn blocked_restarts(&self) -> u64
pub fn blocked_restarts(&self) -> u64
Restarts suppressed by Glucose blocking during the last solve.
Sourcepub fn add_vars(&mut self, k: usize) -> usize
pub fn add_vars(&mut self, k: usize) -> usize
Restrict branching to vars (DPLL(XOR): the engine’s non-pivot variables; the theory forces
the rest). A model is still complete because theory propagation assigns every excluded
variable before all decision variables are exhausted.
Grow the solver by k fresh variables, numbered after those it has, and return the first one’s number: each
unassigned and unconstrained, a decision variable unless a decision set restricts them (one then joins it by
Solver::add_decision_vars). A user that encodes a formula a part at a time numbers its variables densely
as it goes, so a solver is as large as what it was asked.
Sourcepub fn add_decision_vars(&mut self, vars: &[usize])
pub fn add_decision_vars(&mut self, vars: &[usize])
Add vars to the variables decisions fall on, beside those already there: an incremental user grows the set as
it adds the clauses that constrain them. Without a set yet, every variable is one already. Out-of-range and
repeated variables are ignored.
pub fn set_decision_vars(&mut self, vars: &[usize])
Sourcepub fn propagations(&self) -> u64
pub fn propagations(&self) -> u64
Total BCP propagations during the last solve — the throughput metric.
Sourcepub fn set_reduce(&mut self, on: bool)
pub fn set_reduce(&mut self, on: bool)
Enable or disable LBD-based learned-clause deletion (default on). For A/B benchmarking.
Sourcepub fn set_reduce_limit(&mut self, limit: usize)
pub fn set_reduce_limit(&mut self, limit: usize)
Set the live-learned-clause count that triggers a reduction (tuning / stress-testing).
Sourcepub fn set_initial_phase(&mut self, phases: &[bool])
pub fn set_initial_phase(&mut self, phases: &[bool])
Seed the saved-phase polarities (the order decisions try first) from an external assignment. Purely a search-order hint — it never changes which models exist, so it cannot affect the verdict — but starting decisions on, e.g., a GF(2)-consistent assignment lets the hybrid XOR route begin on the linear system’s solution manifold and only repair the residual clauses.
Sourcepub fn live_learned(&self) -> usize
pub fn live_learned(&self) -> usize
The number of learned clauses currently live in the database (originals excluded).
Sourcepub fn learned(&self) -> &[LearnedClause]
pub fn learned(&self) -> &[LearnedClause]
The learned clauses produced during the last solve (the DRAT/LRAT proof skeleton).
Sourcepub fn take_learned(&mut self) -> Vec<LearnedClause>
pub fn take_learned(&mut self) -> Vec<LearnedClause>
The learned clauses since the last take, moved out: a caller that keeps its own proof log takes each once, so the solver does not hold every one for its whole life.
Sourcepub fn live_ids(&self) -> &[u64]
pub fn live_ids(&self) -> &[u64]
The ids of the clauses the database holds. A hint a later solve gives names one of these or a clause it learned since, so a proof log may forget whatever none of them rests on.
Sourcepub fn original_clauses(&self) -> &[Vec<Lit>]
pub fn original_clauses(&self) -> &[Vec<Lit>]
The ORIGINAL clauses (those present before solving), borrowed in place — so a RUP checker can replay over them without copying the clause set.
Sourcepub fn add_clause(&mut self, lits: Vec<Lit>)
pub fn add_clause(&mut self, lits: Vec<Lit>)
Add a clause. An empty clause makes the formula trivially unsatisfiable; a unit clause is enqueued as a top-level fact. Between incremental solves the search is dropped first and the clause read against the level-0 facts: its literals not yet false lead, so the two it watches are ones that can still become false; one left is a fact enqueued now, none left makes the formula unsatisfiable.
Sourcepub fn add_clause_with_id(&mut self, lits: Vec<Lit>, id: u64)
pub fn add_clause_with_id(&mut self, lits: Vec<Lit>, id: u64)
Solver::add_clause with the id the clause’s hints name it by chosen by the caller, above every id before it.
A tautology is dropped and its id left unused.
Sourcepub fn set_next_clause_id(&mut self, id: u64)
pub fn set_next_clause_id(&mut self, id: u64)
Number the clauses the solver makes from id on (when that is above every id it has used): a caller that gives
its own clauses ids from another range keeps the two apart.
Sourcepub fn next_clause_id(&mut self) -> u64
pub fn next_clause_id(&mut self) -> u64
The next clause id, taken: one a caller gives a clause it derives itself.
Sourcepub fn set_lrat(&mut self, on: bool)
pub fn set_lrat(&mut self, on: bool)
Record LRAT hints: each learned clause’s, and each refutation’s (see Solver::unsat_hints). For pure CNF
solving: inprocessing, which strengthens clauses without a chain, is turned off, and a theory’s clauses carry
none.
Sourcepub fn unsat_hints(&self) -> &[u64]
pub fn unsat_hints(&self) -> &[u64]
After an unsatisfiable solve under assumptions, with tracing on: the hints of the clause of the assumptions’ negations (the empty clause’s when the formula itself is unsatisfiable), each id in order a clause that is unit under that clause’s negation, the last conflicting.
Sourcepub fn solve(&mut self) -> SolveResult
pub fn solve(&mut self) -> SolveResult
Solve, optionally under a list of theory propagators (DPLL(T)). Returns a model or
Unsat. The learned-clause log is available afterwards via Solver::learned.
Sourcepub fn solve_budgeted(&mut self, max_conflicts: u64) -> BudgetedResult
pub fn solve_budgeted(&mut self, max_conflicts: u64) -> BudgetedResult
Solve but give up after max_conflicts conflicts, returning BudgetedResult::Budget with
the learned clauses (Self::learned) intact — the hook dynamic symmetry breaking needs to
interleave bounded search with symmetric clause amplification. A max_conflicts of 0 means
unlimited (equivalent to Self::solve).
Sourcepub fn solve_with(&mut self, theories: &mut [Box<dyn Theory>]) -> SolveResult
pub fn solve_with(&mut self, theories: &mut [Box<dyn Theory>]) -> SolveResult
Solve with theory propagators. Each is consulted at every Boolean fixpoint; a returned clause is added to the formula (and may immediately propagate or conflict).
Sourcepub fn solve_under_assumptions(&mut self, assumptions: &[Lit]) -> SolveResult
pub fn solve_under_assumptions(&mut self, assumptions: &[Lit]) -> SolveResult
Solve under temporary assumptions (literals forced true for THIS query only),
reusing every clause learned so far. The permanent clause database is untouched, so a
later call with different assumptions may well be satisfiable — successive queries on
the same solver (e.g. BMC at increasing depths) amortise learning. This is the
incremental-SAT (IPASIR) pattern. Unsat here means “unsatisfiable UNDER these
assumptions”.
Soundness of reuse: conflict analysis keeps decision-level literals (assumptions are decisions) and drops level-0 facts, so each learned clause is a consequence of the PERMANENT clauses alone — valid no matter which assumptions a future query makes.
Restarts follow the Luby sequence (100 conflicts a unit) and drop the search to level 0:
the next decisions place the assumptions again, so they stay the bottom levels.
(Does not touch n_original; do not mix with Solver::original_clauses/RUP on the
same solver.)
Sourcepub fn solve_under_assumptions_budgeted(
&mut self,
assumptions: &[Lit],
max_conflicts: u64,
) -> BudgetedResult
pub fn solve_under_assumptions_budgeted( &mut self, assumptions: &[Lit], max_conflicts: u64, ) -> BudgetedResult
Solver::solve_under_assumptions within max_conflicts conflicts (0: no limit), Budget when they run out
with the search dropped and every learned clause kept. On Unsat, the clause of the assumptions’ negations is
RUP from the clauses added and Solver::learned so far. Learned clauses are deleted, the added ones never,
whatever their order: a long run of queries keeps its database in bounds.