SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PolyTree.h
Go to the documentation of this file.
1 /**
2  * @file PolyTree.h
3  * @author Andreas Krueger <andreas.krueger@rwth-aachen.de>
4  */
5 
6 #pragma once
7 
8 #include <optional>
10 
11 namespace smtrat
12 {
13  // forward declaration
14  class PolyTreeContent;
15 
16  // forward declaration
17  class PolyTreePool;
18 
19  class PolyTree
20  {
21  private:
23 
24  public:
25  enum class Type : unsigned { VARIABLE, CONSTANT, SUM, PRODUCT };
26 
27  PolyTree(const Poly& _poly);
28 
29  const PolyTree& left() const;
30  const PolyTree& right() const;
31  carl::Variable::Arg variable() const;
32  const Integer& constant() const;
33  Type type() const;
34  const Poly& poly() const;
35  };
36 
38  {
39  friend class PolyTree;
40 
41  private:
44  union
45  {
46  carl::Variable mVariable;
48  };
49  std::optional<PolyTree> mLeft;
50  std::optional<PolyTree> mRight;
51 
52  public:
53  PolyTreeContent(const Poly& _poly, PolyTree::Type _type, const PolyTree& _left, const PolyTree& _right) :
54  mPoly(_poly), mType(_type), mVariable(), mLeft(_left), mRight(_right)
55  {
56  assert(_type == PolyTree::Type::SUM || _type == PolyTree::Type::PRODUCT);
57  }
58 
59  PolyTreeContent(carl::Variable::Arg _variable) :
60  mPoly(_variable), mType(PolyTree::Type::VARIABLE), mVariable(_variable), mLeft(), mRight()
61  { }
62 
63  PolyTreeContent(Integer _constant) :
64  mPoly(_constant), mType(PolyTree::Type::CONSTANT), mConstant(_constant), mLeft(), mRight()
65  { }
66 
68  {
70  mConstant.~Integer();
71  } else {
72  mVariable.~Variable();
73  }
74  }
75 
76  const Poly& poly() const
77  {
78  return mPoly;
79  }
80 
81  bool operator==(const PolyTreeContent& _other) const
82  {
83  return mPoly == _other.mPoly;
84  }
85 
86  };
87 } // namespace smtrat
PolyTree::Type mType
Definition: PolyTree.h:43
carl::Variable mVariable
Definition: PolyTree.h:46
PolyTreeContent(carl::Variable::Arg _variable)
Definition: PolyTree.h:59
PolyTreeContent(const Poly &_poly, PolyTree::Type _type, const PolyTree &_left, const PolyTree &_right)
Definition: PolyTree.h:53
std::optional< PolyTree > mRight
Definition: PolyTree.h:50
bool operator==(const PolyTreeContent &_other) const
Definition: PolyTree.h:81
const Poly & poly() const
Definition: PolyTree.h:76
PolyTreeContent(Integer _constant)
Definition: PolyTree.h:63
std::optional< PolyTree > mLeft
Definition: PolyTree.h:49
const Poly & poly() const
Definition: PolyTree.cpp:39
const PolyTreeContent * mpContent
Definition: PolyTree.h:22
const PolyTree & left() const
Definition: PolyTree.cpp:15
carl::Variable::Arg variable() const
Definition: PolyTree.cpp:25
const PolyTree & right() const
Definition: PolyTree.cpp:20
PolyTree(const Poly &_poly)
Definition: PolyTree.cpp:11
const Integer & constant() const
Definition: PolyTree.cpp:30
Type type() const
Definition: PolyTree.cpp:35
Class to create the formulas for axioms.
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
carl::IntegralType< Rational >::type Integer
Definition: types.h:21