15#include "dlinear/libs/libgmp.h"
16#include "dlinear/solver/BoundIterator.h"
17#include "dlinear/solver/BoundPreprocessor.h"
18#include "dlinear/solver/LpColBound.h"
19#include "dlinear/solver/SatResult.h"
20#include "dlinear/symbolic/PredicateAbstractor.h"
21#include "dlinear/symbolic/literal.h"
22#include "dlinear/symbolic/symbolic.h"
23#include "dlinear/util/Box.h"
24#include "dlinear/util/Config.h"
25#include "dlinear/util/Stats.h"
39 using Bound = std::tuple<const Variable &, LpColBound, const mpq_class &>;
54 const std::string &class_name =
"TheorySolver");
110 [[nodiscard]]
const Box &
model()
const;
156 SatResult CheckSat(
const Box &box, mpq_class *actual_precision, std::set<LiteralSet> &explanations);
193 virtual void Reset();
202 void DumpEnabledLiterals();
210 UPPER_BOUND_VIOLATION,
213 void BoundsToTheoryRows(
const Variable &var,
const mpq_class &value, std::set<int> &theory_rows)
const;
282#ifdef DLINEAR_INCLUDE_FMT
284#include "dlinear/util/logging.h"
This class uses some basic algebraic operations to preprocess the constraints and identify violations...
const BoundVectorMap & theory_bounds() const
Get read-only access to the bounds of the variables in the LP solver of the BoundPreprocessor.
Collection of variables with associated intervals.
Simple dataclass used to store the configuration of the program.
Dataclass collecting statistics about some operation or process.
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
Base class for theory solvers.
virtual void UpdateModelSolution()=0
Update the model with the solution obtained from the LP solver.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the TheorySolver.
virtual void Reset()
Reset the linear problem.
BoundPreprocessor & m_preprocessor()
Get read-write access to the bound preprocessor of the TheorySolver.
BoundPreprocessor preprocessor_
Preprocessor for the bounds.
virtual SatResult CheckSatCore(mpq_class *actual_precision, std::set< LiteralSet > &explanations)=0
Check the satisfiability of the theory.
const BoundVectorMap & theory_bounds() const
Get read-only access to the bounds of each theory variable of the TheorySolver.
Box model_
Model produced by the theory solver.
std::size_t theory_col_count() const
Get read-only access to the number of columns of the TheorySolver.
virtual void UpdateModelBounds()=0
Update each variable in the model with the bounds passed to the theory solver.
std::vector< Literal > theory_row_to_lit_
Theory row ⇔ Literal The row is the constraint used by the theory solver.
const std::map< Variable::Id, int > & lit_to_theory_row() const
Get read-only access to the map of literals to the theory rows of the TheorySolver.
const BoundPreprocessor & preprocessor() const
Get read-only access to the bound preprocessor of the TheorySolver.
virtual void AddLiteral(const Variable &formula_var, const Formula &formula)=0
Add a Literal to the theory solver.
TheorySolver(const PredicateAbstractor &predicate_abstractor, const std::string &class_name="TheorySolver")
Construct a new Theory Solver object.
const Config & config() const
Get read-only access to the configuration of the TheorySolver.
virtual Explanations PreprocessFixedLiterals(const LiteralSet &fixed_literals)
Add the fixed literals to the theory solver.
std::map< Variable::Id, int > lit_to_theory_row_
Literal ⇔ theory row.
std::vector< bool > theory_rows_state_
Whether each theory row is enabled or not.
BoundViolationType
Enum used to describe how the bounds on a variable participate in the infeasibility result of an LP p...
@ NO_BOUND_VIOLATION
The bounds of the variable have no role in the infeasibility.
@ LOWER_BOUND_VIOLATION
The lower bound is involved in the infeasibility.
const std::vector< Variable > & theory_col_to_var() const
Get read-only access to the map of theory columns to the variables of the TheorySolver.
BoundPreprocessor & m_fixed_preprocessor()
Get read-write access to the fixed bound preprocessor of the TheorySolver.
const BoundVectorMap & fixed_theory_bounds() const
Get read-only access to the fixed bounds of each theory variable of the TheorySolver.
const Config & config_
Configuration of the theory solver.
std::set< Literal > enabled_literals() const
Get read-only access to the vector of enabled literals of the TheorySolver.
virtual void UpdateExplanation(LiteralSet &explanation)=0
Use the result from the theory solver to update the explanation with the conflict that has been detec...
std::set< LiteralSet > Explanations
Set of explanations of the conflict.
virtual void AddVariable(const Variable &var)=0
Add a variable (column) to the theory solver.
const PredicateAbstractor & predicate_abstractor_
Predicate abstractor used to create the theory solver.
std::size_t theory_row_count() const
Get read-only access to the number of rows of the TheorySolver.
Explanations EnableLiterals(std::span< const Literal > theory_literals)
Activate the literals that have previously been added to the theory solver.
bool is_consolidated_
Whether the solver has been consolidated.
const Box & model() const
Get read-only access to the model that satisfies all the constraints of the TheorySolver.
virtual void AddLiterals()
Add a vector of literals to the theory solver.
std::map< Variable::Id, int > var_to_theory_col_
Variable ⇔ theory column.
const std::vector< Literal > & theory_row_to_lit() const
Get read-only access to the map of theory rows to the literals of the TheorySolver.
BoundPreprocessor fixed_preprocessor_
Preprocessor for the bounds. Only computed on fixed literal theories.
virtual Explanations EnableLiteral(const Literal &lit)=0
Activate the literal that had previously been added to the theory solver.
const BoundPreprocessor & fixed_preprocessor() const
Get read-only access to the fixed bound preprocessor of the TheorySolver.
void UpdateExplanations(Explanations &explanations)
Use the result from the theory solver to update the explanations with the conflict that has been dete...
std::tuple< const Variable &, LpColBound, const mpq_class & > Bound
Bound on the variable.
virtual void Consolidate(const Box &box)
Consolidate the solver.
const IterationStats & stats() const
Get the statistics of the theory solver.
const std::map< Variable::Id, int > & var_to_theory_col() const
Get read-only access to the map of variables to the theory columns of the TheorySolver.
std::vector< Variable > theory_col_to_var_
Theory column ⇔ Variable.
SatResult CheckSat(const Box &box, mpq_class *actual_precision, std::set< LiteralSet > &explanations)
Check the satisfiability of the theory.
IterationStats stats_
Statistics of the theory solver.
Represents a symbolic variable.
Global namespace for the dlinear library.
SatResult
Result of running the theory solver over the literals decided by the SAT solver.
std::set< Literal > LiteralSet
A set of literals.
A literal is a variable with an associated truth value, indicating whether it is true or false.