PPL  1.2
Parma_Polyhedra_Library::Ask_Tell< D > Class Template Reference

The ask and tell construction on a base-level domain. More...

#include <Ask_Tell_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::Ask_Tell< D >:

Public Types

typedef Sequence::size_type size_type
 
typedef Sequence::value_type value_type
 
typedef iterator_to_const< Sequenceiterator
 Alias for a read-only bidirectional iterator on the pairs an Ask_Tell object. More...
 
typedef const_iterator_to_const< Sequenceconst_iterator
 A bidirectional const_iterator on the disjuncts of a Powerset element. More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 The reverse iterator type built from Powerset::iterator. More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 The reverse iterator type built from Powerset::const_iterator. More...
 

Public Member Functions

Constructors and Destructor
 Ask_Tell ()
 Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system). More...
 
 Ask_Tell (const Ask_Tell &y)
 Copy constructor. More...
 
 Ask_Tell (const Ask_Tell_Pair< D > &p)
 If p is not top, builds an ask-and-tell system containing only p. Builds the empty system otherwise. More...
 
 Ask_Tell (const D &ask, const D &tell)
 If ask and tell do not constitute a top pair, builds an ask-and-tell system containing only that pair. Builds the empty system otherwise. More...
 
 ~Ask_Tell ()
 Destructor. More...
 
Member Functions that Do Not Modify the Ask_Tell Object
bool definitely_entails (const Ask_Tell &y) const
 Returns true if *this definitely entails y. Returns false if *this may not entail y (i.e., if *this does not entail y or if entailment could not be decided). More...
 
bool is_top () const
 Returns true if and only if *this is the top element of the ask-and-tell constraint system (i.e., it represents the universe). More...
 
bool is_bottom () const
 Returns true if and only if *this is the bottom element of the ask-and-tell constraint system (i.e., it represents the empty set). More...
 
memory_size_type total_memory_in_bytes () const
 Returns a lower bound to the total size in bytes of the memory occupied by *this. More...
 
memory_size_type external_memory_in_bytes () const
 Returns a lower bound to the size in bytes of the memory managed by *this. More...
 
int32_t hash_code () const
 Returns a 32-bit hash code for *this. More...
 
bool OK () const
 Checks if all the invariants are satisfied. More...
 
Member Functions for the Direct Manipulation of Pairs
void normalize () const
 Normalizes the pairs in *this. More...
 
size_type size () const
 Returns the number of pairs. More...
 
bool empty () const
 Returns true if and only if there are no pairs in *this. More...
 
iterator begin ()
 Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-the-end iterator. More...
 
iterator end ()
 Returns the past-the-end iterator. More...
 
const_iterator begin () const
 Returns a const_iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-the-end const_iterator. More...
 
const_iterator end () const
 Returns the past-the-end const_iterator. More...
 
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. More...
 
reverse_iterator rend ()
 Returns the before-the-start reverse_iterator. More...
 
const_reverse_iterator rbegin () const
 Returns a const_reverse_iterator pointing to the last pair, if *this is not empty; otherwise, returns the before-the-start const_reverse_iterator. More...
 
const_reverse_iterator rend () const
 Returns the before-the-start const_reverse_iterator. More...
 
Ask_Telladd_pair (const Ask_Tell_Pair< D > &p)
 Adds to *this the pair p. More...
 
Ask_Telladd_pair (const D &ask, const D &tell)
 Adds to *this the pair constituted by ask and tell. More...
 
iterator drop_pair (iterator position)
 Drops the pair in *this pointed to by position, returning an iterator to the pair following position. More...
 
void drop_pairs (iterator first, iterator last)
 Drops all the pairs from first to last (excluded). More...
 
void clear ()
 Drops all the pairs, making *this an empty powerset. More...
 
Member Functions that May Modify the Ask_Tell Object
Ask_Telloperator= (const Ask_Tell &y)
 The assignment operator. (*this and y can be dimension-incompatible.) More...
 
void m_swap (Ask_Tell &y)
 Swaps *this with y. More...
 
void upper_bound_assign (const Ask_Tell &y)
 Assigns to *this an upper bound of *this and y. More...
 
void meet_assign (const Ask_Tell &y)
 Assigns to *this the meet of *this and y. More...
 

