PPL  1.2
Ask_Tell_defs.hh
Go to the documentation of this file.
1 /* Ask_Tell 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_Ask_Tell_defs_hh
25 #define PPL_Ask_Tell_defs_hh
26 
27 #include "Ask_Tell_types.hh"
29 #include "globals_types.hh"
30 #include <iosfwd>
31 #include <list>
32 
33 namespace Parma_Polyhedra_Library {
34 
36 
37 template <typename D>
38 void swap(Ask_Tell<D>& x, Ask_Tell<D>& y);
39 
41 
42 template <typename D>
43 bool
44 operator==(const Ask_Tell<D>& x, const Ask_Tell<D>& y);
45 
47 
48 template <typename D>
49 bool
50 operator!=(const Ask_Tell<D>& x, const Ask_Tell<D>& y);
51 
52 namespace IO_Operators {
53 
55 
56 template <typename D>
57 std::ostream&
58 operator<<(std::ostream&, const Ask_Tell<D>&);
59 
60 } // namespace IO_Operators
61 
62 } // namespace Parma_Polyhedra_Library
63 
65 
66 template <typename D>
68 public:
70  Ask_Tell_Pair(const D& ask, const D& tell);
71 
73  const D& ask() const;
74 
76  D& ask();
77 
79  const D& tell() const;
80 
82  D& tell();
83 
90  bool definitely_entails(const Ask_Tell_Pair& y) const;
91 
92 private:
94  D a;
95 
97  D t;
98 };
99 
101 
105 template <typename D>
107 public:
109 
110 
115  Ask_Tell();
116 
118  Ask_Tell(const Ask_Tell& y);
119 
124  explicit Ask_Tell(const Ask_Tell_Pair<D>& p);
125 
131  Ask_Tell(const D& ask, const D& tell);
132 
134  ~Ask_Tell();
135 
137 
139 
140 
147  bool definitely_entails(const Ask_Tell& y) const;
148 
154  bool is_top() const;
155 
161  bool is_bottom() const;
162 
168 
174 
181  int32_t hash_code() const;
182 
184  bool OK() const;
185 
187 
188 protected:
191 
193 
197  typedef std::list<Ask_Tell_Pair<D> > Sequence;
198 
200  typedef typename Sequence::iterator Sequence_iterator;
201 
203  typedef typename Sequence::const_iterator Sequence_const_iterator;
204 
206  Sequence sequence;
207 
209  mutable bool normalized;
210 
211 public:
212  // Sequence manipulation types, accessors and modifiers
213  typedef typename Sequence::size_type size_type;
214  typedef typename Sequence::value_type value_type;
215 
227 
230 
232  typedef std::reverse_iterator<iterator> reverse_iterator;
233 
235  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
236 
238 
239 
247  void normalize() const;
248 
250  size_type size() const;
251 
253  bool empty() const;
254 
259  iterator begin();
260 
262  iterator end();
263 
268  const_iterator begin() const;
269 
271  const_iterator end() const;
272 
277  reverse_iterator rbegin();
278 
280  reverse_iterator rend();
281 
287  const_reverse_iterator rbegin() const;
288 
290  const_reverse_iterator rend() const;
291 
294 
296  Ask_Tell& add_pair(const D& ask, const D& tell);
297 
302  iterator drop_pair(iterator position);
303 
305  void drop_pairs(iterator first, iterator last);
306 
308  void clear();
309 
311 
313 
314 
319  Ask_Tell& operator=(const Ask_Tell& y);
320 
322  void m_swap(Ask_Tell& y);
323 
325  void upper_bound_assign(const Ask_Tell& y);
326 
328  void meet_assign(const Ask_Tell& y);
329 
331 
332 protected:
334  bool is_normalized() const;
335 
336  void pair_insert(const D& a, const D& t);
337  void pair_insert_good(const D& a, const D& t);
338 
339  /*
340  Postcondition:
341  the map is well formed and there are no two pairs x and y such that
342  x.ASK.definitely_entails(y.ASK) && y.TELL.definitely_entails(x.TELL).
343  */
344  bool reduce();
345 
346  // Preconditions:
347  //
348  // the map is well formed and the postcondition of reduce() is satisfied.
349  //
350  // Postconditions:
351  //
352  // the map is well formed, the postcondition of reduce() is satisfied,
353  // and...
354  //
355  bool deduce();
356 
357  bool absorb();
358 
359  void deabsorb() const;
360 
365  bool check_normalized() const;
366 
367 protected:
368  bool probe(const D& tellv, const D& askv) const;
369 };
370 
371 #include "Ask_Tell_inlines.hh"
372 #include "Ask_Tell_templates.hh"
373 
374 #endif // !defined(PPL_Ask_Tell_defs_hh)
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
bool probe(const D &tellv, const D &askv) const
void normalize() const
Normalizes the pairs in *this.
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
void swap(CO_Tree &x, CO_Tree &y)
const D & ask() const
Const accessor to the ask component.
bool definitely_entails(const Ask_Tell_Pair &y) const
Returns true if *this definitely entails y. Returns false if *this may not entail y (i...
Ask_Tell & operator=(const Ask_Tell &y)
The assignment operator. (*this and y can be dimension-incompatible.)
Ask_Tell()
Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system)...
iterator_to_const< Sequence > iterator
Alias for a read-only bidirectional iterator on the pairs an Ask_Tell object.
void drop_pairs(iterator first, iterator last)
Drops all the pairs from first to last (excluded).
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
bool empty() const
Returns true if and only if there are no pairs in *this.
bool is_bottom() const
Returns true if and only if *this is the bottom element of the ask-and-tell constraint system (i...
void m_swap(Ask_Tell &y)
Swaps *this with y.
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the pairs.
size_type size() const
Returns the number of pairs.
iterator end()
Returns the past-the-end iterator.
Ask_Tell_Pair(const D &ask, const D &tell)
Pair constructor.
std::reverse_iterator< iterator > reverse_iterator
The reverse iterator type built from Powerset::iterator.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
std::reverse_iterator< const_iterator > const_reverse_iterator
The reverse iterator type built from Powerset::const_iterator.
Sequence sequence
The sequence container holding the pairs/.
reverse_iterator rbegin()
Returns a reverse_iterator pointing to the last pair, if *this is not empty; otherwise, returns the before-the-start reverse_iterator.
bool is_normalized() const
Returns true if and only if *this is normalized.
std::list< Ask_Tell_Pair< D > > Sequence
An ask-tell agent is implemented as a sequence of ask-tell pairs.
void upper_bound_assign(const Ask_Tell &y)
Assigns to *this an upper bound of *this and y.
bool definitely_entails(const Ask_Tell &y) const
Returns true if *this definitely entails y. Returns false if *this may not entail y (i...
void meet_assign(const Ask_Tell &y)
Assigns to *this the meet of *this and y.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
bool is_top() const
Returns true if and only if *this is the top element of the ask-and-tell constraint system (i...
A const_iterator on a sequence of read-only objects.
Ask_Tell & add_pair(const Ask_Tell_Pair< D > &p)
Adds to *this the pair p.
The entire library is confined to this namespace.
Definition: version.hh:61
Ask_Tell_Pair< D > Pair
An ask-tell agent is composed of pairs.
Sequence::const_iterator Sequence_const_iterator
Alias for the low-level const_iterator on the pairs.
const D & tell() const
Const accessor to the ask component.
void pair_insert_good(const D &a, const D &t)
bool normalized
If true, *this is normalized.
bool check_normalized() const
Does the hard work of checking whether *this is normalized and returns true if and only if it is...
iterator drop_pair(iterator position)
Drops the pair in *this pointed to by position, returning an iterator to the pair following position...
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
A pair of ask and tell descriptions.
An iterator on a sequence of read-only objects.
reverse_iterator rend()
Returns the before-the-start reverse_iterator.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void pair_insert(const D &a, const D &t)
The ask and tell construction on a base-level domain.
void clear()
Drops all the pairs, making *this an empty powerset.
bool OK() const
Checks if all the invariants are satisfied.