SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
AxiomFactory.cpp
Go to the documentation of this file.
1 /**
2  * Class to create the formulas for axioms.
3  * @author Aklima Zaman
4  * @since 2018-09-24
5  * @version 2018-09-24
6  */
7 
8 #include "AxiomFactory.h"
9 #include "../LOG.h"
10 
11 namespace smtrat {
12 
13  FormulaT createZeroOne(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable) {
14  // x = 0
15  FormulaT xFormula = FormulaT(Poly(xVariable), carl::Relation::EQ);
16  // y = 0
17  FormulaT yFormula = FormulaT(Poly(yVariable), carl::Relation::EQ);
18  // z = 0
19  FormulaT zFormula = FormulaT(Poly(zVariable), carl::Relation::EQ);
20 
21  // x = 0 | y = 0
22  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, xFormula, yFormula);
23 
24  // (x = 0 | y = 0) <-> (z = 0)
25  FormulaT finalFormula = FormulaT(carl::FormulaType::IFF, leftFormula, zFormula);
26 
27  if (smtrat::LOG::getInstance().isDebugEnabled()) {
28  std::cout << "\n";
29  std::cout << "created ZeroOne Axiom Formula is: " << finalFormula;
30  std::cout << "\n";
31  }
32 
33  return finalFormula;
34 
35  }
36 
37  FormulaT createZeroTwo(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable) {
38 
39  // x > 0
40  FormulaT xFormulaGreater = FormulaT(Poly(xVariable), carl::Relation::GREATER);
41  // y > 0
42  FormulaT yFormulaGreater = FormulaT(Poly(yVariable), carl::Relation::GREATER);
43  // x > 0 && y > 0
44  FormulaT partOneFormula = FormulaT(carl::FormulaType::AND, xFormulaGreater, yFormulaGreater);
45 
46  // x < 0
47  FormulaT xFormulaLess = FormulaT(Poly(xVariable), carl::Relation::LESS);
48  // y < 0
49  FormulaT yFormulaLess = FormulaT(Poly(yVariable), carl::Relation::LESS);
50  // x < 0 && y < 0
51  FormulaT partTwoFormula = FormulaT(carl::FormulaType::AND, xFormulaLess, yFormulaLess);
52 
53  // z > 0
54  FormulaT zFormula = FormulaT(Poly(zVariable), carl::Relation::GREATER);
55 
56  // (x > 0 && y > 0) | (x < 0 && y < 0)
57  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, partOneFormula, partTwoFormula);
58 
59  // (x > 0 && y > 0) | (x < 0 && y < 0) <-> z > 0
60  FormulaT finalFormula = FormulaT(carl::FormulaType::IFF, leftFormula, zFormula);
61 
62  if (smtrat::LOG::getInstance().isDebugEnabled()) {
63  std::cout << "\n";
64  std::cout << "created ZeroTwo Axiom Formula is: " << finalFormula;
65  std::cout << "\n";
66  }
67 
68  return finalFormula;
69 
70  }
71 
72  FormulaT createZeroThree(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable) {
73 
74  // x < 0
75  FormulaT xFormulaLess = FormulaT(Poly(xVariable), carl::Relation::LESS);
76  // y > 0
77  FormulaT yFormulaGreater = FormulaT(Poly(yVariable), carl::Relation::GREATER);
78  // x < 0 && y > 0
79  FormulaT partOneFormula = FormulaT(carl::FormulaType::AND, xFormulaLess, yFormulaGreater);
80 
81  // x > 0
82  FormulaT xFormulaGreater = FormulaT(Poly(xVariable), carl::Relation::GREATER);
83  // y < 0
84  FormulaT yFormulaLess = FormulaT(Poly(yVariable), carl::Relation::LESS);
85  // x > 0 && y < 0
86  FormulaT partTwoFormula = FormulaT(carl::FormulaType::AND, xFormulaGreater, yFormulaLess);
87 
88  // z < 0
89  FormulaT zFormula = FormulaT(Poly(zVariable), carl::Relation::LESS);
90 
91  // (x < 0 && y > 0) | (x > 0 && y < 0)
92  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, partOneFormula, partTwoFormula);
93 
94  // (x < 0 && y > 0) | (x > 0 && y < 0) <-> z < 0
95  FormulaT finalFormula = FormulaT(carl::FormulaType::IFF, leftFormula, zFormula);
96 
97  if (smtrat::LOG::getInstance().isDebugEnabled()) {
98  std::cout << "\n";
99  std::cout << "created ZeroThree Axiom Formula is: " << finalFormula;
100  std::cout << "\n";
101  }
102 
103  return finalFormula;
104 
105  }
106 
108  FormulasT zeroFormulas;
109  zeroFormulas.push_back(createZeroOne(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable()));
110  zeroFormulas.push_back(createZeroTwo(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable()));
111  zeroFormulas.push_back(createZeroThree(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable()));
112  return zeroFormulas;
113  }
114 
115  FormulaT createTangentPlaneNEQOne (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational) {
116 
117  // x - a = 0
118  FormulaT leftFormula = FormulaT(Poly(xVariable) - aRational, carl::Relation::EQ);
119 
120  // z - a*y = 0
121  FormulaT rightFormula = FormulaT(Poly(zVariable) - Poly(aRational*yVariable), carl::Relation::EQ);
122 
123  // (x - a = 0) -> (z - a*y = 0)
124  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
125 
126  if (smtrat::LOG::getInstance().isDebugEnabled()) {
127  std::cout << "\n";
128  std::cout << "created TangentPlaneNEQOne Axiom Formula is: " << finalFormula;
129  std::cout << "\n";
130  }
131 
132  return finalFormula;
133 
134  }
135 
136  FormulaT createTangentPlaneNEQTwo (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational bRational) {
137 
138  // y - b = 0
139  FormulaT leftFormula = FormulaT(Poly(yVariable) - bRational, carl::Relation::EQ);
140 
141  // z - b*x = 0
142  FormulaT rightFormula = FormulaT(Poly(zVariable) - Poly(bRational*xVariable), carl::Relation::EQ);
143 
144  // (y - b = 0) -> (z - b*x = 0)
145  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
146 
147  if (smtrat::LOG::getInstance().isDebugEnabled()) {
148  std::cout << "\n";
149  std::cout << "created TangentPlaneNEQTwo Axiom Formula is: " << finalFormula;
150  std::cout << "\n";
151  }
152 
153  return finalFormula;
154 
155  }
156 
157  FormulaT createTangentPlaneNEQThree (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational, Rational bRational) {
158 
159  // {x, a}
160  std::vector<Poly> operandsxa {Poly(xVariable), Poly(aRational)};
161  // Poly(x - a)
162  Poly xMinusa = Poly(Poly::ConstructorOperation::SUB, operandsxa);
163 
164  // {y, b}
165  std::vector<Poly> operandsyb {Poly(yVariable), Poly(bRational)};
166  // Poly(y - b)
167  Poly yMinusb =Poly(Poly::ConstructorOperation::SUB, operandsyb);
168 
169  FormulaT formula1 = FormulaT(xMinusa, carl::Relation::GREATER);
170  FormulaT formula2 = FormulaT(yMinusb, carl::Relation::LESS);
171  FormulaT partOneFormula = FormulaT(carl::FormulaType::AND, formula1, formula2);
172 
173 
174  FormulaT formula3 = FormulaT(xMinusa, carl::Relation::LESS);
175  FormulaT formula4 = FormulaT(yMinusb, carl::Relation::GREATER);
176  FormulaT partTwoFormula = FormulaT(carl::FormulaType::AND, formula3, formula4);
177 
178  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, partOneFormula, partTwoFormula);
179 
180  // {z, -b*x, -a*y, a*b}
181  std::vector<Poly> operandsz {Poly(zVariable), -Poly(bRational*xVariable), -Poly(aRational*yVariable), Poly(aRational*bRational)};
182  // z - b*x - a*y + a*b < 0
183  Poly zLeftPoly = Poly(Poly::ConstructorOperation::ADD, operandsz);
184  FormulaT rightFormula = FormulaT(zLeftPoly, carl::Relation::LESS);
185 
186  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
187 
188  if (smtrat::LOG::getInstance().isDebugEnabled()) {
189  std::cout << "\n";
190  std::cout << "created TangentPlaneNEQThree Axiom Formula is: " << finalFormula;
191  std::cout << "\n";
192  }
193 
194  return finalFormula;
195 
196  }
197 
198  FormulaT createTangentPlaneNEQFour (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational, Rational bRational) {
199 
200  // {x, a}
201  std::vector<Poly> operandsxa {Poly(xVariable), Poly(aRational)};
202  // Poly(x - a)
203  Poly xMinusa = Poly(Poly::ConstructorOperation::SUB, operandsxa);
204 
205  // {y, b}
206  std::vector<Poly> operandsyb {Poly(yVariable), Poly(bRational)};
207  // Poly(y - b)
208  Poly yMinusb =Poly(Poly::ConstructorOperation::SUB, operandsyb);
209 
210  FormulaT formula1 = FormulaT(xMinusa, carl::Relation::LESS);
211  FormulaT formula2 = FormulaT(yMinusb, carl::Relation::LESS);
212  FormulaT partOneFormula = FormulaT(carl::FormulaType::AND, formula1, formula2);
213 
214 
215  FormulaT formula3 = FormulaT(xMinusa, carl::Relation::GREATER);
216  FormulaT formula4 = FormulaT(yMinusb, carl::Relation::GREATER);
217  FormulaT partTwoFormula = FormulaT(carl::FormulaType::AND, formula3, formula4);
218 
219  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, partOneFormula, partTwoFormula);
220 
221  // {z, -b*x, -a*y, a*b}
222  std::vector<Poly> operandsz {Poly(zVariable), -Poly(bRational*xVariable), -Poly(aRational*yVariable), Poly(aRational*bRational)};
223  // z - b*x - a*y + a*b > 0
224  Poly zLeftPoly = Poly(Poly::ConstructorOperation::ADD, operandsz);
225  FormulaT rightFormula = FormulaT(zLeftPoly, carl::Relation::GREATER);
226 
227  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
228 
229  if (smtrat::LOG::getInstance().isDebugEnabled()) {
230  std::cout << "\n";
231  std::cout << "created TangentPlaneNEQFour Axiom Formula is: " << finalFormula;
232  std::cout << "\n";
233  }
234 
235 
236  return finalFormula;
237 
238  }
239 
241  FormulasT tangentPlaneNEQ;
242  tangentPlaneNEQ.push_back(createTangentPlaneNEQOne(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getARational()));
243  tangentPlaneNEQ.push_back(createTangentPlaneNEQTwo(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getBRational()));
244  tangentPlaneNEQ.push_back(createTangentPlaneNEQThree(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getARational(), rationalCapsule.getBRational()));
245  tangentPlaneNEQ.push_back(createTangentPlaneNEQFour(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getARational(), rationalCapsule.getBRational()));
246  return tangentPlaneNEQ;
247  }
248 
249  FormulaT createTangentPlaneEQOne (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational) {
250 
251  std::vector<Poly> operands {Poly(xVariable), Poly(aRational)};
252  FormulaT leftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands), carl::Relation::EQ);
253 
254  std::vector<Poly> operands2 {Poly(zVariable), Poly(aRational*yVariable)};
255  FormulaT rightFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands2), carl::Relation::EQ);
256 
257  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
258 
259  if (smtrat::LOG::getInstance().isDebugEnabled()) {
260  std::cout << "\n";
261  std::cout << "created TangentPlaneEQOne Axiom Formula is: " << finalFormula;
262  std::cout << "\n";
263  }
264 
265  return finalFormula;
266 
267  }
268 
269  FormulaT createTangentPlaneEQTwo (carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational) {
270 
271  std::vector<Poly> operands {Poly(xVariable), Poly(aRational)};
272  FormulaT leftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands), carl::Relation::NEQ);
273 
274  std::vector<Poly> operands2 {Poly(zVariable), -Poly(aRational*xVariable), -Poly(aRational*xVariable), Poly(aRational*aRational)};
275  FormulaT rightFormula = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands2), carl::Relation::GREATER);
276 
277  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
278 
279  if (smtrat::LOG::getInstance().isDebugEnabled()) {
280  std::cout << "\n";
281  std::cout << "created TangentPlaneEQTwo Axiom Formula is: " << finalFormula;
282  std::cout << "\n";
283  }
284 
285  return finalFormula;
286 
287  }
288 
289  FormulasT createTangentPlaneEQ(VariableCapsule variableCapsule, RationalCapsule rationalCapsule) {
290  FormulasT tangentPlaneEQ;
291  tangentPlaneEQ.push_back(createTangentPlaneEQOne(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getARational()));
292  tangentPlaneEQ.push_back(createTangentPlaneEQTwo(variableCapsule.getXVariable(), variableCapsule.getYVariable(), variableCapsule.getZVariable(), rationalCapsule.getARational()));
293  return tangentPlaneEQ;
294  }
295 
297  carl::Variable zVariable = monomialIterator->first;
298  carl::Monomial::Arg monomial = monomialIterator->second;
299 
300  auto it = monomial->begin();
301 
302  carl::Variable xVariable = it->first;
303  carl::Variable yVariable = it->first;
304 
305  ++it;
306  // if the second variable is not the same, e.g. x * y
307  if (it != monomial->end()){
308  yVariable = it->first;
309  }
310 
311  if (smtrat::LOG::getInstance().isDebugEnabled()) {
312  std::cout << "\n";
313  std::cout << "zVariable is: " << zVariable;
314  std::cout << "\n";
315  std::cout << "xVariable is: " << xVariable;
316  std::cout << "\n";
317  std::cout << "yVariable is: " << yVariable;
318  std::cout << "\n";
319  }
320 
321  smtrat::VariableCapsule capsule(xVariable, yVariable, zVariable);
322  return capsule;
323 
324  }
325 
327 
328  Model absoluteValuedModel;
329 
330  for (auto it = linearizedModel.begin(); it != linearizedModel.end(); ++it) {
331 
332  Rational value = carl::abs(it->second.asRational());
333  absoluteValuedModel.emplace(it->first, value);
334 
335  }
336 
337  if (smtrat::LOG::getInstance().isDebugEnabled()) {
338  std::cout << "\n" << "absolute valued model: " << "\n";
339  std::cout << "variable | value: " << "\n";
340  for (auto it = absoluteValuedModel.begin(); it != absoluteValuedModel.end(); ++it) {
341  std::cout << it->first << " | " << it->second;
342  std::cout << "\n";
343  }
344  }
345 
346  return absoluteValuedModel;
347  }
348 
349  /**
350  * create an auxiliary variable e.g. aux_<Variable Name>
351  * @param variable the variable for which auxiliary variable to be created
352  * @return created auxiliary variable
353  */
354  carl::Variable createAuxiliaryVariable(carl::Variable variable){
355  return carl::fresh_real_variable("aux_" + variable.name());
356  }
357 
358  /**
359  * | x1 | =
360  * (and
361  * (=> (x1 >= 0) (y1 = x1))
362  * (=> (x1 < 0) (y1 = -x1))
363  * )
364  * @param variable
365  * @return
366  */
367  FormulaT generateAbsFormula(carl::Variable variable, carl::Variable aux_variable) {
368 
369  FormulaT partOneOneFormula = FormulaT(Poly(variable), carl::Relation::GEQ);
370 
371  std::vector<Poly> operands {Poly(aux_variable), Poly(variable)};
372 
373  FormulaT partOneTwoFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands), carl::Relation::EQ);
374 
375  FormulaT partOneFormula = FormulaT(carl::FormulaType::IMPLIES, partOneOneFormula, partOneTwoFormula);
376 
377  FormulaT partTwoOneFormula = FormulaT(Poly(variable), carl::Relation::LESS);
378 
379  FormulaT partTwoTwoFormula = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands), carl::Relation::EQ);
380 
381  FormulaT partTwoFormula = FormulaT(carl::FormulaType::IMPLIES, partTwoOneFormula, partTwoTwoFormula);
382 
383  FormulaT absFormula = FormulaT(carl::FormulaType::IMPLIES, partTwoOneFormula, partTwoTwoFormula);
384 
385  return absFormula;
386  }
387 
388 
389  /**
390  *
391  * | x1 | <= | x1 | =
392  * (and
393  * (=> (x1 >= 0) (y1 = x1))
394  * (=> (x1 < 0) (y1 = -x1))
395  * (=> (x2 >= 0) (y2 = x2))
396  * (=> (x2 < 0) (y2 = -x2))
397  * (y1 <= y2)
398  * )
399  *
400  * @param variableLeft
401  * @param variableRight
402  * @param relation
403  * @return
404  */
405  FormulaT generateAbsFormula(carl::Variable variableLeft, carl::Variable variableRight, carl::Relation relation) {
406 
407  FormulasT formulas;
408 
409  carl::Variable auxLeft = createAuxiliaryVariable(variableLeft);
410 
411  FormulaT absFormulaOfVariable1 = generateAbsFormula(variableLeft, auxLeft);
412  formulas.push_back(absFormulaOfVariable1);
413 
414  carl::Variable auxRight = createAuxiliaryVariable(variableRight);
415 
416  FormulaT absFormulaOfVariable2 = generateAbsFormula(variableRight, auxRight);
417  formulas.push_back(absFormulaOfVariable2);
418 
419  std::vector<Poly> operands {Poly(auxLeft), Poly(auxRight)};
420 
421  FormulaT realtionFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands), relation);
422  formulas.push_back(realtionFormula);
423 
424  FormulaT finalAbsFormula = FormulaT(carl::FormulaType::AND, formulas);
425 
426  return finalAbsFormula;
427  }
428 
430  smtrat::VariableCapsule variableCapsuleInner){
431 
432  FormulaT partOneLeftFormula = generateAbsFormula(variableCapsule.getXVariable(), variableCapsuleInner.getXVariable(), carl::Relation::LEQ);
433 
434  FormulaT partTwoLeftFormula = generateAbsFormula(variableCapsule.getYVariable(), variableCapsuleInner.getYVariable(), carl::Relation::LEQ);
435 
436  // (x_1 - x_2 <= 0) && (y_1 - y_2 <= 0)
437  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula);
438 
439  FormulaT rightFormula = generateAbsFormula(variableCapsule.getZVariable(), variableCapsuleInner.getZVariable(), carl::Relation::LEQ);
440 
441  // (x_1 - x_2 <= 0) && (y_1 - y_2 <= 0) -> (z_1 - z_2 <= 0)
442  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
443 
444  if (smtrat::LOG::getInstance().isDebugEnabled()) {
445  std::cout << "\n";
446  std::cout << "created EquivalentToOriginalMonotonicityOne Axiom Formula is: " << finalFormula;
447  std::cout << "\n";
448  }
449 
450  return finalFormula;
451  }
452 
454 
455  FormulaT partOneLeftFormula = generateAbsFormula(variableCapsule.getXVariable(), variableCapsuleInner.getXVariable(), carl::Relation::LESS);
456 
457 
458  FormulaT partTwoLeftFormula = generateAbsFormula(variableCapsule.getYVariable(), variableCapsuleInner.getYVariable(), carl::Relation::LEQ);
459 
460  // y_2 != 0
461  FormulaT partThreeLeftFormula = FormulaT(Poly(variableCapsuleInner.getYVariable()), carl::Relation::NEQ);
462 
463  // (x_1 - x_2 < 0) && (y_1 - y_2 <= 0) && (y_2 != 0)
464  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula, partThreeLeftFormula);
465 
466  FormulaT rightFormula = generateAbsFormula(variableCapsule.getZVariable(), variableCapsuleInner.getZVariable(), carl::Relation::LESS);
467 
468  // (x_1 - x_2 < 0) && (y_1 - y_2 <= 0) && (y_2 != 0) -> (z_1 - z_2 < 0)
469  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
470 
471  if (smtrat::LOG::getInstance().isDebugEnabled()) {
472  std::cout << "\n";
473  std::cout << "created EquivalentToOriginalMonotonicityTwo Axiom Formula is: " << finalFormula;
474  std::cout << "\n";
475  }
476 
477  return finalFormula;
478  }
479 
481  smtrat::VariableCapsule variableCapsuleInner){
482 
483  FormulaT partOneLeftFormula = generateAbsFormula(variableCapsule.getXVariable(), variableCapsuleInner.getXVariable(), carl::Relation::LEQ);
484 
485  FormulaT partTwoLeftFormula = generateAbsFormula(variableCapsule.getYVariable(), variableCapsuleInner.getYVariable(), carl::Relation::LESS);
486 
487  // x_2 != 0
488  FormulaT partThreeLeftFormula = FormulaT(Poly(variableCapsuleInner.getXVariable()), carl::Relation::NEQ);
489 
490  // (x_1 - x_2 <= 0) && (y_1 - y_2 < 0) && (x_2 != 0)
491  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula, partThreeLeftFormula);
492 
493  FormulaT rightFormula = generateAbsFormula(variableCapsule.getZVariable(), variableCapsuleInner.getZVariable(), carl::Relation::LESS);
494 
495  // (x_1 - x_2 <= 0) && (y_1 - y_2 < 0) && (x_2 != 0) -> (z_1 - z_2 < 0)
496  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
497 
498  if (smtrat::LOG::getInstance().isDebugEnabled()) {
499  std::cout << "\n";
500  std::cout << "created EquivalentToOriginalMonotonicityThree Axiom Formula is: " << finalFormula;
501  std::cout << "\n";
502  }
503 
504  return finalFormula;
505  }
506 
507  RationalCapsule extractRationalCapsule(VariableCapsule variableCapsule, Model linearizedModel) {
508  Rational aRational = linearizedModel.find(variableCapsule.getXVariable())->second.asRational();
509  Rational bRational = linearizedModel.find(variableCapsule.getYVariable())->second.asRational();
510  Rational cRational = linearizedModel.find(variableCapsule.getZVariable())->second.asRational();
511  return RationalCapsule(aRational, bRational, cRational);
512  }
513 
515  // {x_1, x_2}
516  std::vector<Poly> operandsxx {Poly(variableCapsule.getXVariable()), Poly(variableCapsuleInner.getXVariable())};
517  // x_1 - x_2 <= 0
518  FormulaT partOneLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsxx), carl::Relation::LEQ);
519 
520  // {y_1, y_2}
521  std::vector<Poly> operandsyy {Poly(variableCapsule.getYVariable()), Poly(variableCapsuleInner.getYVariable())};
522  // y_1 - y_2 <= 0
523  FormulaT partTwoLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsyy), carl::Relation::LEQ);
524 
525  // (x_1 - x_2 <= 0) && (y_1 - y_2 <= 0)
526  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula);
527 
528  // {z_1, z_2}
529  std::vector<Poly> operandszz {Poly(variableCapsule.getZVariable()), Poly(variableCapsuleInner.getZVariable())};
530  // z_1 - z_2 <= 0
531  FormulaT zFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandszz), carl::Relation::LEQ);
532 
533  // (x_1 - x_2 <= 0) && (y_1 - y_2 <= 0) -> (z_1 - z_2 <= 0)
534  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, zFormula);
535 
536  if (smtrat::LOG::getInstance().isDebugEnabled()) {
537  std::cout << "\n";
538  std::cout << "created OriginalMonotonicityOne Axiom Formula is: " << finalFormula;
539  std::cout << "\n";
540  }
541 
542  return finalFormula;
543  }
544 
546  // {x_1, x_2}
547  std::vector<Poly> operandsxx {Poly(variableCapsule.getXVariable()), Poly(variableCapsuleInner.getXVariable())};
548  // x_1 - x_2 < 0
549  FormulaT partOneLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsxx), carl::Relation::LESS);
550 
551  // {y_1, y_2}
552  std::vector<Poly> operandsyy {Poly(variableCapsule.getYVariable()), Poly(variableCapsuleInner.getYVariable())};
553  // y_1 - y_2 <= 0
554  FormulaT partTwoLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsyy), carl::Relation::LEQ);
555 
556  // y_2 != 0
557  FormulaT partThreeLeftFormula = FormulaT(Poly(variableCapsuleInner.getYVariable()), carl::Relation::NEQ);
558 
559  // (x_1 - x_2 < 0) && (y_1 - y_2 <= 0) && (y_2 != 0)
560  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula, partThreeLeftFormula);
561 
562  // {z_1, z_2}
563  std::vector<Poly> operandszz {Poly(variableCapsule.getZVariable()), Poly(variableCapsuleInner.getZVariable())};
564  // z_1 - z_2 < 0
565  FormulaT zFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandszz), carl::Relation::LESS);
566 
567  // (x_1 - x_2 < 0) && (y_1 - y_2 <= 0) && (y_2 != 0) -> (z_1 - z_2 < 0)
568  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, zFormula);
569 
570  if (smtrat::LOG::getInstance().isDebugEnabled()) {
571  std::cout << "\n";
572  std::cout << "created OriginalMonotonicityTwo Axiom Formula is: " << finalFormula;
573  std::cout << "\n";
574  }
575 
576  return finalFormula;
577  }
578 
580  // {x_1, x_2}
581  std::vector<Poly> operandsxx {Poly(variableCapsule.getXVariable()), Poly(variableCapsuleInner.getXVariable())};
582  // x_1 - x_2 <= 0
583  FormulaT partOneLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsxx), carl::Relation::LEQ);
584 
585  // {y_1, y_2}
586  std::vector<Poly> operandsyy {Poly(variableCapsule.getYVariable()), Poly(variableCapsuleInner.getYVariable())};
587  // y_1 - y_2 < 0
588  FormulaT partTwoLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsyy), carl::Relation::LESS);
589 
590  // x_2 != 0
591  FormulaT partThreeLeftFormula = FormulaT(Poly(variableCapsuleInner.getXVariable()), carl::Relation::NEQ);
592 
593  // (x_1 - x_2 <= 0) && (y_1 - y_2 < 0) && (x_2 != 0)
594  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula, partThreeLeftFormula);
595 
596  // {z_1, z_2}
597  std::vector<Poly> operandszz {Poly(variableCapsule.getZVariable()), Poly(variableCapsuleInner.getZVariable())};
598  // z_1 - z_2 < 0
599  FormulaT zFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandszz), carl::Relation::LESS);
600 
601  // (x_1 - x_2 <= 0) && (y_1 - y_2 < 0) && (x_2 != 0) -> (z_1 - z_2 < 0)
602  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, zFormula);
603 
604  if (smtrat::LOG::getInstance().isDebugEnabled()) {
605  std::cout << "\n";
606  std::cout << "created OriginalMonotonicityThree Axiom Formula is: " << finalFormula;
607  std::cout << "\n";
608  }
609 
610  return finalFormula;
611  }
612 
613  FormulasT createMonotonicity(VariableCapsule variableCapsuleOuter, VariableCapsule variableCapsuleInner, Model absoluteValuedModel) {
614 
615  FormulasT monotonicityFormulas;
616 
617  if(carl::satisfied_by(createOriginalMonotonicityOne(variableCapsuleOuter, variableCapsuleInner), absoluteValuedModel) == 0){
618  monotonicityFormulas.push_back(
619  createEquivalentToOriginalMonotonicityOne(variableCapsuleOuter, variableCapsuleInner));
620  }
621 
622  if(carl::satisfied_by(createOriginalMonotonicityTwo(variableCapsuleOuter, variableCapsuleInner), absoluteValuedModel) == 0){
623  monotonicityFormulas.push_back(
624  createEquivalentToOriginalMonotonicityTwo(variableCapsuleOuter, variableCapsuleInner));
625  }
626 
627  if(carl::satisfied_by(createOriginalMonotonicityThree(variableCapsuleOuter, variableCapsuleInner), absoluteValuedModel) == 0){
628  monotonicityFormulas.push_back(
629  createEquivalentToOriginalMonotonicityThree(variableCapsuleOuter, variableCapsuleInner));
630  }
631 
632  return monotonicityFormulas;
633  }
634 
635  FormulaT createCongruence(smtrat::VariableCapsule variableCapsuleOuter, smtrat::VariableCapsule variableCapsuleInner){
636  // {x_1, x_2}
637  std::vector<Poly> operandsxx {Poly(variableCapsuleOuter.getXVariable()), Poly(variableCapsuleInner.getXVariable())};
638  // x_1 - x_2 = 0
639  FormulaT partOneLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsxx), carl::Relation::EQ);
640 
641  // {y_1, y_2}
642  std::vector<Poly> operandsyy {Poly(variableCapsuleOuter.getYVariable()), Poly(variableCapsuleInner.getYVariable())};
643  // y_1 - y_2 = 0
644  FormulaT partTwoLeftFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandsyy), carl::Relation::EQ);
645 
646  // (x_1 - x_2 = 0) && (y_1 - y_2 = 0)
647  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, partOneLeftFormula, partTwoLeftFormula);
648 
649  // {z_1, z_2}
650  std::vector<Poly> operandszz {Poly(variableCapsuleOuter.getZVariable()), Poly(variableCapsuleInner.getZVariable())};
651  // z_1 - z_2 = 0
652  FormulaT rightFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operandszz), carl::Relation::EQ);
653 
654  // (x_1 - x_2 = 0) && (y_1 - y_2 = 0) -> (z_1 - z_2 = 0)
655  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
656 
657  if (smtrat::LOG::getInstance().isDebugEnabled()) {
658  std::cout << "\n";
659  std::cout << "created Congruence Axiom Formula is: " << finalFormula;
660  std::cout << "\n";
661  }
662 
663  return finalFormula;
664  }
665 
666  FormulaT createICPGreaterOne(VariableCapsule variableCapsule, RationalCapsule rationalCapsule){
667 
668  std::vector<Poly> operands1 {Poly(variableCapsule.getXVariable()), Poly(rationalCapsule.getARational())};
669  FormulaT leftFormulaPartOneOne = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands1), carl::Relation::GEQ);
670 
671  std::vector<Poly> operands2 {Poly(variableCapsule.getYVariable()), Poly(rationalCapsule.getBRational())};
672  FormulaT leftFormulaPartOneTwo = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands2), carl::Relation::GEQ);
673 
674  FormulaT leftFormulaOne = FormulaT(carl::FormulaType::AND, leftFormulaPartOneOne, leftFormulaPartOneTwo);
675 
676  FormulaT leftFormulaPartTwoOne = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands1), carl::Relation::LEQ);
677 
678  FormulaT leftFormulaPartTwoTwo = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands2), carl::Relation::LEQ);
679 
680  FormulaT leftFormulaTwo = FormulaT(carl::FormulaType::AND, leftFormulaPartTwoOne, leftFormulaPartTwoTwo);
681 
682  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, leftFormulaOne, leftFormulaTwo);
683 
684  std::vector<Poly> operands3 {Poly(variableCapsule.getZVariable()), Poly(rationalCapsule.getCRational())};
685  FormulaT rightFormula = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands3), carl::Relation::GEQ);
686 
687  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
688 
689  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "created ICPGreaterOne Axiom Formula is: " << finalFormula << std::endl; }
690 
691  return finalFormula;
692  }
693 
694  FormulaT createICPGreaterTwo(VariableCapsule variableCapsule, RationalCapsule rationalCapsule){
695 
696  std::vector<Poly> operands1 {Poly(variableCapsule.getXVariable()), Poly(rationalCapsule.getARational())};
697  FormulaT leftFormulaPartOneOne = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands1), carl::Relation::GEQ);
698 
699  std::vector<Poly> operands2 {Poly(variableCapsule.getYVariable()), Poly(rationalCapsule.getBRational())};
700  FormulaT leftFormulaPartOneTwo = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands2), carl::Relation::LEQ);
701 
702  FormulaT leftFormulaOne = FormulaT(carl::FormulaType::AND, leftFormulaPartOneOne, leftFormulaPartOneTwo);
703 
704  FormulaT leftFormulaPartTwoOne = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands1), carl::Relation::LEQ);
705 
706  FormulaT leftFormulaPartTwoTwo = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands2), carl::Relation::GEQ);
707 
708  FormulaT leftFormulaTwo = FormulaT(carl::FormulaType::AND, leftFormulaPartTwoOne, leftFormulaPartTwoTwo);
709 
710  FormulaT leftFormula = FormulaT(carl::FormulaType::OR, leftFormulaOne, leftFormulaTwo);
711 
712  std::vector<Poly> operands3 {Poly(variableCapsule.getZVariable()), Poly(rationalCapsule.getCRational())};
713  FormulaT rightFormula = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands3), carl::Relation::LEQ);
714 
715  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
716 
717  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "created ICPGreaterTwo Axiom Formula is: " << finalFormula << std::endl; }
718 
719  return finalFormula;
720  }
721 
722  FormulasT createICPGreater(VariableCapsule variableCapsule, RationalCapsule rationalCapsule) {
723  FormulasT iCPGreater;
724  iCPGreater.push_back(createICPGreaterOne(variableCapsule, rationalCapsule));
725  iCPGreater.push_back(createICPGreaterTwo(variableCapsule, rationalCapsule));
726  return iCPGreater;
727  }
728 
729  FormulaT createICPLess(VariableCapsule variableCapsule, RationalCapsule rationalCapsule){
730 
731  FormulasT leftFormulas;
732 
733  std::vector<Poly> operands1 {-Poly(variableCapsule.getXVariable()), -Poly(rationalCapsule.getARational())};
734  FormulaT leftFormulaPartOne = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands1), carl::Relation::LEQ);
735  leftFormulas.push_back(leftFormulaPartOne);
736 
737  std::vector<Poly> operands2 {Poly(variableCapsule.getXVariable()), Poly(rationalCapsule.getARational())};
738  FormulaT leftFormulaPartTwo = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands2), carl::Relation::LEQ);
739  leftFormulas.push_back(leftFormulaPartTwo);
740 
741  std::vector<Poly> operands3 {-Poly(variableCapsule.getYVariable()), -Poly(rationalCapsule.getBRational())};
742  FormulaT leftFormulaPartThree = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands3), carl::Relation::LEQ);
743  leftFormulas.push_back(leftFormulaPartThree);
744 
745  std::vector<Poly> operands4 {Poly(variableCapsule.getYVariable()), Poly(rationalCapsule.getBRational())};
746  FormulaT leftFormulaPartFour = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands4), carl::Relation::LEQ);
747  leftFormulas.push_back(leftFormulaPartFour);
748 
749  FormulaT leftFormula = FormulaT(carl::FormulaType::AND, leftFormulas);
750 
751  std::vector<Poly> operands5 {-Poly(variableCapsule.getZVariable()), -Poly(rationalCapsule.getCRational())};
752  FormulaT rightFormulaPartOne = FormulaT(Poly(Poly::ConstructorOperation::ADD, operands5), carl::Relation::LEQ);
753 
754  std::vector<Poly> operands6 {Poly(variableCapsule.getZVariable()), Poly(rationalCapsule.getCRational())};
755  FormulaT rightFormulaPartTwo = FormulaT(Poly(Poly::ConstructorOperation::SUB, operands6), carl::Relation::LEQ);
756 
757  FormulaT rightFormula = FormulaT(carl::FormulaType::AND, rightFormulaPartOne, rightFormulaPartTwo);
758 
759  FormulaT finalFormula = FormulaT(carl::FormulaType::IMPLIES, leftFormula, rightFormula);
760 
761  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "created ICPLess Axiom Formula is: " << finalFormula << std::endl; }
762 
763  return finalFormula;
764  }
765 
766  bool abEqualcCheck(VariableCapsule variableCapsuleOuter, Model linearizedModel){
767  carl::Variable xVariable = variableCapsuleOuter.getXVariable();
768  carl::Variable yVariable = variableCapsuleOuter.getYVariable();
769  carl::Variable zVariable = variableCapsuleOuter.getZVariable();
770 
771  Rational aRational = linearizedModel.find(variableCapsuleOuter.getXVariable())->second.asRational();
772  Rational bRational = linearizedModel.find(variableCapsuleOuter.getYVariable())->second.asRational();
773  Rational cRational = linearizedModel.find(variableCapsuleOuter.getZVariable())->second.asRational();
774 
775  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << std::endl << "Found values in abEqualcCheck" << " Zvariable = " << cRational << " Xvariable = " << aRational << " Yvariable = " << bRational << std::endl; }
776 
777  carl::Variable aVariable = carl::fresh_real_variable("a");
778  carl::Variable bVariable = carl::fresh_real_variable("b");
779  carl::Variable cVariable = carl::fresh_real_variable("c");
780 
781  Model abcModel;
782  abcModel.emplace(aVariable, aRational);
783  abcModel.emplace(bVariable, bRational);
784  abcModel.emplace(cVariable, cRational);
785 
786  // c != a * b or, c - a * b != 0
787  FormulaT abcFormula = FormulaT(Poly(cVariable) - Poly(aVariable*bVariable), carl::Relation::NEQ);
788 
789  if (carl::satisfied_by(abcFormula, abcModel) == 1){
790  return true;
791  }
792 
793  return false;
794  }
795 
796  bool abGreatercCheck(RationalCapsule rationalCapsule){
797 
798  carl::Variable aVariable = carl::fresh_real_variable("a");
799  carl::Variable bVariable = carl::fresh_real_variable("b");
800  carl::Variable cVariable = carl::fresh_real_variable("c");
801 
802  Model abcModel;
803  abcModel.emplace(aVariable, rationalCapsule.getARational());
804  abcModel.emplace(bVariable, rationalCapsule.getBRational());
805  abcModel.emplace(cVariable, rationalCapsule.getCRational());
806 
807  // c < a * b or, c - a * b < 0
808  FormulaT abcFormula = FormulaT(Poly(cVariable) - Poly(aVariable*bVariable), carl::Relation::LESS);
809 
810  if (carl::satisfied_by(abcFormula, abcModel) == 1){
811  return true;
812  }
813 
814  return false;
815  }
816 
817  bool abLesscCheck(RationalCapsule rationalCapsule){
818 
819  carl::Variable aVariable = carl::fresh_real_variable("a");
820  carl::Variable bVariable = carl::fresh_real_variable("b");
821  carl::Variable cVariable = carl::fresh_real_variable("c");
822 
823  Model abcModel;
824  abcModel.emplace(aVariable, rationalCapsule.getARational());
825  abcModel.emplace(bVariable, rationalCapsule.getBRational());
826  abcModel.emplace(cVariable, rationalCapsule.getCRational());
827 
828  // c > a * b or, c - a * b > 0
829  FormulaT abcFormula = FormulaT(Poly(cVariable) - Poly(aVariable*bVariable), carl::Relation::GREATER);
830 
831  if (carl::satisfied_by(abcFormula, abcModel) == 1){
832  return true;
833  }
834 
835  return false;
836  }
837 
838  RationalCapsule generateAbcPrimeForICP(RationalCapsule rationalCapsule, bool isGreater) {
839 
840  Rational cByA = rationalCapsule.getCRational() / rationalCapsule.getARational();
841 
842  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "generated cByA: " << cByA << std::endl; }
843 
844  RationalInterval bPrimeInterval;
845 
846  if (isGreater) {
847  bPrimeInterval = RationalInterval(cByA, rationalCapsule.getBRational());
848  } else {
849  bPrimeInterval = RationalInterval(rationalCapsule.getBRational(), cByA);
850  }
851 
852  if (smtrat::LOG::getInstance().isDebugEnabled()) {
853  std::cout << "The bPrimeInterval is: " << bPrimeInterval << std::endl;
854  if (bPrimeInterval.is_consistent())
855  std::cout << "isConsistent: " << std::endl;
856  if (!bPrimeInterval.is_empty())
857  std::cout << "Not Empty: " << std::endl;
858  }
859 
860  Rational bPrime = carl::sample(bPrimeInterval);
861 
862  Rational cByBPrime = rationalCapsule.getCRational() / bPrime;
863  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "generated cByBPrime: " << cByBPrime << std::endl; }
864 
865  RationalInterval aPrimeInterval;
866 
867  if (isGreater) {
868  aPrimeInterval = RationalInterval(cByBPrime, rationalCapsule.getARational());
869  } else {
870  aPrimeInterval = RationalInterval(rationalCapsule.getARational(), cByBPrime);
871  }
872 
873  Rational aPrime = carl::sample(aPrimeInterval);
874 
875  // c' = a * b
876  Rational cPrime = aPrime * bPrime;
877 
878  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "generated aPrime: " << aPrime << " bPrime: " << bPrime << " cPrime: " << cPrime << std::endl; }
879 
880  return RationalCapsule(aPrime, bPrime, cPrime);
881  }
882 
883  bool isAnyRationalIsZero (RationalCapsule rationalCapsule) {
884  return carl::get_num(rationalCapsule.getARational()) == Rational(0) ||
885  carl::get_num(rationalCapsule.getBRational()) == Rational(0) ||
886  carl::get_num(rationalCapsule.getCRational()) == Rational(0);
887  }
888 
889 
890  FormulasT AxiomFactory::createFormula(AxiomType axiomType, Model linearizedModel, MonomialMap monomialMap) {
891 
892 
893  Model absoluteValuedModel;
894 
895  if (axiomType == AxiomType::MONOTONICITY) { absoluteValuedModel = createAbsoluteValuedModel(linearizedModel); }
896 
897  FormulasT formulas;
898 
899  for (MonomialMapIterator monomialIteratorOuter = monomialMap.begin(); monomialIteratorOuter != monomialMap.end(); ++monomialIteratorOuter){
900 
901  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << std::endl <<"creating variableCapsuleOuter..."; }
902  smtrat::VariableCapsule variableCapsuleOuter = extractVariables(monomialIteratorOuter);
903 
904  RationalCapsule rationalCapsule = extractRationalCapsule(variableCapsuleOuter, linearizedModel);
905 
906  if (axiomType == AxiomType::ZERO) {
907 
908  FormulasT createdZeroFormulas = createZero(variableCapsuleOuter);
909  formulas.insert(std::end(formulas), std::begin(createdZeroFormulas), std::end(createdZeroFormulas));
910 
911  } else if (axiomType == AxiomType::TANGENT_PLANE){
912  if(abEqualcCheck(variableCapsuleOuter, linearizedModel)) {
913  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abEqualcCheck is true, creating TANGENT_PLANE..." << std::endl; }
914  if (variableCapsuleOuter.getXVariable() != variableCapsuleOuter.getYVariable()){
915  FormulasT createdTangentPlaneNEQ = createTangentPlaneNEQ(variableCapsuleOuter, rationalCapsule);
916  formulas.insert(std::end(formulas), std::begin(createdTangentPlaneNEQ), std::end(createdTangentPlaneNEQ));
917  } else {
918  FormulasT createdTangentPlaneEQ = createTangentPlaneEQ(variableCapsuleOuter, rationalCapsule);
919  formulas.insert(std::end(formulas), std::begin(createdTangentPlaneEQ), std::end(createdTangentPlaneEQ));
920  }
921  } else {
922  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abEqualcCheck is false TANGENT_PLANE is not creating..." << std::endl; }
923  }
924  } else if(axiomType == AxiomType::MONOTONICITY || axiomType == AxiomType::CONGRUENCE){
925  for (MonomialMapIterator monomialIteratorInner = monomialMap.begin(); monomialIteratorInner != monomialMap.end(); ++monomialIteratorInner){
926  if (monomialIteratorOuter == monomialIteratorInner){
927  continue;
928  }
929 
930  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << std::endl << "creating variableCapsuleInner..."; }
931 
932  smtrat::VariableCapsule variableCapsuleInner = extractVariables(monomialIteratorInner);
933 
934  if (axiomType == AxiomType::MONOTONICITY){
935 
936  if(abEqualcCheck(variableCapsuleInner, linearizedModel) || abEqualcCheck(variableCapsuleOuter, linearizedModel)){
937 
938  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abEqualcCheck is true, creating Monotonicity..." << std::endl; }
939 
940  FormulasT createdMonotonicity = createMonotonicity(variableCapsuleOuter, variableCapsuleInner, absoluteValuedModel);
941  formulas.insert(std::end(formulas), std::begin(createdMonotonicity), std::end(createdMonotonicity));
942 
943  } else { if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abEqualcCheck is false Monotonicity is not creating..." << std::endl; }}
944 
945  } else {
946 
947  formulas.push_back(createCongruence(variableCapsuleOuter, variableCapsuleInner));
948 
949  }
950  }
951 
952  } else if (axiomType == AxiomType::ICP) {
953 
954  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "ICP axioms are creating..." << std::endl; }
955 
956  // For ICP, we take the a, b, c always as positive value.
957  RationalCapsule rationalCapsuleAbs(carl::abs(rationalCapsule.getARational()), carl::abs(rationalCapsule.getBRational()), carl::abs(rationalCapsule.getCRational()));
958 
959  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "rationalCapsuleAbs for ICP with a: " << rationalCapsuleAbs.getARational() << " b: " << rationalCapsuleAbs.getBRational() << " c: " << rationalCapsuleAbs.getCRational() << std::endl; }
960 
961  if (isAnyRationalIsZero(rationalCapsuleAbs)){
962 
963  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "one of the rational is zero and Zero axiom is creating..." << std::endl; }
964 
965  FormulasT createdZeroFormulas = createZero(variableCapsuleOuter);
966  formulas.insert(std::end(formulas), std::begin(createdZeroFormulas), std::end(createdZeroFormulas));
967 
968  } else {
969 
970  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "none of the rational is zero and ICP is creating..." << std::endl; }
971 
972  if (abGreatercCheck(rationalCapsuleAbs)) {
973 
974  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abGreatercCheck is true and ICPGreater is creating..." << std::endl; }
975 
976  RationalCapsule rationalCapsulePrimeForICPGreater = generateAbcPrimeForICP(rationalCapsuleAbs, true);
977  // RationalCapsule rationalCapsulePrimeForICPGreater(rationalCapsuleAbs.getARational(), rationalCapsuleAbs.getBRational(), rationalCapsuleAbs.getARational() * rationalCapsuleAbs.getBRational());
978 
979  FormulasT createdICPGreater = createICPGreater(variableCapsuleOuter, rationalCapsulePrimeForICPGreater);
980  formulas.insert(std::end(formulas), std::begin(createdICPGreater), std::end(createdICPGreater));
981 
982  } else if (abLesscCheck(rationalCapsuleAbs)) {
983 
984  if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "abLesscCheck is true and ICPLess is creating..." << std::endl; }
985 
986  RationalCapsule rationalCapsulePrimeForICPLess = generateAbcPrimeForICP(rationalCapsuleAbs, false);
987  // RationalCapsule rationalCapsulePrimeForICPLess(rationalCapsuleAbs.getARational(), rationalCapsuleAbs.getBRational(), rationalCapsuleAbs.getARational() * rationalCapsuleAbs.getBRational());
988 
989  formulas.push_back(createICPLess(variableCapsuleOuter, rationalCapsulePrimeForICPLess));
990 
991  } else { if (smtrat::LOG::getInstance().isDebugEnabled()) { std::cout << "None of the precondition is true and ICP is not creating..." << std::endl; } }
992  }
993  }
994  }
995  return formulas;
996  }
997 
998 
999 }
1000 
static FormulasT createFormula(AxiomType axiomType, Model linearizedModel, MonomialMap monomialMap)
const Rational & getCRational() const
const Rational & getBRational() const
const Rational & getARational() const
const carl::Variable & getYVariable() const
const carl::Variable & getZVariable() const
const carl::Variable & getXVariable() const
Numeric abs(const Numeric &_value)
Calculates the absolute value of the given Numeric.
Definition: Numeric.cpp:276
Class to create the formulas for axioms.
const smtrat::VariableCapsule extractVariables(MonomialMapIterator monomialIterator)
Model createAbsoluteValuedModel(Model linearizedModel)
FormulaT createTangentPlaneNEQFour(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational, Rational bRational)
FormulaT generateAbsFormula(carl::Variable variable, carl::Variable aux_variable)
| x1 | = (and (=> (x1 >= 0) (y1 = x1)) (=> (x1 < 0) (y1 = -x1)) )
FormulaT createTangentPlaneEQOne(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational)
FormulasT createMonotonicity(VariableCapsule variableCapsuleOuter, VariableCapsule variableCapsuleInner, Model absoluteValuedModel)
FormulaT createEquivalentToOriginalMonotonicityTwo(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
FormulaT createICPLess(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
carl::Formula< Poly > FormulaT
Definition: types.h:37
FormulaT createZeroTwo(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable)
std::unordered_map< carl::Variable, carl::Monomial::Arg > MonomialMap
Definition: Util.h:11
bool abLesscCheck(RationalCapsule rationalCapsule)
carl::Model< Rational, Poly > Model
Definition: model.h:13
FormulaT createOriginalMonotonicityTwo(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
FormulasT createTangentPlaneNEQ(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
FormulaT createTangentPlaneNEQOne(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational)
FormulaT createTangentPlaneEQTwo(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational)
FormulasT createICPGreater(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
FormulaT createOriginalMonotonicityOne(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
std::unordered_map< carl::Variable, carl::Monomial::Arg >::iterator MonomialMapIterator
Definition: Util.h:10
carl::Interval< Rational > RationalInterval
Definition: model.h:27
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
FormulaT createEquivalentToOriginalMonotonicityOne(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
FormulaT createOriginalMonotonicityThree(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
FormulasT createTangentPlaneEQ(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
FormulaT createZeroOne(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable)
bool abEqualcCheck(VariableCapsule variableCapsuleOuter, Model linearizedModel)
bool abGreatercCheck(RationalCapsule rationalCapsule)
FormulaT createICPGreaterTwo(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
FormulaT createICPGreaterOne(VariableCapsule variableCapsule, RationalCapsule rationalCapsule)
carl::Formulas< Poly > FormulasT
Definition: types.h:39
mpq_class Rational
Definition: types.h:19
FormulaT createCongruence(smtrat::VariableCapsule variableCapsuleOuter, smtrat::VariableCapsule variableCapsuleInner)
FormulasT createZero(smtrat::VariableCapsule variableCapsule)
FormulaT createZeroThree(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable)
RationalCapsule generateAbcPrimeForICP(RationalCapsule rationalCapsule, bool isGreater)
FormulaT createTangentPlaneNEQThree(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational aRational, Rational bRational)
bool isAnyRationalIsZero(RationalCapsule rationalCapsule)
FormulaT createEquivalentToOriginalMonotonicityThree(smtrat::VariableCapsule variableCapsule, smtrat::VariableCapsule variableCapsuleInner)
RationalCapsule extractRationalCapsule(VariableCapsule variableCapsule, Model linearizedModel)
carl::Variable createAuxiliaryVariable(carl::Variable variable)
create an auxiliary variable e.g.
FormulaT createTangentPlaneNEQTwo(carl::Variable xVariable, carl::Variable yVariable, carl::Variable zVariable, Rational bRational)