16#include "dlinear/symbolic/PlaistedGreenbaumCnfizer.h"
17#include "dlinear/symbolic/PredicateAbstractor.h"
18#include "dlinear/symbolic/literal.h"
19#include "dlinear/symbolic/symbolic.h"
20#include "dlinear/util/Config.h"
21#include "dlinear/util/ScopedUnorderedMap.hpp"
22#include "dlinear/util/ScopedUnorderedSet.hpp"
23#include "dlinear/util/Stats.h"
54 virtual void Push() = 0;
55 virtual void Pop() = 0;
70 void AddFormulas(
const std::vector<Formula> &formulas);
86 void AddClauses(
const std::vector<Formula> &formulas);
156 [[nodiscard]] std::vector<std::vector<Literal>> clauses()
const;
Simple dataclass used to store the configuration of the program.
Dataclass collecting statistics about some operation or process.
Plaisted-Greenbaum transformation is a method to convert a formula into an equi-satisfiable vector of...
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
Base class for SAT solvers.
SatSolver(PredicateAbstractor &predicate_abstractor, const std::string &class_name="SatSolver")
Construct a new SatSolver object.
virtual void AddLiteral(const Literal &l, bool learned)=0
Add a literal l to the SAT solver.
virtual std::optional< Model > CheckSat()=0
Check the satisfiability of the current configuration.
IterationStats stats_
Statistics for the solver.
void AddClauses(const std::vector< Formula > &formulas)
Add a vector of formulas formulas to the solver.
void AddFormula(const Formula &f)
Add a formula f to the solver.
virtual void FixedTheoryLiterals(LiteralSet &fixed_literals)=0
Get the theory literals that are fixed in the current configuration.
ScopedUnorderedSet< Variable::Id > cnf_variables_
Set of temporary Boolean variables introduced by CNF transformations.
std::size_t cur_clause_start_
Index of the first clause added by the SAT solver.
ScopedUnorderedMap< int, Variable > sat_to_var_
Map int (Variable type in PicoSat) → symbolic::Variable.
std::vector< int > main_clauses_copy_
Store the main clauses to restore them after the SAT solver call.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the SAT solver.
void AddLiteral(const Formula &f)
Add a formula f to the solver.
virtual void AddClauseToSat(const Formula &f)=0
Add a clause f to the internal SAT solver.
Model OnSatResult()
If the SAT solver returns SAT, this function can be used to obtain a model for the formula.
ScopedUnorderedMap< Variable::Id, int > var_to_sat_
Map symbolic::Variable → int (Variable type in PicoSat).
void AddClause(const Formula &f)
Add a formula f to the solver.
PlaistedGreenbaumCnfizer cnfizer_
Converts the formula to CNF.
PredicateAbstractor & predicate_abstractor_
Converts the theory literals to boolean variables.
const Config & config_
Configuration of the SAT solver.
const IterationStats & stats() const
Get read-only access to the statistics of the SAT solver.
void AddFormulas(const std::vector< Formula > &formulas)
Add the formulas to the solver.
LiteralSet FixedTheoryLiterals()
Get the theory literals that are fixed in the current configuration.
virtual void MakeSatVar(const Variable &var)=0
Add a variable to the internal SAT solver.
void UpdateLookup(int lit)
Update data structures used to minimize the number of assigned literals the theory solver has to veri...
virtual std::set< int > GetMainActiveLiterals()=0
Get a set of the currently active literals in the clauses, ignoring those required by learned clauses...
void MarkAsCnfVariable(const Variable &var)
Mark var as a CNF variable.
void Assume(const LiteralSet &literals)
Assumption a set of literals to be fixed for the next iteration.
const IterationStats & cnfizer_stats() const
Get read-only access to the statistics of the cnfizer of the SAT solver.
virtual void AddLearnedClause(const Literal &literals)=0
Given a clause = {f}, adds a clause (¬f) to the solver.
std::map< int, std::set< std::size_t > > main_clause_lookup_
Lookup table for literals in the main clauses.
virtual void AddLearnedClause(const LiteralSet &literals)=0
Given a clause = {f₁, ..., fₙ}, adds a clause (¬f₁ ∨ ... ∨ ¬ fₙ) to the solver.
virtual void Assume(const Literal &lit)=0
Assumption a literals to be fixed for the next iteration.
Represents a symbolic variable.
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
std::pair< std::vector< Literal >, std::vector< Literal > > Model
A model is a pair of two vectors of literals.
A literal is a variable with an associated truth value, indicating whether it is true or false.