SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
quantifier_splitting.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace smtrat::qe::util {
6 
7 struct Subquery {
9  std::vector<carl::Variable> elimination_vars;
10  Subquery(const FormulasT& fs, const std::vector<carl::Variable> vs)
11  : constraints(fs), elimination_vars(vs) {}
12 };
13 
14 std::vector<Subquery> split_quantifiers(const FormulasT& constraints, const std::vector<carl::Variable>& vars) {
15  std::vector<Subquery> blocks;
16  std::vector<int> ccs(vars.size(), -1);
17  std::vector<bool> constraint_used(constraints.size(), false);
18 
19  std::vector<std::size_t> pending;
20 
21  for (std::size_t i = 0; i < vars.size();) {
22  pending.push_back(i);
23  blocks.push_back(Subquery({},{}));
24  ++i;
25  while (!pending.empty()) {
26  std::size_t v = pending.back();
27  pending.pop_back();
28  if (ccs[v] != -1) continue;
29  assert(blocks.size() > 0);
30  ccs[v] = static_cast<int>(blocks.size()) - 1;
31  blocks.back().elimination_vars.push_back(vars[v]);
32  for (std::size_t k = 0; k < constraints.size(); ++k) {
33  if (constraint_used[k]) continue;
34  auto vars_c = carl::variables(constraints[k]);
35  if (vars_c.has(vars[v])) {
36  for (std::size_t v_other = 0; v_other < vars.size(); ++v_other) {
37  if (v != v_other && vars_c.has(vars[v_other])) {
38  pending.push_back(v_other);
39  }
40  }
41  constraint_used[k] = true;
42  blocks.back().constraints.push_back(constraints[k]);
43  }
44  }
45  }
46  while (i < vars.size() && ccs[i] != -1) ++i;
47  }
48 
49  return blocks;
50 }
51 
52 }
std::vector< Subquery > split_quantifiers(const FormulasT &constraints, const std::vector< carl::Variable > &vars)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:43
carl::Formulas< Poly > FormulasT
Definition: types.h:39
std::vector< carl::Variable > elimination_vars
Subquery(const FormulasT &fs, const std::vector< carl::Variable > vs)