carl  24.04
Computer ARithmetic Library
ConstraintOperations.h
Go to the documentation of this file.
1 /**
2  * @file ConstraintOperations.h
3  * @author Sebastian Junges
4  * @ingroup constraints
5  *
6  */
7 
8 #pragma once
9 
10 #include <iterator>
11 
13 #include "RationalFunction.h"
14 
15 
16 
17 namespace carl
18 {
19  namespace constraints
20  {
21  /// Converts Constraint<RationalFunction<Poly>> to Constraint<Poly>
22  template<typename PolType, bool AS, typename InIt, typename InsertIt>
23  void toPolynomialConstraints(InIt start,
24  InIt end,
25  InsertIt out)
26  {
27  using PCon = Constraint<PolType>;
28 
29  // TODO add static assertion.InsertIt
30  for(auto it = start; it != end; ++it)
31  {
32  if(it->isTrivialTrue())
33  {
34  out = PCon(true);
35  }
36  else if(it->isTrivialFalse())
37  {
38  out = PCon(false);
39  }
40  else if(it->lhs().denominator().is_one())
41  {
42  out = PCon(it->lhs().nominator(), it->rel());
43  }
44  else
45  {
46  assert(!it->lhs().denominator().is_constant());
47  out = PCon(it->lhs().nominator(), inverse(it->rel()));
48  out = PCon(it->lhs().nominator() * it->lhs().denominator(), it->rel());
49  }
50 
51 
52  }
53  }
54  }
55 }
carl is the main namespace for the library.
Relation inverse(Relation r)
Inverts the given relation symbol.
Definition: Relation.h:40
void toPolynomialConstraints(InIt start, InIt end, InsertIt out)
Converts Constraint<RationalFunction<Poly>> to Constraint<Poly>
Represent a polynomial (in)equality against zero.
Definition: Constraint.h:62