carl  24.04
Computer ARithmetic Library
BVCompareRelation.h
Go to the documentation of this file.
1 /**
2  * @file BVCompareRelation.h
3  * @author Andreas Krueger <andreas.krueger@rwth-aachen.de>
4  */
5 
6 #pragma once
7 
8 #include <cassert>
9 #include <iostream>
10 #include <string>
11 
12 namespace carl
13 {
14 
15  enum class BVCompareRelation : unsigned
16  {
17  EQ, // =
18  NEQ, // <>
19  ULT, // unsigned <
20  ULE, // unsigned <=
21  UGT, // unsigned >
22  UGE, // unsigned >=
23  SLT, // signed <
24  SLE, // signed <=
25  SGT, // signed >
26  SGE // signed >=
27  };
28 
29  inline std::string toString(BVCompareRelation _r)
30  {
31  switch(_r) {
32  case BVCompareRelation::EQ: return "=";
33  case BVCompareRelation::NEQ: return "<>";
34  case BVCompareRelation::ULT: return "bvult";
35  case BVCompareRelation::ULE: return "bvule";
36  case BVCompareRelation::UGT: return "bvugt";
37  case BVCompareRelation::UGE: return "bvuge";
38  case BVCompareRelation::SLT: return "bvslt";
39  case BVCompareRelation::SLE: return "bvsle";
40  case BVCompareRelation::SGT: return "bvsgt";
41  case BVCompareRelation::SGE: return "bvsge";
42  }
43  assert(false);
44  return "";
45  }
46 
47  inline std::ostream& operator<<(std::ostream& _os, const BVCompareRelation& _r)
48  {
49  return(_os << toString(_r));
50  }
51 
52  inline std::size_t toId(const BVCompareRelation _relation)
53  {
54  return static_cast<std::size_t>(_relation);
55  }
56 
58  {
59  switch(_c) {
70  }
71  assert(false);
72  return BVCompareRelation::EQ;
73  }
74 
76  {
77  return _r == BVCompareRelation::ULT ||
78  _r == BVCompareRelation::UGT ||
79  _r == BVCompareRelation::SLT ||
80  _r == BVCompareRelation::SGT ||
82  }
83 
85  {
86  return _r == BVCompareRelation::SLT ||
87  _r == BVCompareRelation::SLE ||
88  _r == BVCompareRelation::SGT ||
90  }
91 
92 } // end namespace carl
93 
94 namespace std
95 {
96 
97  template<>
98  struct hash<carl::BVCompareRelation>
99  {
100 
101  std::size_t operator()(const carl::BVCompareRelation& _rel) const
102  {
103  return static_cast<std::size_t>(_rel);
104  }
105  };
106 
107 } // end namespace std
carl is the main namespace for the library.
std::string toString(Relation r)
Definition: Relation.h:73
std::size_t toId(const BVCompareRelation _relation)
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
bool relationIsSigned(BVCompareRelation _r)
Relation inverse(Relation r)
Inverts the given relation symbol.
Definition: Relation.h:40
bool relationIsStrict(BVCompareRelation _r)
std::size_t operator()(const carl::BVCompareRelation &_rel) const