SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Covering.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-common/datastructures/Bitset.h>
5 
6 #include <iostream>
7 #include <map>
8 
9 namespace smtrat {
10 namespace mcsat {
11 namespace arithmetic {
12 
13 
14 /**
15  * Semantics:
16  * The space is divided into a number of intervals: (-oo,a)[a,a](a,b)[b,b](b,oo)
17  * A bit is set if the constraints refutes the corresponding interval
18  */
19 class Covering {
20  friend std::ostream& operator<<(std::ostream& os, const Covering& ri);
21 private:
22  std::map<FormulaT, carl::Bitset> mData;
23  carl::Bitset mOkay;
24 public:
25  Covering(std::size_t intervals) {
26  mOkay.resize(intervals, true);
27  }
28  void add(const FormulaT& c, const carl::Bitset& b) {
29  mData.emplace(c, b);
30  mOkay -= b;
31  }
32  bool conflicts() const {
33  return mOkay.none();
34  }
35  std::size_t satisfyingInterval() const {
36  return mOkay.find_first();
37  }
38  const auto& satisfyingSamples() const {
39  return mOkay;
40  }
41  void buildConflictingCore(std::vector<FormulaT>& core) const {
42  std::map<FormulaT, carl::Bitset> data = mData;
43  carl::Bitset covered;
44  covered.resize(mOkay.size(), true);
45  while (covered.any()) {
46  auto maxit = data.begin();
47  for (auto it = data.begin(); it != data.end(); it++) {
48  if (maxit->second.count() < it->second.count()) maxit = it;
49  }
50  core.push_back(maxit->first);
51  covered -= maxit->second;
52  data.erase(maxit);
53  for (auto& d: data) {
54  d.second &= covered;
55  }
56  }
57  }
58 };
59 inline std::ostream& operator<<(std::ostream& os, const Covering& ri) {
60  os << "Covering: " << ri.mOkay << std::endl;
61  for (const auto& d: ri.mData) {
62  os << "\t" << d.first << " -> " << d.second << std::endl;
63  }
64  return os;
65 }
66 
67 }
68 }
69 }
Semantics: The space is divided into a number of intervals: (-oo,a)[a,a](a,b)[b,b](b,...
Definition: Covering.h:19
std::map< FormulaT, carl::Bitset > mData
Definition: Covering.h:22
void buildConflictingCore(std::vector< FormulaT > &core) const
Definition: Covering.h:41
const auto & satisfyingSamples() const
Definition: Covering.h:38
Covering(std::size_t intervals)
Definition: Covering.h:25
friend std::ostream & operator<<(std::ostream &os, const Covering &ri)
Definition: Covering.h:59
void add(const FormulaT &c, const carl::Bitset &b)
Definition: Covering.h:28
std::size_t satisfyingInterval() const
Definition: Covering.h:35
std::ostream & operator<<(std::ostream &os, const Covering &ri)
Definition: Covering.h:59
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37