Solver class is the main interface for SAT solving in MiniSat. It implements the Conflict-Driven Clause Learning (CDCL) algorithm with activity-based variable ordering and clause learning.
Constructor and destructor
Solver()
Creates a new solver instance with default configuration.~Solver()
Virtual destructor for cleanup.Problem specification
newVar()
Adds a new variable to the solver.User preferred polarity for the variable. Can be
l_True, l_False, or l_Undef for no preference.Whether the variable should be a decision variable (eligible for selection in the decision heuristic).
The newly created variable identifier.
releaseVar()
Makes a literal true and promises to never refer to the variable again.The literal to release.
addClause()
Adds a clause to the solver. Multiple overloads are available for different clause sizes.Vector of literals forming the clause.
First literal (for unit, binary, ternary, and quaternary clauses).
Second literal (for binary, ternary, and quaternary clauses).
Third literal (for ternary and quaternary clauses).
Fourth literal (for quaternary clauses).
Returns
false if the clause makes the formula unsatisfiable, true otherwise.addEmptyClause()
Adds the empty clause, making the solver contradictory.Returns
false (the formula becomes unsatisfiable).addClause_()
Adds a clause to the solver without making superfluous internal copy.Vector of literals forming the clause. Will be modified by this method.
Returns
false if the clause makes the formula unsatisfiable, true otherwise.This method modifies the passed vector for efficiency. Use the const reference version if you need to preserve the original vector.
Solving
solve()
Searches for a satisfying assignment. Multiple overloads support different assumption sets.First assumption literal.
Second assumption literal.
Third assumption literal.
Vector of assumption literals that must be satisfied.
Returns
true if the formula is satisfiable under the given assumptions, false otherwise.If satisfiable, the model can be read from the
model member variable.solveLimited()
Searches for a model with resource constraints.Vector of assumption literals.
Returns
l_True if satisfiable, l_False if unsatisfiable, or l_Undef if the search was interrupted due to resource limits.simplify()
Removes already satisfied clauses.Returns
false if the formula is unsatisfiable, true otherwise.okay()
Checks if the solver is in a consistent state.Returns
false if the solver is in a conflicting state, true otherwise.implies()
Checks logical implications under assumptions.Vector of assumptions.
Output vector for implied literals.
Returns
true if implications were found.Variable mode
setPolarity()
Declares which polarity the decision heuristic should use for a variable.The variable to configure.
The preferred polarity:
l_True, l_False, or l_Undef.Requires the polarity mode to be set to ‘polarity_user’ in solver configuration.
setDecisionVar()
Declares if a variable should be eligible for selection in the decision heuristic.The variable to configure.
true to make the variable a decision variable, false to exclude it from decisions.Read state
value()
Gets the current value of a variable or literal.Variable to query.
Literal to query.
Current assignment:
l_True, l_False, or l_Undef if unassigned.modelValue()
Gets the value of a variable or literal in the last model.Variable to query.
Literal to query.
Value in the last model:
l_True or l_False.nAssigns()
Gets the current number of assigned literals.Number of assigned literals.
nClauses()
Gets the current number of original clauses.Number of original clauses.
nLearnts()
Gets the current number of learnt clauses.Number of learnt clauses.
nVars()
Gets the current number of variables.Total number of variables in the solver.
nFreeVars()
Gets the number of free (unassigned) variables.Number of unassigned variables.
printStats()
Prints current statistics to standard output.Resource constraints
setConfBudget()
Sets a conflict budget for the solver.Maximum number of conflicts allowed.
setPropBudget()
Sets a propagation budget for the solver.Maximum number of propagations allowed.
budgetOff()
Disables all resource budgets.interrupt()
Triggers a potentially asynchronous interruption of the solver.This method can be called from another thread to interrupt a running search.
clearInterrupt()
Clears the interrupt indicator flag.Clause iteration
clausesBegin() / clausesEnd()
Iterators for traversing original clauses.Iterator pointing to the beginning or end of the clause list.
trailBegin() / trailEnd()
Iterators for traversing top-level assignments.Iterator pointing to the beginning or end of the assignment trail.
DIMACS output
toDimacs()
Writes the CNF formula to a file in DIMACS format.Path to the output file.
Open file handle for output.
First assumption literal.
Second assumption literal.
Third assumption literal.
Vector of assumptions to include.
Specific clause to write.
Variable mapping.
Maximum variable.
Memory management
garbageCollect()
Performs garbage collection on internal clause storage.checkGarbage()
Checks if garbage collection should be triggered.Garbage fraction threshold. Collection is triggered when wasted memory exceeds this fraction.
Public member variables
Result variables
If the problem is satisfiable, this vector contains the model with variable assignments.
If unsatisfiable under assumptions, this represents the final conflict clause expressed in the assumptions.
Configuration parameters
Controls output verbosity level.
Variable activity decay factor (default 0.95).
Clause activity decay factor (default 0.999).
Frequency of random variable selection (default 0.0).
Random seed for the solver.
Use Luby restart sequence if true.
Conflict clause minimization mode: 0=none, 1=basic, 2=deep.
Phase saving level: 0=none, 1=limited, 2=full.
Use random polarities for branching heuristics.
Initialize variable activities with small random values.
Fraction of wasted memory allowed before triggering garbage collection.
Minimum learnt clause limit.
Initial restart limit (default 100).
Restart limit multiplier for each restart (default 1.5).
Initial learnt clause limit as factor of original clauses (default 1/3).
Learnt clause limit multiplier for each restart (default 1.1).
Conflict count to start adjusting learnt clause limit.
Adjustment increment for learnt clause limit.
Statistics
Number of solve calls.
Number of search restarts.
Number of decisions made.
Number of random decisions.
Number of propagations performed.
Number of conflicts encountered.
Number of decision variables.
Total number of original clauses.
Total number of learnt clauses.
Total literals in original clauses.
Total literals in learnt clauses.
Maximum literals encountered.
Total literals processed.