8 bool hasPositiveCoeff =
false;
10 for (
const auto& term : constraint.lhs()) {
11 if ( term.is_constant() )
continue;
13 if (term.coeff() >
Rational(0)) hasPositiveCoeff =
true;
18 std::optional<FormulaT> booleanPart = {};
20 if (constraint.relation() == carl::Relation::LESS) {
24 assert(constraint.relation() == carl::Relation::LEQ || constraint.relation() ==
carl::Relation::EQ);
26 if (hasPositiveCoeff) {
28 booleanPart = processedPositiveConstr.first;
29 normalizedConstraint = processedPositiveConstr.second;
33 normalizedConstraint =
trim(normalizedConstraint);
36 normalizedConstraint =
gcd(normalizedConstraint);
38 return std::make_pair(booleanPart, normalizedConstraint);
42 Rational constantPart = constraint.lhs().constant_part();
44 for (
const auto& term : constraint.lhs()) {
45 if ( term.is_constant() )
continue;
47 if (
carl::abs(term.coeff()) > constantPart && constantPart >=
Rational(1))
return true;
54 Rational constant = constraint.lhs().constant_part();
57 for (
const auto& term : constraint.lhs()) {
58 if (term.is_constant())
continue;
61 result -= constant*term.single_variable();
77 for (
const auto& term : constraint.lhs()) {
78 if (term.is_constant()) {
85 carl::Variable currentVariable = term.single_variable();
90 lhs += currentVariable;
107 std::vector<Rational> coeffs;
108 Rational constant = constraint.lhs().constant_part();
109 for (
const auto& term : constraint.lhs()) {
110 if (term.is_constant())
continue;
112 coeffs.push_back(term.coeff());
115 if (coeffs.size() == 0) {
120 for (
size_t i = 0; i < coeffs.size(); i++) {
124 if (carl::is_one(
gcd)) {
128 return ConstraintT(((constraint.lhs() - constant) /
gcd) +
Poly(carl::floor(constant/
gcd)), constraint.relation());
132 assert(constraint.relation() == carl::Relation::LESS);
std::pair< std::optional< FormulaT >, ConstraintT > normalize(const ConstraintT &constraint)
Modifies the constraint in-place and returns an additional boolean formula.
ConstraintT trim(const ConstraintT &constraint)
std::pair< std::optional< FormulaT >, ConstraintT > removePositiveCoeff(const ConstraintT &constraint)
ConstraintT normalizeLessConstraint(const ConstraintT &constraint)
bool trimmable(const ConstraintT &constraint)
ConstraintT gcd(const ConstraintT &constraint)
std::map< carl::Variable, carl::Variable > mVariablesCache
Numeric abs(const Numeric &_value)
Calculates the absolute value of the given Numeric.
Numeric gcd(const Numeric &_valueA, const Numeric &_valueB)
Calculates the greatest common divisor of the two arguments.
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
carl::Constraint< Poly > ConstraintT
carl::Formulas< Poly > FormulasT