1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
/* Determinate class declaration.
Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
Copyright (C) 2010-2011 BUGSENG srl (http://bugseng.com)
This file is part of the Parma Polyhedra Library (PPL).
The PPL is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The PPL is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
For the most up-to-date information see the Parma Polyhedra Library
site: http://www.cs.unipr.it/ppl/ . */
#ifndef PPL_Determinate_defs_hh
#define PPL_Determinate_defs_hh
#include "Determinate.types.hh"
#include "Constraint_System.types.hh"
#include "Congruence_System.types.hh"
#include "Variable.defs.hh"
#include "globals.types.hh"
#include <iosfwd>
#include "assert.hh"
namespace Parma_Polyhedra_Library {
/*! \brief
Returns <CODE>true</CODE> if and only if \p x and \p y are the same
COW-wrapped pointset.
\relates Determinate
*/
template <typename PSET>
bool operator==(const Determinate<PSET>& x, const Determinate<PSET>& y);
/*! \brief
Returns <CODE>true</CODE> if and only if \p x and \p y are different
COW-wrapped pointsets.
\relates Determinate
*/
template <typename PSET>
bool operator!=(const Determinate<PSET>& x, const Determinate<PSET>& y);
namespace IO_Operators {
//! Output operator.
/*! \relates Parma_Polyhedra_Library::Determinate */
template <typename PSET>
std::ostream&
operator<<(std::ostream&, const Determinate<PSET>&);
} // namespace IO_Operators
} // namespace Parma_Polyhedra_Library
/*! \brief
A wrapper for PPL pointsets, providing them with a
<EM>determinate constraint system</EM> interface, as defined
in \ref Bag98 "[Bag98]".
The implementation uses a copy-on-write optimization, making the
class suitable for constructions, like the <EM>finite powerset</EM></A>
and <EM>ask-and-tell</EM> of \ref Bag98 "[Bag98]", that are likely
to perform many copies.
\ingroup PPL_CXX_interface
*/
template <typename PSET>
class Parma_Polyhedra_Library::Determinate {
public:
//! \name Constructors and Destructor
//@{
/*! \brief
Constructs a COW-wrapped object corresponding to the pointset \p p.
*/
Determinate(const PSET& p);
/*! \brief
Constructs a COW-wrapped object corresponding to the pointset
defined by \p cs.
*/
Determinate(const Constraint_System& cs);
/*! \brief
Constructs a COW-wrapped object corresponding to the pointset
defined by \p cgs.
*/
Determinate(const Congruence_System& cgs);
//! Copy constructor.
Determinate(const Determinate& y);
//! Destructor.
~Determinate();
//@} // Constructors and Destructor
//! \name Member Functions that Do Not Modify the Domain Element
//@{
//! Returns a const reference to the embedded pointset.
const PSET& pointset() const;
/*! \brief
Returns <CODE>true</CODE> if and only if \p *this embeds the universe
element \p PSET.
*/
bool is_top() const;
/*! \brief
Returns <CODE>true</CODE> if and only if \p *this embeds the empty
element of \p PSET.
*/
bool is_bottom() const;
//! Returns <CODE>true</CODE> if and only if \p *this entails \p y.
bool definitely_entails(const Determinate& y) const;
/*! \brief
Returns <CODE>true</CODE> if and only if \p *this and \p y
are definitely equivalent.
*/
bool is_definitely_equivalent_to(const Determinate& y) const;
/*! \brief
Returns a lower bound to the total size in bytes of the memory
occupied by \p *this.
*/
memory_size_type total_memory_in_bytes() const;
/*! \brief
Returns a lower bound to the size in bytes of the memory
managed by \p *this.
*/
memory_size_type external_memory_in_bytes() const;
/*!
Returns <CODE>true</CODE> if and only if this domain
has a nontrivial weakening operator.
*/
static bool has_nontrivial_weakening();
//! Checks if all the invariants are satisfied.
bool OK() const;
//@} // Member Functions that Do Not Modify the Domain Element
//! \name Member Functions that May Modify the Domain Element
//@{
//! Assigns to \p *this the upper bound of \p *this and \p y.
void upper_bound_assign(const Determinate& y);
//! Assigns to \p *this the meet of \p *this and \p y.
void meet_assign(const Determinate& y);
//! Assigns to \p *this the result of weakening \p *this with \p y.
void weakening_assign(const Determinate& y);
/*! \brief
Assigns to \p *this the \ref Concatenating_Polyhedra "concatenation"
of \p *this and \p y, taken in this order.
*/
void concatenate_assign(const Determinate& y);
//! Returns a reference to the embedded element.
PSET& pointset();
#ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
/*! \brief
On return from this method, the representation of \p *this
is not shared by different Determinate objects.
*/
#endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
void mutate();
//! Assignment operator.
Determinate& operator=(const Determinate& y);
//! Swaps \p *this with \p y.
void swap(Determinate& y);
//@} // Member Functions that May Modify the Domain Element
#ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
//! A function adapter for the Determinate class.
/*! \ingroup PPL_CXX_interface
It lifts a Binary_Operator_Assign function object, taking arguments
of type PSET, producing the corresponding function object taking
arguments of type Determinate<PSET>.
The template parameter Binary_Operator_Assign is supposed to
implement an <EM>apply and assign</EM> function, i.e., a function
having signature <CODE>void foo(PSET& x, const PSET& y)</CODE> that
applies an operator to \c x and \c y and assigns the result to \c x.
For instance, such a function object is obtained by
<CODE>std::mem_fun_ref(&C_Polyhedron::intersection_assign)</CODE>.
*/
#endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
template <typename Binary_Operator_Assign>
class Binary_Operator_Assign_Lifter {
public:
//! Explicit unary constructor.
explicit
Binary_Operator_Assign_Lifter(Binary_Operator_Assign op_assign);
//! Function-application operator.
void operator()(Determinate& x, const Determinate& y) const;
private:
//! The function object to be lifted.
Binary_Operator_Assign op_assign_;
};
#ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
/*! \brief
Helper function returning a Binary_Operator_Assign_Lifter object,
also allowing for the deduction of template arguments.
*/
#endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
template <typename Binary_Operator_Assign>
static Binary_Operator_Assign_Lifter<Binary_Operator_Assign>
lift_op_assign(Binary_Operator_Assign op_assign);
private:
//! The possibly shared representation of a Determinate object.
/*! \ingroup PPL_CXX_interface
By adopting the <EM>copy-on-write</EM> technique, a single
representation of the base-level object may be shared by more than
one object of the class Determinate.
*/
class Rep {
private:
/*! \brief
Count the number of references:
- 0: leaked, \p pset is non-const;
- 1: one reference, \p pset is non-const;
- > 1: more than one reference, \p pset is const.
*/
mutable unsigned long references;
//! Private and unimplemented: assignment not allowed.
Rep& operator=(const Rep& y);
//! Private and unimplemented: copies not allowed.
Rep(const Rep& y);
//! Private and unimplemented: default construction not allowed.
Rep();
public:
//! The possibly shared, embedded pointset.
PSET pset;
/*! \brief
Builds a new representation by creating a pointset
of the specified kind, in the specified vector space.
*/
Rep(dimension_type num_dimensions, Degenerate_Element kind);
//! Builds a new representation by copying the pointset \p p.
Rep(const PSET& p);
//! Builds a new representation by copying the constraints in \p cs.
Rep(const Constraint_System& cs);
//! Builds a new representation by copying the constraints in \p cgs.
Rep(const Congruence_System& cgs);
//! Destructor.
~Rep();
//! Registers a new reference.
void new_reference() const;
/*! \brief
Unregisters one reference; returns <CODE>true</CODE> if and only if
the representation has become unreferenced.
*/
bool del_reference() const;
//! True if and only if this representation is currently shared.
bool is_shared() const;
/*! \brief
Returns a lower bound to the total size in bytes of the memory
occupied by \p *this.
*/
memory_size_type total_memory_in_bytes() const;
/*! \brief
Returns a lower bound to the size in bytes of the memory
managed by \p *this.
*/
memory_size_type external_memory_in_bytes() const;
};
/*! \brief
A pointer to the possibly shared representation of
the base-level domain element.
*/
Rep* prep;
friend bool
operator==<PSET>(const Determinate<PSET>& x, const Determinate<PSET>& y);
friend bool
operator!=<PSET>(const Determinate<PSET>& x, const Determinate<PSET>& y);
};
namespace std {
//! Specializes <CODE>std::swap</CODE>.
/*! \relates Parma_Polyhedra_Library::Determinate */
template <typename PSET>
void swap(Parma_Polyhedra_Library::Determinate<PSET>& x,
Parma_Polyhedra_Library::Determinate<PSET>& y);
} // namespace std
#include "Determinate.inlines.hh"
#endif // !defined(PPL_Determinate_defs_hh)
|