19 namespace po = boost::program_options;
20 auto& settings = settings::Settings::getInstance();
23 parser.add(
"CAD Preprocessor settings").add_options()
24 (
"cad.pp.no-elimination", po::bool_switch(&s.disable_variable_elimination),
"disable variable elimination")
25 (
"cad.pp.no-resultants", po::bool_switch(&s.disable_resultants),
"disable resultant rule")
40 namespace preprocessor {
43 std::map<FormulaT, std::vector<std::vector<FormulaT>>>
mOrigins;
46 void add(
const FormulaT& f,
const std::vector<FormulaT>& origin);
48 const std::vector<FormulaT>&
get(
const FormulaT& f)
const;
49 bool resolve(std::set<FormulaT>& conflict)
const;
62 std::map<carl::Variable, ConstraintT>
mReasons;
91 const std::vector<carl::Variable>&
mVars;
93 std::vector<std::vector<UPoly>>
mData;
98 bool addPoly(
const UPoly& poly, std::size_t level,
const std::vector<FormulaT>& origin);
107 std::optional<std::vector<FormulaT>>
compute(
const std::map<ConstraintT,ConstraintT>& constraints);
128 const std::vector<carl::Variable>&
mVars;
148 bool addEqualities(
const std::vector<ConstraintT>& constraints);
154 bool collectOriginsOfConflict(std::set<FormulaT>& conflict,
const std::map<ConstraintT, ConstraintT>& constraints)
const;
185 template<
typename Map>
187 std::set<ConstraintT> newC;
189 if (c.second.is_consistent() == 1)
continue;
190 newC.insert(c.second);
193 if (c.second.is_consistent() == 1)
continue;
194 newC.insert(c.second);
200 std::vector<ConstraintT> toAdd;
201 std::vector<ConstraintT> toRemove;
203 for (
const auto& c: newC) {
204 if (oldC.find(c) == oldC.end()) toAdd.emplace_back(c);
206 for (
const auto& c: oldC) {
207 if (newC.find(c.first) == newC.end()) toRemove.emplace_back(c.first);
213 return {toAdd, toRemove};
225 os <<
"Equalities: " << cadpp.
mEqualities << std::endl;
228 os <<
"Model: " << cadpp.
mModel << std::endl;
CADPreprocessor(const std::vector< carl::Variable > &vars)
std::vector< ConstraintT > mEqualities
Equalities from the input.
std::map< ConstraintT, ConstraintT > mDerivedEqualities
Derived set of equalities, essentially mEqualities - mModel.
friend std::ostream & operator<<(std::ostream &os, const CADPreprocessor &cadpp)
bool collectOriginsOfConflict(std::set< FormulaT > &conflict, const std::map< ConstraintT, ConstraintT > &constraints) const
Replace constraints that have been modified by its origins in the given conflict.
bool addEqualities(const std::vector< ConstraintT > &constraints)
std::set< FormulaT > getConflict() const
void postprocessConflict(std::set< FormulaT > &mis) const
preprocessor::ResultantRule mResultants
The resultant rule.
void removeEquality(const ConstraintT &c)
std::optional< std::set< FormulaT > > mConflict
preprocessor::AssignmentCollector mAssignments
The assignment collector.
void removeConstraint(const ConstraintT &c)
bool addModelToConflict(std::set< FormulaT > &conflict, carl::Variables &added) const
const Model & model() const
bool preprocess()
Performs the preprocessing.
preprocessor::ConstraintUpdate result(const Map &oldC) const
Model mModel
The model used for variable elimination.
std::vector< ConstraintT > collectDerivedEqualities() const
const auto & equalities() const
void addConstraint(const ConstraintT &c)
std::map< ConstraintT, ConstraintT > mInequalities
Inequalities from the input.
preprocessor::Origins mOrigins
Origins of new formulas.
const auto & inequalities() const
const std::vector< carl::Variable > & mVars
Variable ordering.
FormulaT simplify(const FormulaT &f) const
bool extractAssignments(std::map< ConstraintT, ConstraintT > &constraints)
std::map< ConstraintT, carl::Variable > mConstraints
std::variant< bool, ConstraintT > CollectionResult
Result of an assignment collection.
CollectionResult simplify(std::map< ConstraintT, ConstraintT > &constraints)
CollectionResult collect(std::map< ConstraintT, ConstraintT > &constraints)
const auto & reasons() const
bool extractParametricAssignments(std::map< ConstraintT, ConstraintT > &constraints)
bool extractValueAssignments(std::map< ConstraintT, ConstraintT > &constraints)
const auto & constraints() const
std::map< carl::Variable, ConstraintT > mReasons
Reasons for the assignment of variables.
AssignmentCollector(Model &model)
const auto & getNewECs() const
std::vector< std::vector< UPoly > > mData
std::vector< ConstraintT > mNewECs
std::vector< ConstraintT > mConstraints
bool addPoly(const Poly &poly)
std::optional< std::vector< FormulaT > > compute(const std::map< ConstraintT, ConstraintT > &constraints)
std::optional< std::vector< FormulaT > > computeResultants(std::size_t level)
const std::vector< carl::Variable > & mVars
ResultantRule(Origins &origins, const std::vector< carl::Variable > &vars)
std::ostream & operator<<(std::ostream &os, const SampleIteratorQueue< I, C > &siq)
carl::UnivariatePolynomial< Poly > UPoly
const auto & settings_cadpp()
bool substitute(const FormulaT &constr, const carl::Variable var, const carl::vs::Term< Poly > &term, FormulaT &result)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::MultivariatePolynomial< Rational > Poly
carl::Constraint< Poly > ConstraintT
#define SMTRAT_LOG_DEBUG(channel, msg)
static bool register_hook()
bool disable_variable_elimination
static void register_settings(SettingsParser &parser)
std::vector< ConstraintT > toAdd
std::vector< ConstraintT > toRemove
const std::vector< FormulaT > & get(const FormulaT &f) const
bool resolve(std::set< FormulaT > &conflict) const
void cleanOrigins(const FormulaT &f)
void add(const FormulaT &f, const std::vector< FormulaT > &origin)
std::map< FormulaT, std::vector< std::vector< FormulaT > > > mOrigins
void remove(const FormulaT &f)