Protected Types

typedef Ask_Tell_Pair< D > Pair
 An ask-tell agent is composed of pairs. More...
 
typedef std::list< Ask_Tell_Pair< D > > Sequence
 An ask-tell agent is implemented as a sequence of ask-tell pairs. More...
 
typedef Sequence::iterator Sequence_iterator
 Alias for the low-level iterator on the pairs. More...
 
typedef Sequence::const_iterator Sequence_const_iterator
 Alias for the low-level const_iterator on the pairs. More...
 

Protected Member Functions

bool is_normalized () const
 Returns true if and only if *this is normalized. More...
 
void pair_insert (const D &a, const D &t)
 
void pair_insert_good (const D &a, const D &t)
 
bool reduce ()
 
bool deduce ()
 
bool absorb ()
 
void deabsorb () const
 
bool check_normalized () const
 Does the hard work of checking whether *this is normalized and returns true if and only if it is. More...
 
bool probe (const D &tellv, const D &askv) const
 

Protected Attributes

Sequence sequence
 The sequence container holding the pairs/. More...
 
bool normalized
 If true, *this is normalized. More...
 

Related Functions

(Note that these are not member functions.)

template<typename D >
void swap (Ask_Tell< D > &x, Ask_Tell< D > &y)
 Swaps x with y. More...
 
template<typename D >
bool operator== (const Ask_Tell< D > &x, const Ask_Tell< D > &y)
 Returns true if and only if x and y are equivalent. More...
 
template<typename D >
bool operator!= (const Ask_Tell< D > &x, const Ask_Tell< D > &y)
 Returns true if and only if x and y are not equivalent. More...
 
template<typename D >
std::ostream & operator<< (std::ostream &, const Ask_Tell< D > &)
 Output operator. More...
 
template<typename D >
bool operator== (const Ask_Tell< D > &x, const Ask_Tell< D > &y)
 
template<typename D >
bool operator!= (const Ask_Tell< D > &x, const Ask_Tell< D > &y)
 
template<typename D >
void swap (Ask_Tell< D > &x, Ask_Tell< D > &y)
 

Detailed Description

template<typename D>
class Parma_Polyhedra_Library::Ask_Tell< D >

The ask and tell construction on a base-level domain.

This class offers a generic implementation of ask-and-tell constraint systems as defined in [Bag98].

Definition at line 106 of file Ask_Tell_defs.hh.

Member Typedef Documentation

A bidirectional const_iterator on the disjuncts of a Powerset element.

Definition at line 229 of file Ask_Tell_defs.hh.

template<typename D>
typedef std::reverse_iterator<const_iterator> Parma_Polyhedra_Library::Ask_Tell< D >::const_reverse_iterator

The reverse iterator type built from Powerset::const_iterator.

Definition at line 235 of file Ask_Tell_defs.hh.

Alias for a read-only bidirectional iterator on the pairs an Ask_Tell object.

By using this iterator type, the pairs cannot be overwritten, but they can be removed using methods drop_pair(iterator position) and drop_pairs(iterator first, iterator last), while still ensuring a correct handling of normalization.

Definition at line 226 of file Ask_Tell_defs.hh.

template<typename D>
typedef Ask_Tell_Pair<D> Parma_Polyhedra_Library::Ask_Tell< D >::Pair
protected

An ask-tell agent is composed of pairs.

Definition at line 190 of file Ask_Tell_defs.hh.

template<typename D>
typedef std::reverse_iterator<iterator> Parma_Polyhedra_Library::Ask_Tell< D >::reverse_iterator

The reverse iterator type built from Powerset::iterator.

Definition at line 232 of file Ask_Tell_defs.hh.

template<typename D>
typedef std::list<Ask_Tell_Pair<D> > Parma_Polyhedra_Library::Ask_Tell< D >::Sequence
protected

An ask-tell agent is implemented as a sequence of ask-tell pairs.

The particular sequence employed must support efficient deletion in any position and efficient back insertion.

Definition at line 197 of file Ask_Tell_defs.hh.

template<typename D>
typedef Sequence::const_iterator Parma_Polyhedra_Library::Ask_Tell< D >::Sequence_const_iterator
protected

