17 #include <carl-common/config.h>
21 template<
typename Settings>
27 std::vector<carl::Variable> mOrdering;
29 void addPoly(std::map<carl::Variable, std::size_t>& ordermap,
const Poly& p) {
30 for (
auto var: carl::variables(p)) {
31 auto it = ordermap.find(
var);
32 if (it == ordermap.end()) {
33 ordermap.emplace(
var, 1);
39 void makeOrdering(
const std::map<carl::Variable, std::size_t>& ordermap) {
40 std::vector<std::pair<std::size_t, carl::Variable>> flatorder;
41 for (
const auto& v: ordermap) {
42 flatorder.emplace_back(v.second, v.first);
44 std::sort(flatorder.begin(), flatorder.end());
45 for (
const auto& t: flatorder) {
46 mOrdering.emplace_back(t.second);
51 std::map<carl::Variable, std::size_t> ordermap;
52 for (
const auto& p: polys) addPoly(ordermap, p);
53 makeOrdering(ordermap);
55 const std::vector<carl::Variable>& getOrdering()
const {
61 std::map<ConstraintT, carl::Variable> mAuxVariables;
63 std::map<ConstraintT, Poly> mGBPolys;
65 std::vector<Poly> mLastBasis;
69 auto it = mAuxVariables.find(c);
70 if (it != mAuxVariables.end()) {
73 return mAuxVariables.emplace(c, carl::fresh_real_variable()).first->second;
80 if (!Settings::convert_inequalities) {
83 carl::Variable aux = getAuxVar(c);
84 switch (c.relation()) {
85 case carl::Relation::GEQ:
86 return c.lhs() +
TermT(-1, aux, 2);
87 case carl::Relation::LEQ:
88 return c.lhs() +
TermT(1, aux, 2);
89 case carl::Relation::GREATER:
90 return c.lhs() * aux * aux -
Rational(1);
91 case carl::Relation::LESS:
92 return c.lhs() * aux * aux +
Rational(1);
93 case carl::Relation::NEQ:
104 return SettingsType::moduleName;
A base class for all kind of theory solving methods.
virtual void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
virtual bool addCore([[maybe_unused]] ModuleInput::const_iterator formula)
The module has to take the given sub-formula of the received formula into account.
virtual std::string moduleName() const
virtual void updateModel() const
Updates the model, if the solver has detected the consistency of the received formula,...
virtual void removeCore([[maybe_unused]] ModuleInput::const_iterator formula)
Removes everything related to the given sub-formula of the received formula.
virtual bool informCore([[maybe_unused]] const FormulaT &_constraint)
Informs the module about the given constraint.
virtual Answer checkCore()
Checks the received formula for consistency.
void sort(T *array, int size, LessThan lt)
std::vector< carl::Variable > VariableOrdering
Class to create the formulas for axioms.
carl::Term< Rational > TermT
carl::Formula< Poly > FormulaT
const settings::Settings & Settings()
carl::MultivariatePolynomial< Rational > Poly
Answer
An enum with the possible answers a Module can give.
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
carl::Constraint< Poly > ConstraintT