19#include <unordered_map>
23#include "dlinear/libs/libgmp.h"
24#include "dlinear/solver/BoundVector.h"
25#include "dlinear/symbolic/PredicateAbstractor.h"
26#include "dlinear/symbolic/environment.h"
27#include "dlinear/symbolic/literal.h"
28#include "dlinear/symbolic/symbolic.h"
29#include "dlinear/util/Config.h"
39 using Explanations = std::set<LiteralSet>;
40 using VarToEqBinomialMap = std::unordered_map<Variable, mpq_class>;
66 std::set<LiteralSet>
EnableLiterals(
const std::vector<Literal>& enabled_literals);
76 void EnableLiterals(
const std::vector<Literal>& enabled_literals, std::set<LiteralSet>& explanation);
118 void Process(Explanations& explanations);
297 const std::vector<Bound>& assumptions, Explanations& explanations);
301 const Variable* ShouldPropagateEqPolynomial(
const Formula& formula)
const;
302 const Variable* ShouldPropagateBoundsPolynomial(
const Literal& lit)
const;
303 const Variable* ShouldPropagateBoundsPolynomial(
const Formula& formula)
const;
304 bool ShouldEvaluate(
const Literal& lit)
const;
305 bool ShouldEvaluate(
const Formula& formula)
const;
310 void PropagateConstraints(std::list<Literal>& enabled_literals, Explanations& explanations);
311 void PropagateEqConstraints(std::list<Literal>& enabled_literals, Explanations& explanations);
312 void PropagateBoundConstraints(std::list<Literal>& enabled_literals, Explanations& explanations);
313 void EvaluateFormulas(std::list<Literal>& enabled_literals, Explanations& explanations);
314 void FormulaViolationExplanation(
const Literal& lit,
const Formula& formula, Explanations& explanations);
316 std::pair<Variable, Variable> ExtractBoundEdge(
const Formula& formula)
const;
333#if DEBUGGING_PREPROCESSOR
334 std::vector<Variable> GetExplanationOrigins(
const Variable& var);
353std::ostream& operator<<(std::ostream& os,
const BoundPreprocessor& preprocessor);
357#ifdef DLINEAR_INCLUDE_FMT
359#include "dlinear/util/logging.h"
This class uses some basic algebraic operations to preprocess the constraints and identify violations...
static bool IsSimpleBound(const Formula &formula)
Check whether the formula is a simple relational bound.
static bool IsGreaterThan(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with a greater than operator ( ).
std::list< mpq_class > temporary_mpq_vector_
Vector used to store temporary mpq values obtained from more complex constraints.
bool PropagateEqPolynomial(const Literal &lit, const Variable &var_to_propagate, Explanations &explanations)
Propagate the bounds of the variables in the given formula.
const BoundVectorMap & theory_bounds() const
Get read-only access to the bounds of the variables in the LP solver of the BoundPreprocessor.
const mpq_class * StoreTemporaryMpq(const mpq_class &value)
Vector used to store the mpq_class elements obtained from more complex constraints.
static bool IsLessThan(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with a less than operator ( ).
const Config & config() const
Get read-only access to the configuration of the BoundPreprocessor.
const Environment & env() const
Get read-only access to the propagated environment containing the variable's values of the BoundPrepr...
static bool IsLessThanOrEqualTo(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with a less than or equal to operator ( ).
BoundPreprocessor(const PredicateAbstractor &predicate_abstractor)
Construct a new Bound Preprocessor object using the predicate_abstractor.
static bool IsNotEqualTo(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with a non-equality operator ( ).
std::set< LiteralSet > EnableLiteral(const Literal &lit)
Enable the literal lit.
std::set< LiteralSet > EnableLiterals(const std::vector< Literal > &enabled_literals)
Preprocess all the enabled_literals.
void SetInfinityBounds(const Variable &var, const mpq_class &lb, const mpq_class &ub)
Set the lower and upper infinity bounds (lb, ub) of the variable var.
IterationStats stats_
Statistics of the preprocessing.
mpq_class ExtractEqBoundCoefficient(const Formula &formula) const
Given a formula of the form , with being constants, extract the coefficient .
const Config & config_
Configuration of the preprocessor.
bool PropagateBoundsPolynomial(const Literal &lit, const Variable &var_to_propagate, Explanations &explanations)
Propagate the bounds of the variables in the given formula.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the BoundPreprocessor.
void Clear()
Clear the preprocessor.
void GetActiveExplanation(const Variable &var, LiteralSet &explanation)
Get the active explanation for the variable var.
Explanations Process()
Process all enabled literals.
const IterationStats & stats() const
Get read-only access to the statistics of the BoundPreprocessor.
BoundVectorMap theory_bounds_
Theory bounds for each theory variable.
static bool IsGreaterThanOrEqualTo(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with a less than or equal to operator ( ).
static bool IsEqualTo(const Formula &formula, bool truth=true)
Check whether the formula is a simple relational bound with an equality operator ( ).
const PredicateAbstractor & predicate_abstractor_
Predicate abstractor used to get the constraints from the literals.
Environment env_
Environment storing the values of all the variables with a fixed value.
void AddVariable(const Variable &var)
Add a theory variable to the preprocessor.
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.
Represents a symbolic environment (mapping from a variable to a value).
Represents a symbolic variable.
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
Tuple containing the value, bound type and theory literal associated with the bound.
A literal is a variable with an associated truth value, indicating whether it is true or false.