SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
representation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "derivation.h"
4 #include "roots.h"
5 
6 #include <boost/container/flat_set.hpp>
7 
9 /**
10  * Represents a cell.
11  */
12 template<typename P>
14  /// Description of a cell.
16  /// Polys considered in the indexed root ordering.
17  boost::container::flat_set<PolyRef> ordering_polys;
18  /// Polys that are considered "non-projectively" in the ordering.
19  boost::container::flat_set<PolyRef> ordering_non_projective_polys;
20  /// An ordering on the roots that protects the cell.
22  /// Polynomials that should be projected using the equational constraints projection.
23  boost::container::flat_set<PolyRef> equational;
24  /// Derivation
26 
28  : derivation(deriv) {}
29 };
30 template<typename P>
31 inline std::ostream& operator<<(std::ostream& os, const CellRepresentation<P>& data) {
32  os << "(cell: " << data.description << "; ordering: " << data.ordering << "; equational: " << data.equational << "; derivation: " << data.derivation << ")";
33  return os;
34 }
35 
36 /**
37 * Represents a covering over a cell.
38 *
39 * The cells forming the covering are in increasing order (ordered by lower bound) and no cell is contained in another cell.
40 */
41 template<typename P>
43  /// Cells of the covering in increasing order and no cell is contained in another cell.
44  std::vector<CellRepresentation<P>> cells;
45  /// An ordering on the roots for the cell boundaries mainting the covering.
47  /// Returns a descriptions of the covering.
49  assert(is_valid());
51  for (const auto& cell : cells) {
52  cov.add(cell.description);
53  }
54  return cov;
55  }
56  /// Returns the derivations.
57  std::vector<SampledDerivationRef<P>> sampled_derivations() {
58  std::vector<SampledDerivationRef<P>> cov;
59  for (const auto& cell : cells) {
60  cov.push_back(cell.derivation);
61  }
62  return cov;
63  }
64 
65  /// Checks whether this represents a proper non-redundant covering.
66  bool is_valid() const {
67  auto cell = cells.begin();
68 
69  // covering
70  if (!cell->derivation->cell().lower_unbounded()) return false;
71  while (cell != std::prev(cells.end())) {
72  cell++;
73  if (std::prev(cell)->derivation->cell().upper_unbounded()) return false;
74  if (cell->derivation->cell().lower_unbounded()) return false;
75  if (upper_lt_lower(std::prev(cell)->derivation->cell(), cell->derivation->cell())) return false;
76  }
77  if (!cell->derivation->cell().upper_unbounded()) return false;
78 
79  // redundancy
80  cell = cells.begin();
81  while (cell != std::prev(cells.end())) {
82  cell++;
83  if (std::prev(cell)->derivation->cell().upper_unbounded()) return false;
84  if (cell->derivation->cell().lower_unbounded()) return false;
85  if (cell->derivation->cell().upper_unbounded()) continue;
86  if (upper_lt_upper(cell->derivation->cell(), std::prev(cell)->derivation->cell())) return false;
87  }
88 
89  return true;
90  }
91 };
92 
93 template<typename P>
94 std::ostream& operator<<(std::ostream& os, const CoveringRepresentation<P>& data) {
95  os << "(cells: " << data.cells << ", ordering: " << data.ordering << ")";
96  return os;
97 }
98 
99 } // namespace smtrat::cadcells::datastructures
Describes a covering of the real line by SymbolicIntervals (given an appropriate sample).
Definition: roots.h:342
void add(const SymbolicInterval &c)
Add a SymbolicInterval to the covering.
Definition: roots.h:357
Describes an ordering of IndexedRoots.
Definition: roots.h:400
A symbolic interal whose bounds are defined by indexed root expressions.
Definition: roots.h:250
Main datastructures.
Definition: delineation.h:9
std::ostream & operator<<(std::ostream &os, const TaggedIndexedRoot &data)
Definition: delineation.h:17
bool upper_lt_upper(const DelineationInterval &del1, const DelineationInterval &del2)
Compares the upper bounds of two DelineationIntervals.
Definition: delineation.h:286
bool upper_lt_lower(const DelineationInterval &del1, const DelineationInterval &del2)
Compares an upper bound with a lower bound of DelineationIntervals.
Definition: delineation.h:296
std::shared_ptr< SampledDerivation< Properties > > SampledDerivationRef
Definition: derivation.h:25
IndexedRootOrdering ordering
An ordering on the roots that protects the cell.
boost::container::flat_set< PolyRef > ordering_polys
Polys considered in the indexed root ordering.
SymbolicInterval description
Description of a cell.
boost::container::flat_set< PolyRef > equational
Polynomials that should be projected using the equational constraints projection.
boost::container::flat_set< PolyRef > ordering_non_projective_polys
Polys that are considered "non-projectively" in the ordering.
CellRepresentation(SampledDerivationRef< P > &deriv)
SampledDerivationRef< P > derivation
Derivation.
IndexedRootOrdering ordering
An ordering on the roots for the cell boundaries mainting the covering.
std::vector< CellRepresentation< P > > cells
Cells of the covering in increasing order and no cell is contained in another cell.
CoveringDescription get_covering() const
Returns a descriptions of the covering.
std::vector< SampledDerivationRef< P > > sampled_derivations()
Returns the derivations.
bool is_valid() const
Checks whether this represents a proper non-redundant covering.