PPL  1.2
Pointset_Powerset_defs.hh
Go to the documentation of this file.
1 /* Pointset_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_Pointset_Powerset_defs_hh
25 #define PPL_Pointset_Powerset_defs_hh
26 
28 #include "globals_defs.hh"
30 #include "Constraint_types.hh"
32 #include "Congruence_types.hh"
34 #include "C_Polyhedron_defs.hh"
35 #include "NNC_Polyhedron_defs.hh"
36 #include "Polyhedron_defs.hh"
37 #include "Grid_defs.hh"
39 #include "Variables_Set_types.hh"
40 #include "Determinate_defs.hh"
41 #include "Powerset_defs.hh"
44 #include <iosfwd>
45 #include <list>
46 #include <map>
47 
49 
60 template <typename PSET>
63 <Parma_Polyhedra_Library::Determinate<PSET> > {
64 public:
65  typedef PSET element_type;
66 
67 private:
70 
71 public:
74 
76 
77 
79 
86  explicit
87  Pointset_Powerset(dimension_type num_dimensions = 0,
89 
91 
95  Complexity_Class complexity = ANY_COMPLEXITY);
96 
107  template <typename QH>
108  explicit Pointset_Powerset(const Pointset_Powerset<QH>& y,
109  Complexity_Class complexity = ANY_COMPLEXITY);
110 
116  template <typename QH1, typename QH2, typename R>
117  explicit
119  Complexity_Class complexity = ANY_COMPLEXITY);
120 
125  explicit Pointset_Powerset(const Constraint_System& cs);
126 
131  explicit Pointset_Powerset(const Congruence_System& cgs);
132 
133 
135 
152  explicit Pointset_Powerset(const C_Polyhedron& ph,
153  Complexity_Class complexity = ANY_COMPLEXITY);
154 
156 
173  explicit Pointset_Powerset(const NNC_Polyhedron& ph,
174  Complexity_Class complexity = ANY_COMPLEXITY);
175 
176 
178 
193  explicit Pointset_Powerset(const Grid& gr,
194  Complexity_Class complexity = ANY_COMPLEXITY);
195 
197 
213  template <typename T>
214  explicit Pointset_Powerset(const Octagonal_Shape<T>& os,
215  Complexity_Class complexity = ANY_COMPLEXITY);
216 
218 
234  template <typename T>
235  explicit Pointset_Powerset(const BD_Shape<T>& bds,
236  Complexity_Class complexity = ANY_COMPLEXITY);
237 
239 
254  template <typename Interval>
255  explicit Pointset_Powerset(const Box<Interval>& box,
256  Complexity_Class complexity = ANY_COMPLEXITY);
257 
259 
261 
262 
265 
268 
273  bool is_empty() const;
274 
279  bool is_universe() const;
280 
285  bool is_topologically_closed() const;
286 
291  bool is_bounded() const;
292 
294 
299  bool is_disjoint_from(const Pointset_Powerset& y) const;
300 
302  bool is_discrete() const;
303 
323  bool constrains(Variable var) const;
324 
332  bool bounds_from_above(const Linear_Expression& expr) const;
333 
341  bool bounds_from_below(const Linear_Expression& expr) const;
342 
367  bool maximize(const Linear_Expression& expr,
368  Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
369 
398  bool maximize(const Linear_Expression& expr,
399  Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
400  Generator& g) const;
401 
426  bool minimize(const Linear_Expression& expr,
427  Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
428 
429 
458  bool minimize(const Linear_Expression& expr,
459  Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
460  Generator& g) const;
461 
473  bool geometrically_covers(const Pointset_Powerset& y) const;
474 
486  bool geometrically_equals(const Pointset_Powerset& y) const;
487 
496  bool contains(const Pointset_Powerset& y) const;
497 
506  bool strictly_contains(const Pointset_Powerset& y) const;
507 
512  bool contains_integer_point() const;
513 
522 
530  Poly_Gen_Relation relation_with(const Generator& g) const;
531 
539  Poly_Con_Relation relation_with(const Congruence& cg) const;
540 
546 
552 
559  int32_t hash_code() const;
560 
562  bool OK() const;
563 
565 
567 
568 
570 
574  void add_disjunct(const PSET& ph);
575 
577 
582  void add_constraint(const Constraint& c);
583 
593  void refine_with_constraint(const Constraint& c);
594 
596 
604  void add_constraints(const Constraint_System& cs);
605 
616 
618 
623  void add_congruence(const Congruence& cg);
624 
634  void refine_with_congruence(const Congruence& cg);
635 
637 
645  void add_congruences(const Congruence_System& cgs);
646 
657 
668  void unconstrain(Variable var);
669 
682  void unconstrain(const Variables_Set& vars);
683 
696  = ANY_COMPLEXITY);
697 
714  Complexity_Class complexity
715  = ANY_COMPLEXITY);
716 
719 
721 
725  void intersection_assign(const Pointset_Powerset& y);
726 
735  void difference_assign(const Pointset_Powerset& y);
736 
747 
769  void affine_image(Variable var,
770  const Linear_Expression& expr,
771  Coefficient_traits::const_reference denominator
772  = Coefficient_one());
773 
795  void affine_preimage(Variable var,
796  const Linear_Expression& expr,
797  Coefficient_traits::const_reference denominator
798  = Coefficient_one());
799 
827  Relation_Symbol relsym,
828  const Linear_Expression& expr,
829  Coefficient_traits::const_reference denominator
830  = Coefficient_one());
831 
858  void
860  Relation_Symbol relsym,
861  const Linear_Expression& expr,
862  Coefficient_traits::const_reference denominator
863  = Coefficient_one());
864 
886  Relation_Symbol relsym,
887  const Linear_Expression& rhs);
888 
910  Relation_Symbol relsym,
911  const Linear_Expression& rhs);
912 
940  const Linear_Expression& lb_expr,
941  const Linear_Expression& ub_expr,
942  Coefficient_traits::const_reference denominator
943  = Coefficient_one());
944 
972  const Linear_Expression& lb_expr,
973  const Linear_Expression& ub_expr,
974  Coefficient_traits::const_reference denominator
975  = Coefficient_one());
976 
985  void time_elapse_assign(const Pointset_Powerset& y);
986 
1033  void wrap_assign(const Variables_Set& vars,
1037  const Constraint_System* cs_p = 0,
1038  unsigned complexity_threshold = 16,
1039  bool wrap_individually = true);
1040 
1049  void pairwise_reduce();
1050 
1078  template <typename Widening>
1080  Widening widen_fun,
1081  unsigned max_disjuncts);
1082 
1111  template <typename Cert, typename Widening>
1112  void BHZ03_widening_assign(const Pointset_Powerset& y, Widening widen_fun);
1113 
1115 
1117 
1118 
1124 
1130  template <typename QH>
1132 
1134  void m_swap(Pointset_Powerset& y);
1135 
1141 
1147 
1149 
1154  void concatenate_assign(const Pointset_Powerset& y);
1155 
1157 
1166  void remove_space_dimensions(const Variables_Set& vars);
1167 
1176  void remove_higher_space_dimensions(dimension_type new_dimension);
1177 
1184  template <typename Partial_Function>
1185  void map_space_dimensions(const Partial_Function& pfunc);
1186 
1188 
1211 
1213 
1236  void fold_space_dimensions(const Variables_Set& vars, Variable dest);
1237 
1239 
1240 public:
1241  typedef typename Base::size_type size_type;
1242  typedef typename Base::value_type value_type;
1243  typedef typename Base::iterator iterator;
1247 
1249 
1255  bool ascii_load(std::istream& s);
1256 
1257 private:
1258  typedef typename Base::Sequence Sequence;
1261 
1264 
1274  bool intersection_preserving_enlarge_element(PSET& dest) const;
1275 
1280  template <typename Widening>
1281  void BGP99_heuristics_assign(const Pointset_Powerset& y, Widening widen_fun);
1282 
1284  template <typename Cert>
1285  void collect_certificates(std::map<Cert, size_type,
1286  typename Cert::Compare>& cert_ms) const;
1287 
1292  template <typename Cert>
1293  bool is_cert_multiset_stabilizing(const std::map<Cert, size_type,
1294  typename Cert::Compare>&
1295  y_cert_ms) const;
1296 
1301  template <typename Cons_or_Congr>
1302  Poly_Con_Relation relation_with_aux(const Cons_or_Congr& c) const;
1303 
1304  // FIXME: here it should be enough to befriend the template constructor
1305  // template <typename QH>
1306  // Pointset_Powerset(const Pointset_Powerset<QH>&),
1307  // but, apparently, this cannot be done.
1309 };
1310 
1311 namespace Parma_Polyhedra_Library {
1312 
1314 
1315 template <typename PSET>
1317 
1319 
1338 template <typename PSET>
1339 std::pair<PSET, Pointset_Powerset<NNC_Polyhedron> >
1340 linear_partition(const PSET& p, const PSET& q);
1341 
1348 bool
1349 check_containment(const NNC_Polyhedron& ph,
1351 
1352 
1374 std::pair<Grid, Pointset_Powerset<Grid> >
1375 approximate_partition(const Grid& p, const Grid& q, bool& finite_partition);
1376 
1383 bool
1384 check_containment(const Grid& ph,
1385  const Pointset_Powerset<Grid>& ps);
1386 
1397 template <typename PSET>
1398 bool
1399 check_containment(const PSET& ph, const Pointset_Powerset<PSET>& ps);
1400 
1401 // CHECKME: according to the Intel compiler, the declaration of the
1402 // following specialization (of the class template parameter) should come
1403 // before the declaration of the corresponding full specialization
1404 // (where the member template parameter is specialized too).
1405 template <>
1406 template <typename QH>
1410 
1411 // Non-inline full specializations should be declared here
1412 // so as to inhibit multiple instantiations of the generic template.
1413 template <>
1414 template <>
1418 
1419 template <>
1420 template <>
1424 
1425 template <>
1426 template <>
1430 
1431 template <>
1432 void
1435 
1436 template <>
1437 void
1440 
1441 template <>
1442 bool
1445 
1446 template <>
1447 bool
1450 
1451 } // namespace Parma_Polyhedra_Library
1452 
1455 
1456 #endif // !defined(PPL_Pointset_Powerset_defs_hh)
Poly_Con_Relation relation_with(const Constraint &c) const
Returns the relations holding between the powerset *this and the constraint c.
void add_congruence(const Congruence &cg)
Intersects *this with congruence cg.
The partially reduced product of two abstractions.
void BHZ03_widening_assign(const Pointset_Powerset &y, Widening widen_fun)
Assigns to *this the result of computing the BHZ03-widening between *this and y, using the widening f...
A linear equality or inequality.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from below in *this.
void swap(CO_Tree &x, CO_Tree &y)
void pairwise_reduce()
Assign to *this the result of (recursively) merging together the pairs of disjuncts whose upper-bound...
bool maximize(const Linear_Expression &expr, Coefficient &sup_n, Coefficient &sup_d, bool &maximum) const
Returns true if and only if *this is not empty and expr is bounded from above in *this, in which case the supremum value is computed.
std::reverse_iterator< const_iterator > const_reverse_iterator
The reverse iterator type built from Powerset::const_iterator.
size_t dimension_type
An unsigned integral type for representing space dimensions.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
static dimension_type max_space_dimension()
Returns the maximum space dimension a Pointset_Powerset can handle.
An std::set of variables' indexes.
bool is_topologically_closed() const
Returns true if and only if all the disjuncts in *this are topologically closed.
A line, ray, point or closure point.
void generalized_affine_image(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the image of *this with respect to the generalized affine relation ...
void refine_with_constraints(const Constraint_System &cs)
Use the constraints in cs to refine *this.
void time_elapse_assign(const Pointset_Powerset &y)
Assigns to *this the result of computing the time-elapse between *this and y.
bool contains_integer_point() const
Returns true if and only if *this contains at least one integer point.
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified space dimensions.
void concatenate_assign(const Pointset_Powerset &y)
Assigns to *this the concatenation of *this and y.
bool OK() const
Checks if all the invariants are satisfied.
bool geometrically_equals(const Pointset_Powerset &y) const
Returns true if and only if *this is geometrically equal to y, i.e., if (the elements of) *this and y...
void difference_assign(const Pointset_Powerset &y)
Assigns to *this an (a smallest) over-approximation as a powerset of the disjunct domain of the set-t...
A wrapper for PPL pointsets, providing them with a determinate constraint system interface, as defined in [Bag98].
void add_constraints(const Constraint_System &cs)
Intersects *this with the constraints in cs.
void m_swap(Pointset_Powerset &y)
Swaps *this with y.
bool is_bounded() const
Returns true if and only if all elements in *this are bounded.
The powerset construction on a base-level domain.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
A dimension of the vector space.
Sequence::const_iterator Sequence_const_iterator
Alias for the low-level const_iterator on the disjuncts.
void refine_with_constraint(const Constraint &c)
Use the constraint c to refine *this.
Complexity_Class
Complexity pseudo-classes.
bool geometrically_covers(const Pointset_Powerset &y) const
Returns true if and only if *this geometrically covers y, i.e., if any point (in some element) of y i...
void add_space_dimensions_and_embed(dimension_type m)
Adds m new dimensions to the vector space containing *this and embeds each disjunct in *this in the n...
#define PPL_OUTPUT_DECLARATIONS
Relation_Symbol
Relation symbols.
Degenerate_Element
Kinds of degenerate abstract elements.
bool minimize(const Linear_Expression &expr, Coefficient &inf_n, Coefficient &inf_d, bool &minimum) const
Returns true if and only if *this is not empty and expr is bounded from below in *this, in which case the infimum value is computed.
void wrap_assign(const Variables_Set &vars, Bounded_Integer_Type_Width w, Bounded_Integer_Type_Representation r, Bounded_Integer_Type_Overflow o, const Constraint_System *cs_p=0, unsigned complexity_threshold=16, bool wrap_individually=true)
Wraps the specified dimensions of the vector space.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
void refine_with_congruence(const Congruence &cg)
Use the congruence cg to refine *this.
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
void affine_preimage(Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the affine preimage of *this under the function mapping variable var to the affine e...
bool is_universe() const
Returns true if and only if *this is the top element of the powerset lattice.
Pointset_Powerset(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a universe (top) or empty (bottom) Pointset_Powerset.
void collect_certificates(std::map< Cert, size_type, typename Cert::Compare > &cert_ms) const
Records in cert_ms the certificates for this set of disjuncts.
A not necessarily closed convex polyhedron.
dimension_type affine_dimension() const
Returns the dimension of the vector space enclosing *this.
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
A closed convex polyhedron.
bool is_discrete() const
Returns true if and only if *this is discrete.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void bounded_affine_image(Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the image of *this with respect to the bounded affine relation . ...
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
bool contains(const Pointset_Powerset &y) const
Returns true if and only if each disjunct of y is contained in a disjunct of *this.
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
void add_congruences(const Congruence_System &cgs)
Intersects *this with the congruences in cgs.
The universe element, i.e., the whole vector space.
void generalized_affine_preimage(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the preimage of *this with respect to the generalized affine relation ...
void bounded_affine_preimage(Variable var, const Linear_Expression &lb_expr, const Linear_Expression &ub_expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the preimage of *this with respect to the bounded affine relation ...
bool is_empty() const
Returns true if and only if *this is an empty powerset.
A const_iterator on a sequence of read-only objects.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from above in *this.
void remove_higher_space_dimensions(dimension_type new_dimension)
Removes the higher space dimensions so that the resulting space will have dimension new_dimension...
The powerset construction instantiated on PPL pointset domains.
The entire library is confined to this namespace.
Definition: version.hh:61
bool intersection_preserving_enlarge_element(PSET &dest) const
Assigns to dest a powerset meet-preserving enlargement of itself with respect to *this. If false is returned, then the intersection is empty.
void add_disjunct(const PSET &ph)
Adds to *this the disjunct ph.
void add_space_dimensions_and_project(dimension_type m)
Adds m new dimensions to the vector space containing *this without embedding the disjuncts in *this i...
void intersection_assign(const Pointset_Powerset &y)
Assigns to *this the intersection of *this and y.
bool is_disjoint_from(const Pointset_Powerset &y) const
Returns true if and only if *this and y are disjoint.
bool strictly_contains(const Pointset_Powerset &y) const
Returns true if and only if each disjunct of y is strictly contained in a disjunct of *this...
A bounded difference shape.
void drop_some_non_integer_points(Complexity_Class complexity=ANY_COMPLEXITY)
Possibly tightens *this by dropping some points with non-integer coordinates.
void BGP99_heuristics_assign(const Pointset_Powerset &y, Widening widen_fun)
Assigns to *this the result of applying the BGP99 heuristics to *this and y, using the widening funct...
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.
void refine_with_congruences(const Congruence_System &cgs)
Use the congruences in cgs to refine *this.
An iterator on a sequence of read-only objects.
memory_size_type external_memory_in_bytes() const
Returns a lower bound to the size in bytes of the memory managed by *this.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void add_constraint(const Constraint &c)
Intersects *this with constraint c.
Coefficient c
Definition: PIP_Tree.cc:64
dimension_type space_dim
The number of dimensions of the enclosing vector space.
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
Pointset_Powerset & operator=(const Pointset_Powerset &y)
The assignment operator (*this and y can be dimension-incompatible).
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
Poly_Con_Relation relation_with_aux(const Cons_or_Congr &c) const
Template helper: common implementation for constraints and congruences.
std::list< D > Sequence
A powerset is implemented as a sequence of elements.
bool is_cert_multiset_stabilizing(const std::map< Cert, size_type, typename Cert::Compare > &y_cert_ms) const
Returns true if and only if the current set of disjuncts is stabilizing with respect to the multiset ...
void affine_image(Variable var, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one())
Assigns to *this the affine image of *this under the function mapping variable var to the affine expr...
The relation between a polyhedron and a generator.
bool simplify_using_context_assign(const Pointset_Powerset &y)
Assigns to *this a meet-preserving simplification of *this with respect to y. If false is returned...
void topological_closure_assign()
Assigns to *this its topological closure.
The relation between a polyhedron and a constraint.
Base::Sequence_const_iterator Sequence_const_iterator
void BGP99_extrapolation_assign(const Pointset_Powerset &y, Widening widen_fun, unsigned max_disjuncts)
Assigns to *this the result of applying the BGP99 extrapolation operator to *this and y...