PPL  1.2
Powerset_defs.hh
Go to the documentation of this file.
1 /* Powerset class declaration.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Powerset_defs_hh
25 #define PPL_Powerset_defs_hh
26 
27 #include "Powerset_types.hh"
28 #include "globals_types.hh"
30 #include <iosfwd>
31 #include <iterator>
32 #include <list>
33 
34 namespace Parma_Polyhedra_Library {
35 
37 
38 template <typename D>
39 void swap(Powerset<D>& x, Powerset<D>& y);
40 
42 
43 template <typename D>
44 bool
45 operator==(const Powerset<D>& x, const Powerset<D>& y);
46 
48 
49 template <typename D>
50 bool
51 operator!=(const Powerset<D>& x, const Powerset<D>& y);
52 
53 namespace IO_Operators {
54 
56 
57 template <typename D>
58 std::ostream&
59 operator<<(std::ostream& s, const Powerset<D>& x);
60 
61 } // namespace IO_Operators
62 
63 } // namespace Parma_Polyhedra_Library
64 
65 
67 
151 template <typename D>
153 public:
155 
156 
161  Powerset();
162 
164  Powerset(const Powerset& y);
165 
170  explicit Powerset(const D& d);
171 
173  ~Powerset();
174 
176 
178 
179 
186  bool definitely_entails(const Powerset& y) const;
187 
193  bool is_top() const;
194 
200  bool is_bottom() const;
201 
207 
213 
215  // FIXME: document and perhaps use an enum instead of a bool.
216  bool OK(bool disallow_bottom = false) const;
217 
219 
220 protected:
222 
226  typedef std::list<D> Sequence;
227 
229  typedef typename Sequence::iterator Sequence_iterator;
230 
232  typedef typename Sequence::const_iterator Sequence_const_iterator;
233 
235  Sequence sequence;
236 
238  mutable bool reduced;
239 
240 public:
241  // Sequence manipulation types, accessors and modifiers
242  typedef typename Sequence::size_type size_type;
243  typedef typename Sequence::value_type value_type;
244 
256 
259 
261  typedef std::reverse_iterator<iterator> reverse_iterator;
262 
264  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
265 
267 
268 
277  void omega_reduce() const;
278 
280  size_type size() const;
281 
286  bool empty() const;
287 
292  iterator begin();
293 
295  iterator end();
296 
301  const_iterator begin() const;
302 
304  const_iterator end() const;
305 
310  reverse_iterator rbegin();
311 
313  reverse_iterator rend();
314 
320  const_reverse_iterator rbegin() const;
321 
323  const_reverse_iterator rend() const;
324 
326  void add_disjunct(const D& d);
327 
332  iterator drop_disjunct(iterator position);
333 
335  void drop_disjuncts(iterator first, iterator last);
336 
338  void clear();
339 
341 
343 
344 
346  Powerset& operator=(const Powerset& y);
347 
349  void m_swap(Powerset& y);
350 
352  void least_upper_bound_assign(const Powerset& y);
353 
355 
358  void upper_bound_assign(const Powerset& y);
359 
367  bool upper_bound_assign_if_exact(const Powerset& y);
368 
370  void meet_assign(const Powerset& y);
371 
377  void collapse();
378 
380 
381 protected:
386  bool is_omega_reduced() const;
387 
393  void collapse(unsigned max_disjuncts);
394 
408  iterator add_non_bottom_disjunct_preserve_reduction(const D& d,
409  iterator first,
410  iterator last);
411 
420 
429  template <typename Binary_Operator_Assign>
430  void pairwise_apply_assign(const Powerset& y,
431  Binary_Operator_Assign op_assign);
432 
433 private:
438  bool check_omega_reduced() const;
439 
444  void collapse(Sequence_iterator sink);
445 };
446 
447 #include "Powerset_inlines.hh"
448 #include "Powerset_templates.hh"
449 
450 #endif // !defined(PPL_Powerset_defs_hh)
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
size_type size() const
Returns the number of disjuncts.
void upper_bound_assign(const Powerset &y)
Assigns to *this an upper bound of *this and y.
void swap(CO_Tree &x, CO_Tree &y)
bool is_bottom() const
Returns true if and only if *this is the bottom element of the powerset constraint system (i...
Sequence sequence
The sequence container holding powerset's elements.
std::reverse_iterator< const_iterator > const_reverse_iterator
The reverse iterator type built from Powerset::const_iterator.
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...
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
void clear()
Drops all the disjuncts, making *this an empty powerset.
reverse_iterator rbegin()
Returns a reverse_iterator pointing to the last disjunct, if *this is not empty; otherwise, returns the before-the-start reverse_iterator.
iterator_to_const< Sequence > iterator
Alias for a read-only bidirectional iterator on the disjuncts of a Powerset element.
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.
Sequence::const_iterator Sequence_const_iterator
Alias for the low-level const_iterator on the disjuncts.
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
bool definitely_entails(const Powerset &y) const
Returns true if *this definitely entails y. Returns false if *this may not entail y (i...
bool reduced
If true, *this is Omega-reduced.
reverse_iterator rend()
Returns the before-the-start reverse_iterator.
Powerset()
Default constructor: builds the bottom of the powerset constraint system (i.e., the empty powerset)...
void m_swap(Powerset &y)
Swaps *this with y.
void least_upper_bound_assign(const Powerset &y)
Assigns to *this the least upper bound of *this and y.
iterator end()
Returns the past-the-end iterator.
A const_iterator on a sequence of read-only objects.
void meet_assign(const Powerset &y)
Assigns to *this the meet of *this and y.
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.
Definition: version.hh:61
void add_disjunct(const D &d)
Adds to *this the disjunct d.
bool empty() const
Returns true if and only if there are no disjuncts in *this.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
bool is_top() const
Returns true if and only if *this is the top element of the powerset constraint system (i...
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the disjuncts.
std::reverse_iterator< iterator > reverse_iterator
The reverse iterator type built from Powerset::iterator.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
An iterator on a sequence of read-only objects.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
bool upper_bound_assign_if_exact(const Powerset &y)
Assigns to *this the least upper bound of *this and y and returns true.
Powerset & operator=(const Powerset &y)
The assignment operator.
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 drop_disjuncts(iterator first, iterator last)
Drops all the disjuncts from first to last (excluded).
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...