SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
helper.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-arith/core/Variable.h>
4 
5 #include <map>
6 #include <vector>
7 
8 namespace smtrat {
9 namespace mcsat {
10 namespace variableordering {
11 
12 struct VariableIDs {
13  std::map<carl::Variable, std::size_t> mIDs;
14  std::size_t operator[](carl::Variable v) {
15  auto it = mIDs.find(v);
16  if (it == mIDs.end()) {
17  it = mIDs.emplace(v, mIDs.size()).first;
18  }
19  return it->second;
20  }
21  std::size_t operator[](carl::Variable v) const {
22  assert(mIDs.find(v) != mIDs.end());
23  return mIDs.find(v)->second;
24  }
25 };
26 
27 inline std::ostream& operator<<(std::ostream& os, const VariableIDs& vids) {
28  std::vector<carl::Variable> v(vids.mIDs.size());
29  for (const auto& var: vids.mIDs) {
30  assert(var.second < v.size());
31  v[var.second] = var.first;
32  }
33  return os << v;
34 }
35 
36 template<typename Constraints>
37 void gatherVariables(carl::carlVariables& vars, const Constraints& constraints) {
38  for (const auto& c: constraints) {
39  carl::variables(c, vars);
40  }
41 }
42 
43 }
44 }
45 }
int var(Lit p)
Definition: SolverTypes.h:64
void gatherVariables(carl::carlVariables &vars, const Constraints &constraints)
Definition: helper.h:37
std::ostream & operator<<(std::ostream &os, const VariableIDs &vids)
Definition: helper.h:27
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:43
Class to create the formulas for axioms.
std::size_t operator[](carl::Variable v) const
Definition: helper.h:21
std::map< carl::Variable, std::size_t > mIDs
Definition: helper.h:13
std::size_t operator[](carl::Variable v)
Definition: helper.h:14