SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Simplification.cpp
Go to the documentation of this file.
1 #include "Simplification.h"
2 
3 namespace smtrat::covering_ng {
4 
5 void simplify(ParameterTree& tree) {
6  assert(boost::indeterminate(tree.status) || tree.children.empty());
7 
8  if (boost::indeterminate(tree.status)) {
9  for (auto& child : tree.children) {
10  simplify(child);
11  }
12 
13  std::vector<ParameterTree> new_children;
14  auto start = tree.children.begin();
15  auto end = tree.children.begin();
16  while(start != tree.children.end()) {
17  while(boost::indeterminate(start->status) && start != tree.children.end()) {
18  new_children.emplace_back(std::move(*start));
19  start++;
20  }
21  end = start;
22  if (start == tree.children.end()) break;
23 
24  while(start->status == end->status && end != tree.children.end()) {
25  end++;
26  }
27  if (start+1 == end) {
28  new_children.emplace_back(std::move(*start));
29  } else {
30  cadcells::datastructures::SymbolicInterval new_interval(start->interval->lower(), (end-1)->interval->upper());
31  new_children.emplace_back(start->status, *start->variable, new_interval, !start->interval->is_section() ? *start->sample : *(start+1)->sample);
32  }
33  start = end;
34  }
35  tree.children = new_children;
36 
37  if (tree.children.size() == 1) { // optional, does not affect output formula
38  assert(tree.children.begin()->interval->lower().is_infty() && tree.children.begin()->interval->upper().is_infty());
39  tree.status = tree.children.begin()->status;
40  tree.children = tree.children.begin()->children;
41  }
42  }
43 }
44 
45 }
A symbolic interal whose bounds are defined by indexed root expressions.
Definition: roots.h:250
void simplify(ParameterTree &tree)
std::vector< ParameterTree > children
Definition: types.h:104