SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
properties.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../common.h"
4 //#include <set>
5 #include <boost/container/flat_set.hpp>
6 
8 
9 template<typename T>
10 struct property_hash {
11  std::size_t operator()(const T& p) const {
12  return p.hash_on_level();
13  }
14 };
15 
16 template<typename T>
17 //using PropertiesTSet = std::unordered_set<T, property_hash<T>>;
18 //using PropertiesTSet = std::set<T>;
19 using PropertiesTSet = boost::container::flat_set<T>;
20 
21 template<typename T, bool is_flag>
23 
24 template<typename T>
25 struct PropertiesTContent<T, true> {
26  using type = bool;
27 };
28 
29 template<typename T>
30 struct PropertiesTContent<T, false> {
32 };
33 
34 /**
35  * Set of properties.
36  *
37  * This is a recursive template. The list of template parameters specifies the type of properties which can be hold by this set.
38  *
39  * Note that only properties of the same level should be stored within this datastructure.
40  *
41  * Properties have the following requirements:
42  * * They need to implement level().
43  * * They need to implement hash_on_level(), operator< and operator== for comparing with properties of the same type and level.
44  * * They need to have a member `static constexpr bool is_flag`. If set to `true`, this indicates that there is only one property of this kind per level and thus, it is not stored in a set but only a Boolean flag is stored.
45  * * They need to implement operator<<.
46  */
47 template<typename... Ts>
48 struct PropertiesT {};
49 
50 template <class T, class... Ts>
51 struct PropertiesT<T, Ts...> : PropertiesT<Ts...> {
53 };
54 
55 template <class T, class... Ts>
56 void prop_insert(PropertiesT<T, Ts...>& sets, const T& element) {
57  if constexpr (!T::is_flag) {
58  sets.content.emplace(element);
59  } else {
60  sets.content = true;
61  }
62 }
63 template <class S, class T, class... Ts, typename std::enable_if<!std::is_same<S, T>::value>::type>
64 void prop_insert(PropertiesT<T, Ts...>& sets, const S& element) {
65  PropertiesT<Ts...>& base = sets;
66  prop_insert<S>(base, element);
67 }
68 
69 template <class T, class... Ts>
70 bool prop_has(const PropertiesT<T, Ts...>& sets, const T& element) {
71  if constexpr (!T::is_flag) {
72  return sets.content.find(element) != sets.content.end();
73  } else {
74  return sets.content;
75  }
76 
77 }
78 template <class S, class T, class... Ts, typename std::enable_if<!std::is_same<S, T>::value>::type>
79 bool prop_has(const PropertiesT<T, Ts...>& sets, const S& element) {
80  PropertiesT<Ts...>& base = sets;
81  return prop_has<S>(base, element);
82 }
83 
84 template <class T, class... Ts>
85 const auto& prop_get(const PropertiesT<T, Ts...>& sets) {
86  return sets.content;
87 }
88 template <class S, class T, class... Ts, typename std::enable_if<!std::is_same<S, T>::value>::type>
89 const auto& prop_get(const PropertiesT<T, Ts...>& sets) {
90  const PropertiesT<Ts...>& base = sets;
91  return prop_get<S>(base);
92 }
93 
94 //template <class T, class... Ts, typename std::enable_if<(sizeof...(Ts) == 0)>::type>
95 //void merge(PropertiesT<T>& sets_a, const PropertiesT<T>& sets_b) {
96 // sets_a.content.insert(sets_b.content.begin(), sets_b.content.end());
97 //}
98 
99 //template <class T, class... Ts, typename std::enable_if<(sizeof...(Ts) > 0)>::type>
100 template <class T, class... Ts>
101 void merge(PropertiesT<T, Ts...>& sets_a, const PropertiesT<T, Ts...>& sets_b) {
102  if constexpr (!T::is_flag) {
103  sets_a.content.insert(sets_b.content.begin(), sets_b.content.end());
104  } else {
105  sets_a.content = sets_a.content || sets_b.content;
106  }
107 
108  if constexpr(sizeof...(Ts) > 0) {
109  PropertiesT<Ts...>& base_a = sets_a;
110  const PropertiesT<Ts...>& base_b = sets_b;
111  return merge(base_a, base_b);
112  }
113 }
114 
115 }
Main datastructures.
Definition: delineation.h:9
void prop_insert(PropertiesT< T, Ts... > &sets, const T &element)
Definition: properties.h:56
SampledDerivationRef< Properties > merge(std::vector< SampledDerivationRef< Properties >> &derivations)
Merges a set of sampled derivations.
Definition: derivation.h:427
const auto & prop_get(const PropertiesT< T, Ts... > &sets)
Definition: properties.h:85
boost::container::flat_set< T > PropertiesTSet
Definition: properties.h:19
bool prop_has(const PropertiesT< T, Ts... > &sets, const T &element)
Definition: properties.h:70
QuantifierType type(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:39
PropertiesTContent< T, T::is_flag >::type content
Definition: properties.h:52
std::size_t operator()(const T &p) const
Definition: properties.h:11