Alias for the low-level const_iterator on the pairs.

Definition at line 203 of file Ask_Tell_defs.hh.

template<typename D>
typedef Sequence::iterator Parma_Polyhedra_Library::Ask_Tell< D >::Sequence_iterator
protected

Alias for the low-level iterator on the pairs.

Definition at line 200 of file Ask_Tell_defs.hh.

template<typename D>
typedef Sequence::size_type Parma_Polyhedra_Library::Ask_Tell< D >::size_type

Definition at line 213 of file Ask_Tell_defs.hh.

template<typename D>
typedef Sequence::value_type Parma_Polyhedra_Library::Ask_Tell< D >::value_type

Definition at line 214 of file Ask_Tell_defs.hh.

Constructor & Destructor Documentation

template<typename D >
Parma_Polyhedra_Library::Ask_Tell< D >::Ask_Tell ( )

Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system).

Definition at line 90 of file Ask_Tell_inlines.hh.

91  : sequence(), normalized(true) {
92 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
template<typename D >
Parma_Polyhedra_Library::Ask_Tell< D >::Ask_Tell ( const Ask_Tell< D > &  y)

Copy constructor.

Definition at line 95 of file Ask_Tell_inlines.hh.

96  : sequence(y.sequence), normalized(y.normalized) {
97 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
template<typename D>
Parma_Polyhedra_Library::Ask_Tell< D >::Ask_Tell ( const Ask_Tell_Pair< D > &  p)
explicit

If p is not top, builds an ask-and-tell system containing only p. Builds the empty system otherwise.

template<typename D>
Parma_Polyhedra_Library::Ask_Tell< D >::Ask_Tell ( const D &  ask,
const D &  tell 
)

If ask and tell do not constitute a top pair, builds an ask-and-tell system containing only that pair. Builds the empty system otherwise.

Definition at line 100 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::pair_insert().

101  : sequence(), normalized(true) {
102  if (!tell.is_top()) {
103  pair_insert(ask, tell);
104  }
105 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
void pair_insert(const D &a, const D &t)
template<typename D >
Parma_Polyhedra_Library::Ask_Tell< D >::~Ask_Tell ( )
inline

Destructor.

Definition at line 109 of file Ask_Tell_inlines.hh.

109  {
110 }

Member Function Documentation

template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::absorb ( )
protected

Definition at line 106 of file Ask_Tell_templates.hh.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::normalize().

106  {
107  bool changed = false;
108  for (Sequence_iterator x_begin = sequence.begin(),
109  x_end = sequence.end(), xi = x_begin; xi != x_end; ) {
110  D& xi_ask = xi->ask();
111  D& xi_tell = xi->tell();
112  // We may strengthen the ask component of the pair referenced by `xi'.
113  // If we do it, the pair may become useless (i.e., with the ask
114  // component entailing the tell component) and thus to be
115  // discarded.
116  bool must_check_xi_pair = false;
117  bool ask_changed;
118  do {
119  ask_changed = false;
120  for (Sequence_iterator yi = x_begin; yi != x_end; ++yi) {
121  if (xi != yi) {
122  D& yi_ask = yi->ask();
123  D& yi_tell = yi->tell();
124  if (xi_ask.definitely_entails(yi_ask)
125  && !xi_ask.definitely_entails(yi_tell)) {
126  xi_ask.meet_assign(yi_tell);
127  must_check_xi_pair = true;
128  ask_changed = true;
129  }
130  }
131  }
132  } while (ask_changed);
133  if (must_check_xi_pair) {
134  changed = true;
135  if (xi_ask.definitely_entails(xi_tell)) {
136  xi = sequence.erase(xi);
137  x_begin = sequence.begin();
138  x_end = sequence.end();
139  }
140  else {
141  ++xi;
142  }
143  }
144  else {
145  ++xi;
146  }
147  }
148  if (changed) {
149  (void) reduce();
150  }
151  PPL_ASSERT_HEAVY(OK());
152  return changed;
153 }
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the pairs.
Sequence sequence
The sequence container holding the pairs/.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D>
Ask_Tell& Parma_Polyhedra_Library::Ask_Tell< D >::add_pair ( const Ask_Tell_Pair< D > &  p)

Adds to *this the pair p.

template<typename D>
Ask_Tell< D > & Parma_Polyhedra_Library::Ask_Tell< D >::add_pair ( const D &  ask,
const D &  tell 
)

Adds to *this the pair constituted by ask and tell.

Definition at line 245 of file Ask_Tell_inlines.hh.

245  {
246  if (!ask.definitely_entails(tell)) {
247  pair_insert(ask, tell);
248  }
249  PPL_ASSERT_HEAVY(OK());
250  return *this;
251 }
void pair_insert(const D &a, const D &t)
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
Ask_Tell< D >::const_iterator Parma_Polyhedra_Library::Ask_Tell< D >::begin ( ) const

Returns a const_iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-the-end const_iterator.

Definition at line 135 of file Ask_Tell_inlines.hh.

135  {
136  return sequence.begin();
137 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::check_normalized ( ) const
protected

Does the hard work of checking whether *this is normalized and returns true if and only if it is.

Definition at line 33 of file Ask_Tell_templates.hh.

33  {
34  for (const_iterator x_begin = begin(),
35  x_end = end(), xi = x_begin; xi != x_end; ++xi)
36  for (const_iterator yi = x_begin; yi != x_end; ++yi)
37  if (xi != yi) {
38  if (xi->tell().definitely_entails(yi->tell())) {
39  if (yi->ask().definitely_entails(xi->ask())) {
40  return false;
41  }
42  }
43  else if (xi->tell().definitely_entails(yi->ask())) {
44  return false;
45  }
46  if (xi->ask().definitely_entails(yi->ask())
47  && !xi->ask().definitely_entails(yi->tell())) {
48  return false;
49  }
50  }
51  return true;
52 }
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
iterator end()
Returns the past-the-end iterator.
template<typename D>
void Parma_Polyhedra_Library::Ask_Tell< D >::clear ( )

Drops all the pairs, making *this an empty powerset.

template<typename D >
void Parma_Polyhedra_Library::Ask_Tell< D >::deabsorb ( ) const
protected

Definition at line 157 of file Ask_Tell_templates.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::deduce(), Parma_Polyhedra_Library::Ask_Tell< D >::reduce(), and Parma_Polyhedra_Library::Ask_Tell< D >::sequence.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::upper_bound_assign().

157  {
158  if (D::has_nontrivial_weakening()) {
159  Sequence new_sequence;
160  for (Sequence_const_iterator x_begin = sequence.begin(),
161  x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi)
162  for (Sequence_const_iterator yi = x_begin; yi != x_end; ++yi) {
163  if (xi != yi) {
164  const D& xi_ask = xi->ask();
165  const D& yi_ask = yi->ask();
166  if (xi_ask.definitely_entails(yi_ask)) {
167  D new_ask = xi_ask;
168  new_ask.weakening_assign(yi->tell());
169  new_ask.meet_assign(yi_ask);
170  if (!new_ask.definitely_entails(xi_ask)) {
171  new_sequence.push_back(Pair(new_ask, xi->tell()));
172  }
173  }
174  }
175  }
176  if (!new_sequence.empty()) {
177  Ask_Tell& x = const_cast<Ask_Tell&>(*this);
178  std::copy(new_sequence.begin(), new_sequence.end(),
179  back_inserter(x.sequence));
180  x.reduce();
181  x.deduce();
182  normalized = false;
183  }
184  }
185  else if (!normalized) {
186  Ask_Tell& x = const_cast<Ask_Tell&>(*this);
187  x.reduce();
188  x.deduce();
189  }
190  PPL_ASSERT_HEAVY(OK());
191 }
Ask_Tell()
Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system)...
Sequence sequence
The sequence container holding the pairs/.
std::list< Ask_Tell_Pair< D > > Sequence
An ask-tell agent is implemented as a sequence of ask-tell pairs.
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.
bool normalized
If true, *this is normalized.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::deduce ( )
protected

Definition at line 79 of file Ask_Tell_templates.hh.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::deabsorb(), and Parma_Polyhedra_Library::Ask_Tell< D >::normalize().

79  {
80  bool changed = false;
81  for (Sequence_iterator x_begin = sequence.begin(),
82  x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi) {
83  D& xi_tell = xi->tell();
84  bool tell_changed;
85  do {
86  tell_changed = false;
87  for (Sequence_iterator yi = x_begin; yi != x_end; ++yi) {
88  if (xi != yi
89  && xi_tell.definitely_entails(yi->ask())
90  && !xi_tell.definitely_entails(yi->tell())) {
91  xi_tell.meet_assign(yi->tell());
92  changed = tell_changed = true;
93  }
94  }
95  } while (tell_changed);
96  }
97  if (changed) {
98  (void) reduce();
99  }
100  PPL_ASSERT_HEAVY(OK());
101  return changed;
102 }
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the pairs.
Sequence sequence
The sequence container holding the pairs/.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::definitely_entails ( const Ask_Tell< D > &  y) const

Returns true if *this definitely entails y. Returns false if *this may not entail y (i.e., if *this does not entail y or if entailment could not be decided).

Definition at line 229 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::begin(), Parma_Polyhedra_Library::Ask_Tell< D >::end(), and Parma_Polyhedra_Library::Ask_Tell< D >::normalize().

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::operator==().

229  {
230  const Ask_Tell<D>& x = *this;
231  x.normalize();
232  y.normalize();
233  bool found = true;
234  for (const_iterator x_begin = x.begin(), x_end = x.end(), y_end = y.end(),
235  yi = y.begin(); found && yi != y_end; ++yi) {
236  found = false;
237  for (const_iterator xi = x_begin; !found && xi != x_end; ++xi)
238  found = xi->definitely_entails(*yi);
239  }
240  return found;
241 }
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
template<typename D>
iterator Parma_Polyhedra_Library::Ask_Tell< D >::drop_pair ( iterator  position)

Drops the pair in *this pointed to by position, returning an iterator to the pair following position.

template<typename D>
void Parma_Polyhedra_Library::Ask_Tell< D >::drop_pairs ( iterator  first,
iterator  last 
)

Drops all the pairs from first to last (excluded).

template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::empty ( ) const

Returns true if and only if there are no pairs in *this.

Definition at line 286 of file Ask_Tell_inlines.hh.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::meet_assign().

286  {
287  return sequence.empty();
288 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
Ask_Tell< D >::const_iterator Parma_Polyhedra_Library::Ask_Tell< D >::end ( ) const

Returns the past-the-end const_iterator.

Definition at line 147 of file Ask_Tell_inlines.hh.

147  {
148  return sequence.end();
149 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D>
memory_size_type Parma_Polyhedra_Library::Ask_Tell< D >::external_memory_in_bytes ( ) const

Returns a lower bound to the size in bytes of the memory managed by *this.

template<typename D>
int32_t Parma_Polyhedra_Library::Ask_Tell< D >::hash_code ( ) const

Returns a 32-bit hash code for *this.

If x and y are such that x == y, then x.hash_code() == y.hash_code().

template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::is_bottom ( ) const

Returns true if and only if *this is the bottom element of the ask-and-tell constraint system (i.e., it represents the empty set).

Definition at line 275 of file Ask_Tell_inlines.hh.

Referenced by Parma_Polyhedra_Library::Pointset_Ask_Tell< PSET >::map_space_dimensions().

275  {
276  // Must normalize for correctness.
277  const_iterator xi = begin();
278  const_iterator x_end = end();
279  return xi != x_end
280  && xi->ask().is_top() && xi->tell().is_bottom()
281  && ++xi == x_end;
282 }
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
iterator end()
Returns the past-the-end iterator.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::is_normalized ( ) const
protected

Returns true if and only if *this is normalized.

Definition at line 220 of file Ask_Tell_inlines.hh.

220  {
221  if (!normalized && check_normalized()) {
222  normalized = true;
223  }
224  return normalized;
225 }
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...
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::is_top ( ) const

Returns true if and only if *this is the top element of the ask-and-tell constraint system (i.e., it represents the universe).

Definition at line 269 of file Ask_Tell_inlines.hh.

269  {
270  return sequence.empty();
271 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
void Parma_Polyhedra_Library::Ask_Tell< D >::m_swap ( Ask_Tell< D > &  y)
inline

Swaps *this with y.

Definition at line 122 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::normalized, Parma_Polyhedra_Library::Ask_Tell< D >::sequence, and Parma_Polyhedra_Library::swap().

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::swap().

122  {
123  swap(sequence, y.sequence);
124  swap(normalized, y.normalized);
125 }
void swap(Ask_Tell< D > &x, Ask_Tell< D > &y)
Swaps x with y.
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
template<typename D >
void Parma_Polyhedra_Library::Ask_Tell< D >::meet_assign ( const Ask_Tell< D > &  y)

Assigns to *this the meet of *this and y.

Definition at line 292 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::begin(), Parma_Polyhedra_Library::Ask_Tell< D >::empty(), and Parma_Polyhedra_Library::Ask_Tell< D >::end().

292  {
293  if (!y.empty()) {
294  std::copy(y.begin(), y.end(), back_inserter(sequence));
295  normalized = false;
296  }
297  PPL_ASSERT_HEAVY(OK());
298 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
void Parma_Polyhedra_Library::Ask_Tell< D >::normalize ( ) const

Normalizes the pairs in *this.

This method is declared const because, even though normalization may change the syntactic representation of *this, its semantics will be unchanged.

Definition at line 204 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::absorb(), Parma_Polyhedra_Library::Ask_Tell< D >::deduce(), and Parma_Polyhedra_Library::Ask_Tell< D >::reduce().

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::definitely_entails().

204  {
205  if (normalized) {
206  return;
207  }
208 
209  Ask_Tell& x = const_cast<Ask_Tell&>(*this);
210  x.reduce();
211  x.deduce();
212  x.absorb();
213  normalized = true;
214 
215  PPL_ASSERT_HEAVY(OK());
216 }
Ask_Tell()
Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system)...
bool normalized
If true, *this is normalized.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::OK ( ) const

Checks if all the invariants are satisfied.

Definition at line 218 of file Ask_Tell_templates.hh.

References Parma_Polyhedra_Library::Ask_Tell_Pair< D >::ask(), and Parma_Polyhedra_Library::Ask_Tell_Pair< D >::tell().

218  {
219  for (typename Ask_Tell<D>::const_iterator xi = begin(),
220  x_end = end(); xi != x_end; ++xi) {
221  const Ask_Tell_Pair<D>& p = *xi;
222  if (!p.ask().OK()) {
223  return false;
224  }
225  if (!p.tell().OK()) {
226  return false;
227  }
228  if (p.ask().definitely_entails(p.tell())) {
229 #ifndef NDEBUG
230  using namespace IO_Operators;
231  std::cerr << "Illegal agent in ask-and-tell: "
232  << p.ask() << " -> " << p.tell()
233  << std::endl;
234 #endif
235  return false;
236  }
237  }
238  if (normalized && !check_normalized()) {
239 #ifndef NDEBUG
240  std::cerr << "Ask_Tell claims to be normalized, but it is not!"
241  << std::endl;
242 #endif
243  return false;
244  }
245  return true;
246 }
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
iterator end()
Returns the past-the-end iterator.
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...
template<typename D >
Ask_Tell< D > & Parma_Polyhedra_Library::Ask_Tell< D >::operator= ( const Ask_Tell< D > &  y)

The assignment operator. (*this and y can be dimension-incompatible.)

Definition at line 114 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::normalized, and Parma_Polyhedra_Library::Ask_Tell< D >::sequence.

114  {
115  sequence = y.sequence;
116  normalized = y.normalized;
117  return *this;
118 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
template<typename D>
void Parma_Polyhedra_Library::Ask_Tell< D >::pair_insert ( const D &  a,
const D &  t 
)
protected

Definition at line 191 of file Ask_Tell_inlines.hh.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::Ask_Tell(), and Parma_Polyhedra_Library::Ask_Tell< D >::upper_bound_assign().

191  {
192  if (tell.definitely_entails(ask)) {
193  pair_insert_good(ask, tell);
194  }
195  else {
196  D new_tell = tell;
197  new_tell.meet_assign(ask);
198  pair_insert_good(ask, new_tell);
199  }
200 }
void pair_insert_good(const D &a, const D &t)
template<typename D>
void Parma_Polyhedra_Library::Ask_Tell< D >::pair_insert_good ( const D &  a,
const D &  t 
)
protected

Definition at line 183 of file Ask_Tell_inlines.hh.

183  {
184  PPL_ASSERT_HEAVY(!ask.definitely_entails(tell));
185  sequence.push_back(Ask_Tell_Pair<D>(ask, tell));
186  normalized = false;
187 }
Sequence sequence
The sequence container holding the pairs/.
bool normalized
If true, *this is normalized.
template<typename D>
bool Parma_Polyhedra_Library::Ask_Tell< D >::probe ( const D &  tellv,
const D &  askv 
) const
protected

Definition at line 304 of file Ask_Tell_inlines.hh.

304  {
305  const_iterator yi;
306  bool tell_changed;
307 
308  D xtell(tell);
309  tell_changed = true;
310  while (tell_changed) {
311  tell_changed = false;
312  for (yi = begin(); yi != end(); ++yi) {
313  if (xtell.definitely_entails(yi->ask())
314  && !xtell.definitely_entails(yi->tell())) {
315  xtell.meet_assign(yi->tell());
316  if (xtell.definitely_entails(ask)) {
317  return true;
318  }
319  tell_changed = true;
320  }
321  }
322  }
323  return false;
324 }
iterator begin()
Returns an iterator pointing to the first pair, if *this is not empty; otherwise, returns the past-th...
const_iterator_to_const< Sequence > const_iterator
A bidirectional const_iterator on the disjuncts of a Powerset element.
iterator end()
Returns the past-the-end iterator.
template<typename D >
Ask_Tell< D >::reverse_iterator Parma_Polyhedra_Library::Ask_Tell< D >::rbegin ( )

Returns a reverse_iterator pointing to the last pair, if *this is not empty; otherwise, returns the before-the-start reverse_iterator.

Definition at line 153 of file Ask_Tell_inlines.hh.

153  {
154  return sequence.rbegin();
155 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
Ask_Tell< D >::const_reverse_iterator Parma_Polyhedra_Library::Ask_Tell< D >::rbegin ( ) const

Returns a const_reverse_iterator pointing to the last pair, if *this is not empty; otherwise, returns the before-the-start const_reverse_iterator.

Definition at line 159 of file Ask_Tell_inlines.hh.

159  {
160  return sequence.rbegin();
161 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
bool Parma_Polyhedra_Library::Ask_Tell< D >::reduce ( )
protected

Definition at line 56 of file Ask_Tell_templates.hh.

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::deabsorb(), and Parma_Polyhedra_Library::Ask_Tell< D >::normalize().

56  {
57  bool changed = false;
58  for (Sequence_iterator x_begin = sequence.begin(),
59  x_end = sequence.end(), xi = x_begin; xi != x_end; ++xi)
60  for (Sequence_iterator yi = x_begin; yi != x_end; ) {
61  if (xi != yi
62  && yi->ask().definitely_entails(xi->ask())
63  && xi->tell().definitely_entails(yi->tell())) {
64  yi = sequence.erase(yi);
65  x_begin = sequence.begin();
66  x_end = sequence.end();
67  changed = true;
68  }
69  else {
70  ++yi;
71  }
72  }
73  PPL_ASSERT_HEAVY(OK());
74  return changed;
75 }
Sequence::iterator Sequence_iterator
Alias for the low-level iterator on the pairs.
Sequence sequence
The sequence container holding the pairs/.
bool OK() const
Checks if all the invariants are satisfied.
template<typename D >
Ask_Tell< D >::reverse_iterator Parma_Polyhedra_Library::Ask_Tell< D >::rend ( )

Returns the before-the-start reverse_iterator.

Definition at line 165 of file Ask_Tell_inlines.hh.

165  {
166  return sequence.rend();
167 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
Ask_Tell< D >::const_reverse_iterator Parma_Polyhedra_Library::Ask_Tell< D >::rend ( ) const

Returns the before-the-start const_reverse_iterator.

Definition at line 171 of file Ask_Tell_inlines.hh.

171  {
172  return sequence.rend();
173 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D >
Ask_Tell< D >::size_type Parma_Polyhedra_Library::Ask_Tell< D >::size ( ) const

Returns the number of pairs.

Definition at line 177 of file Ask_Tell_inlines.hh.

Referenced by Parma_Polyhedra_Library::Pointset_Ask_Tell< PSET >::ascii_dump().

177  {
178  return sequence.size();
179 }
Sequence sequence
The sequence container holding the pairs/.
template<typename D>
memory_size_type Parma_Polyhedra_Library::Ask_Tell< D >::total_memory_in_bytes ( ) const

Returns a lower bound to the total size in bytes of the memory occupied by *this.

template<typename D >
void Parma_Polyhedra_Library::Ask_Tell< D >::upper_bound_assign ( const Ask_Tell< D > &  y)

Assigns to *this an upper bound of *this and y.

Definition at line 195 of file Ask_Tell_templates.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::begin(), Parma_Polyhedra_Library::Ask_Tell< D >::deabsorb(), Parma_Polyhedra_Library::Ask_Tell< D >::end(), Parma_Polyhedra_Library::Ask_Tell< D >::pair_insert(), and Parma_Polyhedra_Library::Ask_Tell< D >::upper_bound_assign().

Referenced by Parma_Polyhedra_Library::Ask_Tell< D >::upper_bound_assign().

195  {
196  const Ask_Tell& x = *this;
197  x.deabsorb();
198  y.deabsorb();
199  Ask_Tell<D> z;
200  for (typename Ask_Tell<D>::const_iterator xi = x.begin(),
201  x_end = x.end(); xi != x_end; ++xi)
202  for (typename Ask_Tell<D>::const_iterator yi = y.begin(),
203  y_end = y.end(); yi != y_end; ++yi) {
204  D tell = xi->tell();
205  tell.upper_bound_assign(yi->tell());
206  D ask = xi->ask();
207  ask.meet_assign(yi->ask());
208  if (!ask.definitely_entails(tell)) {
209  z.pair_insert(ask, tell);
210  }
211  }
212  *this = z;
213  PPL_ASSERT_HEAVY(OK());
214 }
Ask_Tell()
Default constructor: builds the top of the ask-and-tell constraint system (i.e., the empty system)...
bool OK() const
Checks if all the invariants are satisfied.

Friends And Related Function Documentation

template<typename D >
bool operator!= ( const Ask_Tell< D > &  x,
const Ask_Tell< D > &  y 
)
related

Returns true if and only if x and y are not equivalent.

template<typename D >
bool operator!= ( const Ask_Tell< D > &  x,
const Ask_Tell< D > &  y 
)
related

Definition at line 263 of file Ask_Tell_inlines.hh.

263  {
264  return !(x == y);
265 }
template<typename D >
std::ostream & operator<< ( std::ostream &  ,
const Ask_Tell< D > &   
)
related

Output operator.

Definition at line 252 of file Ask_Tell_templates.hh.

252  {
253  if (x.is_top()) {
254  s << "true";
255  }
256  else if (x.is_bottom()) {
257  s << "false";
258  }
259  else {
260  for (typename Ask_Tell<D>::const_iterator xi = x.begin(),
261  x_end = x.end(); xi != x_end; ++xi)
262  s << "(" << xi->ask() << " -> " << xi->tell() << ")";
263  }
264  return s;
265 }
template<typename D >
bool operator== ( const Ask_Tell< D > &  x,
const Ask_Tell< D > &  y 
)
related

Returns true if and only if x and y are equivalent.

template<typename D >
bool operator== ( const Ask_Tell< D > &  x,
const Ask_Tell< D > &  y 
)
related

Definition at line 256 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::definitely_entails().

256  {
257  return x.definitely_entails(y) && y.definitely_entails(x);
258 }
template<typename D >
void swap ( Ask_Tell< D > &  x,
Ask_Tell< D > &  y 
)
related

Swaps x with y.

template<typename D >
void swap ( Ask_Tell< D > &  x,
Ask_Tell< D > &  y 
)
related

Definition at line 329 of file Ask_Tell_inlines.hh.

References Parma_Polyhedra_Library::Ask_Tell< D >::m_swap().

329  {
330  x.m_swap(y);
331 }

Member Data Documentation


The documentation for this class was generated from the following files: