carl  24.04
Computer ARithmetic Library
substitute.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <bitset>
4 #include <vector>
6 
7 #include "term.h"
8 #include "zeros.h"
9 
10 
11 /**
12  * The maximal number of splits performed, if the left-hand side of a constraints is a product of
13  * polynomials and we split the constraint into constraints over these polynomials according to the
14  * relation.
15  */
16 const unsigned MAX_PRODUCT_SPLIT_NUMBER = 64;
17 /**
18  * The maximum number of the resulting combinations when combining according to the method combine.
19  * If this number is exceeded, the method return false, and no combining is performed.
20  */
21 const unsigned MAX_NUM_OF_COMBINATION_RESULT = 1025;
22 
23 namespace carl::vs {
24  /// a vector of constraints
25  template<typename Poly>
26  using ConstraintConjunction = std::vector<Constraint<Poly>>;
27  /// a vector of vectors of constraints
28  template<typename Poly>
29  using CaseDistinction = std::vector<ConstraintConjunction<Poly>>;
30 }
31 
32 namespace carl::vs::detail {
33  template<class Poly>
34  struct Substitution {
38  const carl::Variable& variable() const {
39  return m_variable;
40  }
41  const Term<Poly>& term() const {
42  return m_term;
43  }
44  };
45  template<class Poly>
46  inline std::ostream& operator<<(std::ostream& os, const Substitution<Poly>& s) {
47  os << "[" << s.term() << "//" << s.variable() << "]";
48  return os;
49  }
50 
52  using EvalDoubleIntervalMap = std::map<carl::Variable, DoubleInterval>;
53 
54  /**
55  * Combines vectors.
56  * @param _toCombine The vectors to combine.
57  * @param _combination The resulting combination.
58  * @return false, if the upper limit in the number of combinations resulting by this method is exceeded.
59  * Note, that this hinders a combinatorial blow up.
60  * true, otherwise.
61  */
62  template <class combineType>
63  inline bool combine( const std::vector< std::vector< std::vector< combineType > > >& _toCombine, std::vector< std::vector< combineType > >& _combination );
64 
65  /**
66  * Simplifies a disjunction of conjunctions of constraints by deleting consistent
67  * constraint and inconsistent conjunctions of constraints. If a conjunction of
68  * only consistent constraints exists, the simplified disjunction contains one
69  * empty conjunction.
70  * @param _toSimplify The disjunction of conjunctions to simplify.
71  */
72  template<typename Poly>
74 
75  /**
76  * Simplifies a disjunction of conjunctions of constraints by deleting consistent
77  * constraint and inconsistent conjunctions of constraints. If a conjunction of
78  * only consistent constraints exists, the simplified disjunction contains one
79  * empty conjunction.
80  * @param _toSimplify The disjunction of conjunctions to simplify.
81  * @param _conflictingVars
82  * @param _solutionSpace
83  */
84  template<typename Poly>
86 
87  /**
88  * Splits all constraints in the given disjunction of conjunctions of constraints having a non-trivial
89  * factorization into a set of constraints which compare the factors instead.
90  * @param _toSimplify The disjunction of conjunctions of the constraints to split.
91  * @param _onlyNeq A flag indicating that only constraints with the relation symbol != are split.
92  * @return false, if the upper limit in the number of combinations resulting by this method is exceeded.
93  * Note, that this hinders a combinatorial blow up.
94  * true, otherwise.
95  */
96  template<typename Poly>
97  inline bool splitProducts( CaseDistinction<Poly>&, bool = false );
98 
99  /**
100  * Splits all constraints in the given conjunction of constraints having a non-trivial
101  * factorization into a set of constraints which compare the factors instead.
102  * @param _toSimplify The conjunction of the constraints to split.
103  * @param _result The result, being a disjunction of conjunctions of constraints.
104  * @param _onlyNeq A flag indicating that only constraints with the relation symbol != are split.
105  * @return false, if the upper limit in the number of combinations resulting by this method is exceeded.
106  * Note, that this hinders a combinatorial blow up.
107  * true, otherwise.
108  */
109  template<typename Poly>
111 
112  /**
113  * Splits the given constraint into a set of constraints which compare the factors of the
114  * factorization of the constraints considered polynomial.
115  * @param _constraint A pointer to the constraint to split.
116  * @param _onlyNeq A flag indicating that only constraints with the relation symbol != are split.
117  * @return The resulting disjunction of conjunctions of constraints, which is semantically equivalent to
118  * the given constraint.
119  */
120  template<typename Poly>
121  inline CaseDistinction<Poly> splitProducts( const Constraint<Poly>&, bool = false );
122 
123  template<typename Poly>
125 
126  /**
127  * For a given constraint f_1*...*f_n ~ 0 this method computes all combinations of constraints
128  * f_1 ~_1 0 ... f_n ~_n 0 such that
129  *
130  * f_1 ~_1 0 and ... and f_n ~_n 0 iff f_1*...*f_n ~ 0
131  * holds.
132  * @param _constraint A pointer to the constraint to split this way.
133  * @return The resulting combinations.
134  */
135  template<typename Poly>
137 
138  /**
139  * @param _length The maximal length of the bit strings with odd parity to compute.
140  * @param _strings All bit strings of length less or equal the given length with odd parity.
141  */
142  inline void getOddBitStrings( size_t _length, std::vector< std::bitset<MAX_PRODUCT_SPLIT_NUMBER> >& _strings );
143 
144  /**
145  * @param _length The maximal length of the bit strings with even parity to compute.
146  * @param _strings All bit strings of length less or equal the given length with even parity.
147  */
148  inline void getEvenBitStrings( size_t _length, std::vector< std::bitset<MAX_PRODUCT_SPLIT_NUMBER> >& _strings );
149 
150  /**
151  * Prints the given disjunction of conjunction of constraints.
152  * @param _substitutionResults The disjunction of conjunction of constraints to print.
153  */
154  template<typename Poly>
155  inline void print( CaseDistinction<Poly>& _substitutionResults );
156 
157  /**
158  * Applies a substitution to a constraint and stores the results in the given vector.
159  * @param _cons The constraint to substitute in.
160  * @param _subs The substitution to apply.
161  * @param _result The vector, in which to store the results of this substitution.
162  * @return false, if the upper limit in the number of combinations in the result of the substitution is exceeded.
163  * Note, that this hinders a combinatorial blow up.
164  * true, otherwise.
165  */
166  template<typename Poly>
168 
169  /**
170  * Applies a substitution of a variable to a term, which is not minus infinity nor a to an square root expression plus an infinitesimal.
171  * @param _cons The constraint to substitute in.
172  * @param _subs The substitution to apply.
173  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
174  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
175  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
176  * degree in the result by splitting the result in more cases (false).
177  * @param _conflictingVariables If a conflict with the given solution space occurs, the variables being part of this conflict are stored in this
178  * container.
179  * @param _solutionSpace The solution space in form of double intervals of the variables occurring in the given constraint.
180  */
181  template<typename Poly>
182  inline bool substituteNormal( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, CaseDistinction<Poly>& _result, bool _accordingPaper, carl::Variables& _conflictingVariables, const detail::EvalDoubleIntervalMap& _solutionSpace );
183 
184  /**
185  * Sub-method of substituteNormalSqrt, where applying the substitution led to a term
186  * containing a square root. The relation symbol of the constraint to substitute is "=".
187  *
188  * (_q+_r*sqrt(_radicand))
189  * The term then looks like: ------------------
190  * _s
191  *
192  * @param _radicand The radicand of the square root.
193  * @param _q The summand not containing the square root.
194  * @param _r The coefficient of the radicand.
195  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
196  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
197  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
198  * degree in the result by splitting the result in more cases (false).
199  */
200  template<typename Poly>
201  inline bool substituteNormalSqrtEq( const Poly& _radicand, const Poly& _q, const Poly& _r, CaseDistinction<Poly>& _result, bool _accordingPaper );
202 
203  /**
204  * Sub-method of substituteNormalSqrt, where applying the substitution led to a term
205  * containing a square root. The relation symbol of the constraint to substitute is "!=".
206  *
207  * (_q+_r*sqrt(_radicand))
208  * The term then looks like: -----------------------
209  * _s
210  *
211  * @param _radicand The radicand of the square root.
212  * @param _q The summand not containing the square root.
213  * @param _r The coefficient of the radicand.
214  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
215  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
216  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
217  * degree in the result by splitting the result in more cases (false).
218  */
219  template<typename Poly>
220  inline bool substituteNormalSqrtNeq( const Poly& _radicand, const Poly& _q, const Poly& _r, CaseDistinction<Poly>& _result, bool _accordingPaper );
221 
222  /**
223  * Sub-method of substituteNormalSqrt, where applying the substitution led to a term
224  * containing a square root. The relation symbol of the constraint to substitute is less.
225  *
226  * (_q+_r*sqrt(_radicand))
227  * The term then looks like: ----------------------
228  * _s
229  *
230  * @param _radicand The radicand of the square root.
231  * @param _q The summand not containing the square root.
232  * @param _r The coefficient of the radicand.
233  * @param _s The denominator of the expression containing the square root.
234  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
235  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
236  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
237  * degree in the result by splitting the result in more cases (false).
238  */
239  template<typename Poly>
240  inline bool substituteNormalSqrtLess( const Poly& _radicand, const Poly& _q, const Poly& _r, const Poly& _s, CaseDistinction<Poly>& _result, bool _accordingPaper );
241 
242  /**
243  * Sub-method of substituteNormalSqrt, where applying the substitution led to a term
244  * containing a square root. The relation symbol of the constraint to substitute is less or equal.
245  *
246  * (_q+_r*sqrt(_radicand))
247  * The term then looks like: ----------------------
248  * _s
249  *
250  * @param _radicand The radicand of the square root.
251  * @param _q The summand not containing the square root.
252  * @param _r The coefficient of the radicand.
253  * @param _s The denominator of the expression containing the square root.
254  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
255  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
256  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
257  * degree in the result by splitting the result in more cases (false).
258  */
259  template<typename Poly>
260  inline bool substituteNormalSqrtLeq( const Poly& _radicand, const Poly& _q, const Poly& _r, const Poly& _s, CaseDistinction<Poly>& _result, bool _accordingPaper );
261 
262  /**
263  * Applies the given substitution to the given constraint, where the substitution
264  * is of the form [x -> t+epsilon] with x as the variable and c and b polynomials in
265  * the real theory excluding x. The constraint is of the form "f(x) \rho 0" with
266  * \rho element of {=,!=,<,>,<=,>=} and k as the maximum degree of x in f.
267  *
268  * @param _cons The constraint to substitute in.
269  * @param _subs The substitution to apply.
270  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
271  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
272  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
273  * degree in the result by splitting the result in more cases (false).
274  * @param _conflictingVariables If a conflict with the given solution space occurs, the variables being part of this conflict are stored in this
275  * container.
276  * @param _solutionSpace The solution space in form of double intervals of the variables occurring in the given constraint.
277  */
278  template<typename Poly>
279  inline bool substitutePlusEps( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, CaseDistinction<Poly>& _result, bool _accordingPaper, carl::Variables& _conflictingVariables, const detail::EvalDoubleIntervalMap& _solutionSpace );
280 
281  /**
282  * Sub-method of substituteEps, where one of the gradients in the
283  * point represented by the substitution must be negative if the given relation is less
284  * or positive if the given relation is greater.
285  * @param _cons The constraint to substitute in.
286  * @param _subs The substitution to apply.
287  * @param _relation The relation symbol, deciding whether the substitution result must be negative or positive.
288  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
289  * @param _accordingPaper A flag that indicates whether to apply the virtual substitution rules according to the paper "Quantifier elimination
290  * for real algebra - the quadratic case and beyond." by Volker Weispfenning (true) or in an adapted way which omits a higher
291  * degree in the result by splitting the result in more cases (false).
292  * @param _conflictingVariables If a conflict with the given solution space occurs, the variables being part of this conflict are stored in this
293  * container.
294  * @param _solutionSpace The solution space in form of double intervals of the variables occurring in the given constraint.
295  */
296  template<typename Poly>
297  inline bool substituteEpsGradients( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, const carl::Relation _relation, CaseDistinction<Poly>&, bool _accordingPaper, carl::Variables& _conflictingVariables, const detail::EvalDoubleIntervalMap& _solutionSpace );
298 
299  /**
300  * Applies the given substitution to the given constraint, where the substitution
301  * is of the form [x -> -infinity] with x as the variable and c and b polynomials in
302  * the real theory excluding x. The constraint is of the form "f(x) \rho 0" with
303  * \rho element of {=,!=,<,>,<=,>=} and k as the maximum degree of x in f.
304  * @param _cons The constraint to substitute in.
305  * @param _subs The substitution to apply.
306  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
307  * @param _conflictingVariables If a conflict with the given solution space occurs, the variables being part of this conflict are stored in this
308  * container.
309  * @param _solutionSpace The solution space in form of double intervals of the variables occurring in the given constraint.
310  */
311  template<typename Poly>
312  inline void substituteInf( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, CaseDistinction<Poly>& _result, carl::Variables& _conflictingVariables, const detail::EvalDoubleIntervalMap& _solutionSpace );
313 
314  /**
315  * Applies the given substitution to the given constraint, where the substitution
316  * is of the form [x -> +/-infinity] with x as the variable and c and b polynomials in
317  * the real theory excluding x. The constraint is of the form "a*x^2+bx+c \rho 0",
318  * where \rho is less or greater.
319  * @param _cons The constraint to substitute in.
320  * @param _subs The substitution to apply.
321  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
322  */
323  template<typename Poly>
324  inline void substituteInfLessGreater( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, CaseDistinction<Poly>& _result );
325 
326  /**
327  * Deals with the case, that the left hand side of the constraint to substitute is
328  * a trivial polynomial in the variable to substitute.
329  * The constraints left hand side then should look like: ax^2+bx+c
330  * @param _cons The constraint to substitute in.
331  * @param _subs The substitution to apply.
332  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
333  */
334  template<typename Poly>
335  inline void substituteTrivialCase( const Constraint<Poly>& _cons, const Substitution<Poly>& _subs, CaseDistinction<Poly>& _result );
336 
337  /**
338  * Deals with the case, that the left hand side of the constraint to substitute is
339  * not a trivial polynomial in the variable to substitute.
340  * The constraints left hand side then should looks like: ax^2+bx+c
341  * @param _cons The constraint to substitute in.
342  * @param _subs The substitution to apply.
343  * @param _result The vector, in which to store the results of this substitution. It is semantically a disjunction of conjunctions of constraints.
344  */
345  template<typename Poly>
347 
348 }
349 
350 namespace carl::vs {
351  /**
352  * @brief Simplifies the case distinction in place.
353  *
354  * @tparam Poly Polynomial type.
355  * @param cases Case distiction to simplify.
356  * @return true On success.
357  * @return false Fail, cases is now invalid.
358  */
359  template<typename Poly>
361  if (!detail::splitProducts(cases, true)) return false;
363  return true;
364  }
365 
366  /**
367  * Applies a substitution to a constraint.
368  * @param cons The constraint to substitute in.
369  * @param subs The substitution to apply.
370  * @return std::nullopt, if the upper limit in the number of combinations in the result of the substitution is exceeded.
371  * Note, that this hinders a combinatorial blow up.
372  * Thr substitution result, otherwise.
373  */
374  template<typename Poly>
375  inline std::optional<CaseDistinction<Poly>> substitute(const Constraint<Poly>& cons, const Variable var, const Term<Poly>& term) {
376  CaseDistinction<Poly> subres;
377  carl::Variables dummy_vars; // we do not make use of this feature here
378  detail::EvalDoubleIntervalMap dummy_map; // we do not make use of this feature here
379  if (!detail::substitute(cons, detail::Substitution<Poly>(var, term), subres, false, dummy_vars, dummy_map)) {
380  return std::nullopt;
381  } else {
382  // return subres;
383  if (simplify_inplace(subres)) {
384  return subres;
385  } else {
386  return std::nullopt;
387  }
388  }
389  }
390 
391  /**
392  * Applies a substitution to a variable comparison.
393  * @param varcomp The variable comparison to substitute in.
394  * @param subs The substitution to apply.
395  * @return std::nullopt, if the upper limit in the number of combinations in the result of the substitution is exceeded
396  * or the substitution cannot be applied.
397  * Note, that this hinders a combinatorial blow up.
398  * Thr substitution result, otherwise.
399  */
400  template<typename Poly>
401  static std::optional<std::variant<CaseDistinction<Poly>, VariableComparison<Poly>>> substitute(const VariableComparison<Poly>& varcomp, const Variable var, const Term<Poly>& term) {
402  if (std::holds_alternative<MultivariateRoot<Poly>>(varcomp.value()) && std::get<MultivariateRoot<Poly>>(varcomp.value()).poly().has(var)) {
403  // Substitution variable occurs in MVRoot's polynomial
404  return std::nullopt;
405  }
406 
407  if (varcomp.var() != var) {
408  return varcomp;
409  }
410 
411  carl::Relation varcompRelation = varcomp.negated() ? carl::inverse(varcomp.relation()) : varcomp.relation();
412 
413  if (term.is_normal() || term.is_plus_eps()) {
414  // convert MVRoot/RAN to SqrtExpression with side conditions
415  std::vector<zero<Poly>> zeros;
416  if (!gather_zeros(varcomp, var, zeros)) {
417  return std::nullopt;
418  }
419  assert(zeros.size() == 1);
420 
421  // calculate subVar1-subVar2 ~ 0 [term//subVar1][zero//subVar2]
422  static carl::Variable subVar1 = carl::fresh_real_variable("__subVar1");
423  static carl::Variable subVar2 = carl::fresh_real_variable("__subVar2");
424  auto subRes1 = substitute(Constraint<Poly>(Poly(subVar1) - subVar2, varcompRelation), subVar1, term);
425  assert(subRes1);
426  CaseDistinction<Poly> result;
427  std::map<std::reference_wrapper<const Constraint<Poly>>, CaseDistinction<Poly>, std::less<Constraint<Poly>>> result_cache;
428  for (const auto& vcase : *subRes1) {
429  std::vector<CaseDistinction<Poly>> subresults;
430  size_t num_cases = 1;
431  for (const auto& constr : vcase) {
432  if (result_cache.find(std::cref(constr)) == result_cache.end()) {
433  auto subRes2 = substitute(constr, subVar2, Term<Poly>::normal(zeros[0].sqrt_ex));
434  assert(subRes2);
435  result_cache.emplace(std::cref(constr), *subRes2);
436  }
437  auto subRes2 = result_cache.at(std::cref(constr));
438  subresults.push_back(subRes2);
439  num_cases = num_cases * subRes2.size();
440  }
441 
442  // distributive law
443  for (size_t i = 0; i < num_cases; i++) {
444  auto temp = i;
445  result.emplace_back(zeros[0].side_condition.begin(), zeros[0].side_condition.end());
446  for (auto const& vec : subresults) {
447  auto index = temp % vec.size();
448  temp /= vec.size();
449  result.back().insert(result.back().end(), vec[index].begin(), vec[index].end());
450  }
451  }
452  }
453  return result;
454  } else if(term.is_minus_infty() ) {
455  static carl::Variable subVar1 = carl::fresh_real_variable("__subVar1");
456  return substitute(Constraint<Poly>(subVar1, varcompRelation), subVar1, Term<Poly>::minus_infty());
457  } else {
458  return std::nullopt;
459  }
460  }
461 }
462 
463 #include "substitute.tpp"
const unsigned MAX_PRODUCT_SPLIT_NUMBER
The maximal number of splits performed, if the left-hand side of a constraints is a product of polyno...
Definition: substitute.h:16
const unsigned MAX_NUM_OF_COMBINATION_RESULT
The maximum number of the resulting combinations when combining according to the method combine.
Definition: substitute.h:21
Variable fresh_real_variable() noexcept
Definition: VariablePool.h:198
Relation inverse(Relation r)
Inverts the given relation symbol.
Definition: Relation.h:40
Relation
Definition: Relation.h:20
std::set< Variable > Variables
Definition: Common.h:18
auto & get(const std::string &name)
std::optional< CaseDistinction< Poly > > substitute(const Constraint< Poly > &cons, const Variable var, const Term< Poly > &term)
Applies a substitution to a constraint.
Definition: substitute.h:375
bool simplify_inplace(CaseDistinction< Poly > &cases)
Simplifies the case distinction in place.
Definition: substitute.h:360
static bool gather_zeros(const Constraint< Poly > &constraint, const Variable &eliminationVar, std::vector< zero< Poly >> &results)
Gathers zeros with side conditions from the given constraint in the given variable.
Definition: zeros.h:27
std::vector< Constraint< Poly > > ConstraintConjunction
a vector of constraints
Definition: substitute.h:26
std::vector< ConstraintConjunction< Poly > > CaseDistinction
a vector of vectors of constraints
Definition: substitute.h:29
void splitSosDecompositions(CaseDistinction< Poly > &)
void substituteInf(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, CaseDistinction< Poly > &_result, carl::Variables &_conflictingVariables, const detail::EvalDoubleIntervalMap &_solutionSpace)
Applies the given substitution to the given constraint, where the substitution is of the form [x -> -...
void substituteTrivialCase(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, CaseDistinction< Poly > &_result)
Deals with the case, that the left hand side of the constraint to substitute is a trivial polynomial ...
std::map< carl::Variable, DoubleInterval > EvalDoubleIntervalMap
Definition: substitute.h:52
void print(CaseDistinction< Poly > &_substitutionResults)
Prints the given disjunction of conjunction of constraints.
bool substituteNormalSqrtLeq(const Poly &_radicand, const Poly &_q, const Poly &_r, const Poly &_s, CaseDistinction< Poly > &_result, bool _accordingPaper)
Sub-method of substituteNormalSqrt, where applying the substitution led to a term containing a square...
bool substitutePlusEps(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, CaseDistinction< Poly > &_result, bool _accordingPaper, carl::Variables &_conflictingVariables, const detail::EvalDoubleIntervalMap &_solutionSpace)
Applies the given substitution to the given constraint, where the substitution is of the form [x -> t...
bool substituteEpsGradients(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, const carl::Relation _relation, CaseDistinction< Poly > &, bool _accordingPaper, carl::Variables &_conflictingVariables, const detail::EvalDoubleIntervalMap &_solutionSpace)
Sub-method of substituteEps, where one of the gradients in the point represented by the substitution ...
bool substituteNormalSqrtNeq(const Poly &_radicand, const Poly &_q, const Poly &_r, CaseDistinction< Poly > &_result, bool _accordingPaper)
Sub-method of substituteNormalSqrt, where applying the substitution led to a term containing a square...
void substituteNotTrivialCase(const Constraint< Poly > &, const Substitution< Poly > &, CaseDistinction< Poly > &)
Deals with the case, that the left hand side of the constraint to substitute is not a trivial polynom...
void getOddBitStrings(size_t _length, std::vector< std::bitset< MAX_PRODUCT_SPLIT_NUMBER > > &_strings)
bool substitute(const Constraint< Poly > &, const Substitution< Poly > &, CaseDistinction< Poly > &, bool _accordingPaper, carl::Variables &, const detail::EvalDoubleIntervalMap &)
Applies a substitution to a constraint and stores the results in the given vector.
bool substituteNormalSqrtLess(const Poly &_radicand, const Poly &_q, const Poly &_r, const Poly &_s, CaseDistinction< Poly > &_result, bool _accordingPaper)
Sub-method of substituteNormalSqrt, where applying the substitution led to a term containing a square...
bool splitProducts(CaseDistinction< Poly > &, bool=false)
Splits all constraints in the given disjunction of conjunctions of constraints having a non-trivial f...
void getEvenBitStrings(size_t _length, std::vector< std::bitset< MAX_PRODUCT_SPLIT_NUMBER > > &_strings)
void substituteInfLessGreater(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, CaseDistinction< Poly > &_result)
Applies the given substitution to the given constraint, where the substitution is of the form [x -> +...
bool substituteNormalSqrtEq(const Poly &_radicand, const Poly &_q, const Poly &_r, CaseDistinction< Poly > &_result, bool _accordingPaper)
Sub-method of substituteNormalSqrt, where applying the substitution led to a term containing a square...
bool substituteNormal(const Constraint< Poly > &_cons, const Substitution< Poly > &_subs, CaseDistinction< Poly > &_result, bool _accordingPaper, carl::Variables &_conflictingVariables, const detail::EvalDoubleIntervalMap &_solutionSpace)
Applies a substitution of a variable to a term, which is not minus infinity nor a to an square root e...
void simplify(CaseDistinction< Poly > &)
Simplifies a disjunction of conjunctions of constraints by deleting consistent constraint and inconsi...
CaseDistinction< Poly > getSignCombinations(const Constraint< Poly > &)
For a given constraint f_1*...*f_n ~ 0 this method computes all combinations of constraints f_1 ~_1 0...
std::ostream & operator<<(std::ostream &os, const Substitution< Poly > &s)
Definition: substitute.h:46
bool combine(const std::vector< std::vector< std::vector< combineType > > > &_toCombine, std::vector< std::vector< combineType > > &_combination)
Combines vectors.
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
const Poly & poly() const noexcept
Represent a sum type/variant of an (in)equality between a variable on the left-hand side and multivar...
const std::variant< MR, RAN > & value() const
Represent a polynomial (in)equality against zero.
Definition: Constraint.h:62
Substitution(const Variable &variable, const Term< Poly > &term)
Definition: substitute.h:37
const carl::Variable & variable() const
Definition: substitute.h:38
const Term< Poly > & term() const
Definition: substitute.h:41
const Variable & m_variable
Definition: substitute.h:35
const Term< Poly > & m_term
Definition: substitute.h:36
bool is_plus_eps() const
Definition: term.h:46
bool is_normal() const
Definition: term.h:42
bool is_minus_infty() const
Definition: term.h:50