24 #ifndef PPL_Powerset_templates_hh
25 #define PPL_Powerset_templates_hh 1
28 #include "assertions.hh"
37 PPL_ASSERT(sink != sequence.end());
44 d.upper_bound_assign(*xi);
47 drop_disjuncts(next_x_sink, x_end);
50 for (
iterator xi = begin(); xi != x_sink; ) {
51 if (xi->definitely_entails(d)) {
52 xi = drop_disjunct(xi);
59 PPL_ASSERT_HEAVY(OK());
71 if (xi->is_bottom()) {
81 bool dropping_xi =
false;
88 if (yv.definitely_entails(xv)) {
91 else if (xv.definitely_entails(yv)) {
113 PPL_ASSERT_HEAVY(OK());
116 template <
typename D>
119 PPL_ASSERT(max_disjuncts > 0);
123 if (n > max_disjuncts) {
126 std::advance(i, max_disjuncts-1);
131 PPL_ASSERT_HEAVY(OK());
132 PPL_ASSERT(is_omega_reduced());
135 template <
typename D>
139 xi = x_begin; xi != x_end; ++xi) {
141 if (xv.is_bottom()) {
149 if (xv.definitely_entails(yv) || yv.definitely_entails(xv)) {
157 template <
typename D>
160 if (!reduced && check_omega_reduced()) {
166 template <
typename D>
171 PPL_ASSERT_HEAVY(!d.is_bottom());
172 for (
iterator xi = first; xi != last; ) {
174 if (d.definitely_entails(xv)) {
177 else if (xv.definitely_entails(d)) {
181 xi = drop_disjunct(xi);
187 sequence.push_back(d);
188 PPL_ASSERT_HEAVY(OK());
192 template <
typename D>
198 x_end = x.
end(); found && xi != x_end; ++xi) {
201 y_end = y.
end(); !found && yi != y_end; ++yi) {
209 template <
typename D>
220 x_end = x.
end(); xi != x_end; ++xi) {
223 zi = std::find(zi, z_end, *xi);
234 template <
typename D>
235 template <
typename Binary_Operator_Assign>
238 Binary_Operator_Assign op_assign) {
244 y_begin = y.
begin(), y_end = y.
end(); xi != x_end; ++xi) {
248 if (!zi.is_bottom()) {
249 new_sequence.push_back(zi);
256 PPL_ASSERT_HEAVY(OK());
259 template <
typename D>
268 old_begin = add_non_bottom_disjunct_preserve_reduction(*i,
272 PPL_ASSERT_HEAVY(OK());
275 namespace IO_Operators {
278 template <
typename D>
280 operator<<(std::ostream& s, const Powerset<D>& x) {
284 else if (x.is_top()) {
289 x_end = x.end(); i != x_end; ) {
290 s <<
"{ " << *i <<
" }";
302 template <
typename D>
306 for (
const_iterator xi = begin(), x_end = end(); xi != x_end; ++xi) {
307 bytes += xi->total_memory_in_bytes();
311 bytes += 2*
sizeof(D*);
316 template <
typename D>
319 for (
const_iterator xi = begin(), x_end = end(); xi != x_end; ++xi) {
323 if (disallow_bottom && xi->is_bottom()) {
325 std::cerr <<
"Bottom element in powerset!"
331 if (reduced && !check_omega_reduced()) {
333 std::cerr <<
"Powerset claims to be reduced, but it is not!"
343 #endif // !defined(PPL_Powerset_templates_hh)
size_type size() const
Returns the number of disjuncts.
void swap(CO_Tree &x, CO_Tree &y)
iterator add_non_bottom_disjunct_preserve_reduction(const D &d, iterator first, iterator last)
Adds to *this the disjunct d, assuming d is not the bottom element and ensuring partial Omega-reducti...
iterator drop_disjunct(iterator position)
Drops the disjunct in *this pointed to by position, returning an iterator to the disjunct following p...
bool OK(bool disallow_bottom=false) const
Checks if all the invariants are satisfied.
iterator begin()
Returns an iterator pointing to the first disjunct, if *this is not empty; otherwise, returns the past-the-end iterator.
void omega_reduce() const
Drops from the sequence of disjuncts in *this all the non-maximal elements so that *this is non-redun...
The powerset construction on a base-level domain.
bool definitely_entails(const Powerset &y) const
Returns true if *this definitely entails y. Returns false if *this may not entail y (i...
void least_upper_bound_assign(const Powerset &y)
Assigns to *this the least upper bound of *this and y.
bool operator==(const Powerset< D > &x, const Powerset< D > &y)
iterator end()
Returns the past-the-end iterator.
Base base
A (mutable) iterator on the sequence of elements.
A const_iterator on a sequence of read-only objects.
void collapse()
If *this is not empty (i.e., it is not the bottom element), it is reduced to a singleton obtained by ...
The entire library is confined to this namespace.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
Sequence::size_type size_type
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the disjuncts.
An iterator on a sequence of read-only objects.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
const Throwable *volatile abandon_expensive_computations
A pointer to an exception object.
bool is_omega_reduced() const
Returns true if and only if *this does not contain non-maximal elements.
std::list< D > Sequence
A powerset is implemented as a sequence of elements.
void pairwise_apply_assign(const Powerset &y, Binary_Operator_Assign op_assign)
Assigns to *this the result of applying op_assign pairwise to the elements in *this and y...
bool check_omega_reduced() const
Does the hard work of checking whether *this contains non-maximal elements and returns true if and on...