SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Dependencies.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-common/datastructures/Bitset.h>
5 
6 namespace smtrat {
7 namespace mcsat {
8 namespace icp {
9 
10 class Dependencies {
11 private:
12  std::vector<FormulaT> mConstraints;
13  std::map<FormulaT,std::size_t> mConstraintIDs;
14  std::map<carl::Variable,carl::Bitset> mData;
15 
16  std::size_t get_constraint_id(const FormulaT& c) {
17  auto it = mConstraintIDs.find(c);
18  if (it == mConstraintIDs.end()) {
19  it = mConstraintIDs.emplace(c, mConstraintIDs.size()).first;
20  mConstraints.emplace_back(c);
21  }
22  return it->second;
23  }
24 public:
25  template<typename Contractor>
26  void add(const Contractor& c) {
27  add(c.var(), c.origin(), c.dependees());
28  }
29 
30  void add(carl::Variable v, const FormulaT& c, const std::vector<carl::Variable>& used) {
31  auto& bs = mData[v];
32  bs.set(get_constraint_id(c));
33  SMTRAT_LOG_DEBUG("smtrat.mcsat.icp", "Added " << c << " to " << v << " -> " << bs);
34  for (auto used_var: used) {
35  bs = bs | mData[used_var];
36  SMTRAT_LOG_DEBUG("smtrat.mcsat.icp", "Added " << mData[used_var] << " from " << used_var << " to " << v << " -> " << bs);
37  }
38  }
39 
40  std::vector<FormulaT> get(carl::Variable v, bool negate = true) const {
41  std::vector<FormulaT> res;
42  auto it = mData.find(v);
43  assert(it != mData.end());
44  for (std::size_t i: it->second) {
45  res.emplace_back(negate ? !mConstraints[i] : mConstraints[i]);
46  }
47  return res;
48  }
49 };
50 
51 }
52 }
53 }
std::vector< FormulaT > mConstraints
Definition: Dependencies.h:12
std::vector< FormulaT > get(carl::Variable v, bool negate=true) const
Definition: Dependencies.h:40
void add(carl::Variable v, const FormulaT &c, const std::vector< carl::Variable > &used)
Definition: Dependencies.h:30
void add(const Contractor &c)
Definition: Dependencies.h:26
std::map< FormulaT, std::size_t > mConstraintIDs
Definition: Dependencies.h:13
std::map< carl::Variable, carl::Bitset > mData
Definition: Dependencies.h:14
std::size_t get_constraint_id(const FormulaT &c)
Definition: Dependencies.h:16
carl::Contraction< Operator, Poly > Contractor
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
#define SMTRAT_LOG_DEBUG(channel, msg)
Definition: logging.h:35