PPL  1.2
Partially_Reduced_Product_defs.hh
Go to the documentation of this file.
1 /* Partially_Reduced_Product 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_Partially_Reduced_Product_defs_hh
25 #define PPL_Partially_Reduced_Product_defs_hh 1
26 
28 #include "globals_types.hh"
29 #include "Coefficient_defs.hh"
30 #include "Variable_types.hh"
31 #include "Variables_Set_types.hh"
33 #include "Constraint_types.hh"
34 #include "Generator_types.hh"
35 #include "Congruence_types.hh"
36 #include "Grid_Generator_types.hh"
43 #include "C_Polyhedron_types.hh"
44 #include "NNC_Polyhedron_types.hh"
45 #include "Grid_types.hh"
46 #include "Box_types.hh"
47 #include "BD_Shape_types.hh"
48 #include "Octagonal_Shape_types.hh"
49 
50 namespace Parma_Polyhedra_Library {
51 
52 namespace IO_Operators {
53 
55 
59 template <typename D1, typename D2, typename R>
60 std::ostream&
61 operator<<(std::ostream& s, const Partially_Reduced_Product<D1, D2, R>& dp);
62 
63 } // namespace IO_Operators
64 
66 
67 template <typename D1, typename D2, typename R>
68 void swap(Partially_Reduced_Product<D1, D2, R>& x,
69  Partially_Reduced_Product<D1, D2, R>& y);
70 
79 template <typename D1, typename D2, typename R>
80 bool operator==(const Partially_Reduced_Product<D1, D2, R>& x,
81  const Partially_Reduced_Product<D1, D2, R>& y);
82 
91 template <typename D1, typename D2, typename R>
92 bool operator!=(const Partially_Reduced_Product<D1, D2, R>& x,
93  const Partially_Reduced_Product<D1, D2, R>& y);
94 
95 } // namespace Parma_Polyhedra_Library
96 
97 
106 template <typename D1, typename D2>
108 public:
110  Smash_Reduction();
111 
125  void product_reduce(D1& d1, D2& d2);
126 
129 };
130 
140 template <typename D1, typename D2>
142 public:
145 
168  void product_reduce(D1& d1, D2& d2);
169 
172 };
173 
198 template <typename D1, typename D2>
200 public:
203 
225  void product_reduce(D1& d1, D2& d2);
226 
229 };
230 
248 template <typename D1, typename D2>
250 public:
253 
275  void product_reduce(D1& d1, D2& d2);
276 
279 };
280 
288 template <typename D1, typename D2>
290 public:
292  No_Reduction();
293 
299  void product_reduce(D1& d1, D2& d2);
300 
302  ~No_Reduction();
303 };
304 
306 
417 template <typename D1, typename D2, typename R>
419 public:
425 
427 
438  explicit Partially_Reduced_Product(dimension_type num_dimensions = 0,
440 
442 
452  explicit Partially_Reduced_Product(const Congruence_System& cgs);
453 
455 
467 
469 
479  explicit Partially_Reduced_Product(const Constraint_System& cs);
480 
482 
493 
495 
512  explicit
514  Complexity_Class complexity = ANY_COMPLEXITY);
515 
517 
534  explicit
536  Complexity_Class complexity = ANY_COMPLEXITY);
537 
539 
553  explicit
555  Complexity_Class complexity = ANY_COMPLEXITY);
556 
558 
572  template <typename Interval>
574  Complexity_Class complexity = ANY_COMPLEXITY);
575 
577 
591  template <typename U>
593  Complexity_Class complexity = ANY_COMPLEXITY);
594 
596 
610  template <typename U>
612  Complexity_Class complexity = ANY_COMPLEXITY);
613 
616  Complexity_Class complexity = ANY_COMPLEXITY);
617 
619 
622  template <typename E1, typename E2, typename S>
623  explicit
625  Complexity_Class complexity = ANY_COMPLEXITY);
626 
632 
634 
635 
638 
646 
648  const D1& domain1() const;
649 
651  const D2& domain2() const;
652 
655 
661 
664 
670 
672  /*
673  \exception std::invalid_argument
674  Thrown if \p *this and congruence \p cg are dimension-incompatible.
675 
676  Returns the Poly_Con_Relation \p r for \p *this:
677  suppose the first component returns \p r1 and the second \p r2,
678  then \p r implies <CODE>is_included()</CODE>
679  if and only if one or both of \p r1 and \p r2 imply
680  <CODE>is_included()</CODE>;
681  \p r implies <CODE>saturates()</CODE>
682  if and only if one or both of \p r1 and \p r2 imply
683  <CODE>saturates()</CODE>;
684  \p r implies <CODE>is_disjoint()</CODE>
685  if and only if one or both of \p r1 and \p r2 imply
686  <CODE>is_disjoint()</CODE>;
687  and \p r implies <CODE>nothing()</CODE>
688  if and only if both \p r1 and \p r2 imply
689  <CODE>strictly_intersects()</CODE>.
690  */
692 
694  /*
695  \exception std::invalid_argument
696  Thrown if \p *this and congruence \p cg are dimension-incompatible.
697  */
698  Poly_Con_Relation relation_with(const Congruence& cg) const;
699 
701  /*
702  \exception std::invalid_argument
703  Thrown if \p *this and generator \p g are dimension-incompatible.
704 
705  Returns the Poly_Gen_Relation \p r for \p *this:
706  suppose the first component returns \p r1 and the second \p r2,
707  then \p r = <CODE>subsumes()</CODE>
708  if and only if \p r1 = \p r2 = <CODE>subsumes()</CODE>;
709  and \p r = <CODE>nothing()</CODE>
710  if and only if one or both of \p r1 and \p r2 = <CODE>nothing()</CODE>;
711  */
712  Poly_Gen_Relation relation_with(const Generator& g) const;
713 
718  bool is_empty() const;
719 
724  bool is_universe() const;
725 
730  bool is_topologically_closed() const;
731 
739  bool is_disjoint_from(const Partially_Reduced_Product& y) const;
740 
745  bool is_discrete() const;
746 
751  bool is_bounded() const;
752 
760  bool constrains(Variable var) const;
761 
763 
769  bool bounds_from_above(const Linear_Expression& expr) const;
770 
772 
778  bool bounds_from_below(const Linear_Expression& expr) const;
779 
804  bool maximize(const Linear_Expression& expr,
805  Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
806 
835  bool maximize(const Linear_Expression& expr,
836  Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
837  Generator& g) const;
838 
863  bool minimize(const Linear_Expression& expr,
864  Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
865 
894  bool minimize(const Linear_Expression& expr,
895  Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
896  Generator& g) const;
897 
905  bool contains(const Partially_Reduced_Product& y) const;
906 
914  bool strictly_contains(const Partially_Reduced_Product& y) const;
915 
917  bool OK() const;
918 
920 
922 
923 
925 
929  void add_constraint(const Constraint& c);
930 
940  void refine_with_constraint(const Constraint& c);
941 
943 
948  void add_congruence(const Congruence& cg);
949 
959  void refine_with_congruence(const Congruence& cg);
960 
962 
969  void add_congruences(const Congruence_System& cgs);
970 
981 
983 
995 
997 
1004  void add_constraints(const Constraint_System& cs);
1005 
1016 
1018 
1030 
1041  void unconstrain(Variable var);
1042 
1055  void unconstrain(const Variables_Set& vars);
1056 
1064 
1073 
1084 
1093 
1116  void affine_image(Variable var,
1117  const Linear_Expression& expr,
1118  Coefficient_traits::const_reference denominator
1119  = Coefficient_one());
1120 
1141  void affine_preimage(Variable var,
1142  const Linear_Expression& expr,
1143  Coefficient_traits::const_reference denominator
1144  = Coefficient_one());
1145 
1174  Relation_Symbol relsym,
1175  const Linear_Expression& expr,
1176  Coefficient_traits::const_reference denominator
1177  = Coefficient_one());
1178 
1206  void
1208  Relation_Symbol relsym,
1209  const Linear_Expression& expr,
1210  Coefficient_traits::const_reference denominator
1211  = Coefficient_one());
1212 
1235  Relation_Symbol relsym,
1236  const Linear_Expression& rhs);
1237 
1260  Relation_Symbol relsym,
1261  const Linear_Expression& rhs);
1262 
1289  void bounded_affine_image(Variable var,
1290  const Linear_Expression& lb_expr,
1291  const Linear_Expression& ub_expr,
1292  Coefficient_traits::const_reference denominator
1293  = Coefficient_one());
1294 
1322  const Linear_Expression& lb_expr,
1323  const Linear_Expression& ub_expr,
1324  Coefficient_traits::const_reference denominator
1325  = Coefficient_one());
1326 
1336 
1339 
1340  // TODO: Add a way to call other widenings.
1341 
1342  // CHECKME: This may not be a real widening; it depends on the reduction
1343  // class R and the widening used.
1344 
1365  unsigned* tp = NULL);
1366 
1379  = ANY_COMPLEXITY);
1380 
1397  Complexity_Class complexity
1398  = ANY_COMPLEXITY);
1399 
1401 
1403 
1404 
1417 
1430 
1442 
1444 
1453  void remove_space_dimensions(const Variables_Set& vars);
1454 
1463  void remove_higher_space_dimensions(dimension_type new_dimension);
1464 
1513  template <typename Partial_Function>
1514  void map_space_dimensions(const Partial_Function& pfunc);
1515 
1517 
1540 
1542 
1565  void fold_space_dimensions(const Variables_Set& vars, Variable dest);
1566 
1568 
1569  friend bool operator==<>(const Partially_Reduced_Product<D1, D2, R>& x,
1571 
1572  friend std::ostream&
1573  Parma_Polyhedra_Library::IO_Operators::
1574  operator<<<>(std::ostream& s, const Partially_Reduced_Product<D1, D2, R>& dp);
1575 
1577 
1578 
1581 
1587 
1589 
1595  bool ascii_load(std::istream& s);
1596 
1599 
1602 
1609  int32_t hash_code() const;
1610 
1612 
1614  /*
1615  \return
1616  <CODE>true</CODE> if and only if either of the resulting component
1617  is strictly contained in the respective original.
1618  */
1619  bool reduce() const;
1620 
1621 protected:
1623  typedef D1 Domain1;
1624 
1626  typedef D2 Domain2;
1627 
1629  D1 d1;
1630 
1632  D2 d2;
1633 
1634 protected:
1636  void clear_reduced_flag() const;
1637 
1639  void set_reduced_flag() const;
1640 
1642  bool is_reduced() const;
1643 
1648  bool reduced;
1649 
1650 private:
1651  void throw_space_dimension_overflow(const char* method,
1652  const char* reason);
1653 };
1654 
1655 namespace Parma_Polyhedra_Library {
1656 
1665 template <typename D1, typename D2>
1667 public:
1670 
1673 
1676 
1679 
1682 };
1683 
1684 } // namespace Parma_Polyhedra_Library
1685 
1688 
1689 #endif // !defined(PPL_Partially_Reduced_Product_defs_hh)
dimension_type affine_dimension() const
Returns the minimum affine dimension (see also grid affine dimension) of the components of *this...
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
void upper_bound_assign(const Partially_Reduced_Product &y)
Assigns to *this an upper bound of *this and y computed on the corresponding components.
Partially_Reduced_Product< D1, D2, Congruences_Reduction< D1, D2 > > Congruences_Product
bool is_disjoint_from(const Partially_Reduced_Product &y) const
Returns true if and only if *this and y are componentwise disjoint.
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
The partially reduced product of two abstractions.
Congruence_System congruences() const
Returns a system of congruences which approximates *this.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
void refine_with_constraint(const Constraint &c)
Use the constraint c to refine *this.
A linear equality or inequality.
void topological_closure_assign()
Assigns to *this its topological closure.
void swap(CO_Tree &x, CO_Tree &y)
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
size_t dimension_type
An unsigned integral type for representing space dimensions.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
An std::set of variables' indexes.
A line, ray, point or closure point.
void product_reduce(D1 &d1, D2 &d2)
The congruences reduction operator for detect emptiness or any equalities implied by each of the cong...
This class is temporary and will be removed when template typedefs will be supported in C++...
Poly_Con_Relation relation_with(const Constraint &c) const
Returns the relations holding between *this and c.
void product_reduce(D1 &d1, D2 &d2)
The constraints reduction operator for sharing constraints between the domains.
void refine_with_congruence(const Congruence &cg)
Use the congruence cg to refine *this.
void drop_some_non_integer_points(Complexity_Class complexity=ANY_COMPLEXITY)
Possibly tightens *this by dropping some points with non-integer coordinates.
void product_reduce(D1 &d1, D2 &d2)
The null reduction operator.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
Partially_Reduced_Product< D1, D2, Constraints_Reduction< D1, D2 > > Constraints_Product
Partially_Reduced_Product< D1, D2, No_Reduction< D1, D2 > > Direct_Product
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 i *this, in which case the infimum value is computed.
bool is_reduced() const
Return true if and only if the reduced flag is set.
void refine_with_congruences(const Congruence_System &cgs)
Use the congruences in cgs to refine *this.
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 ...
Congruence_System minimized_congruences() const
Returns a system of congruences which approximates *this, in reduced form.
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
This class provides the reduction method for the Constraints_Product domain.
void add_congruences(const Congruence_System &cgs)
Adds a copy of the congruences in cgs to *this.
void time_elapse_assign(const Partially_Reduced_Product &y)
Assigns to *this the result of computing the time-elapse between *this and y. (See also time-elapse...
bool is_discrete() const
Returns true if and only if a component of *this is discrete.
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 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 ...
Partially_Reduced_Product & operator=(const Partially_Reduced_Product &y)
The assignment operator. (*this and y can be dimension-incompatible.)
This class provides the reduction method for the Congruences_Product domain.
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
Partially_Reduced_Product< D1, D2, Smash_Reduction< D1, D2 > > Smash_Product
void add_constraint(const Constraint &c)
Adds constraint c to *this.
void refine_with_constraints(const Constraint_System &cs)
Use the constraints in cs to refine *this.
Constraint_System minimized_constraints() const
Returns a system of constraints which approximates *this, in reduced form.
A dimension of the vector space.
bool is_bounded() const
Returns true if and only if a component of *this is bounded.
void add_recycled_constraints(Constraint_System &cs)
Adds the constraint system in cs to *this.
void remove_higher_space_dimensions(dimension_type new_dimension)
Removes the higher dimensions of the vector space so that the resulting space will have dimension new...
Complexity_Class
Complexity pseudo-classes.
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
#define PPL_OUTPUT_DECLARATIONS
void product_reduce(D1 &d1, D2 &d2)
The congruences reduction operator for detect emptiness or any equalities implied by each of the cong...
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the components of *this in the new vector space.
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 ...
Relation_Symbol
Relation symbols.
Degenerate_Element
Kinds of degenerate abstract elements.
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.
void add_constraints(const Constraint_System &cs)
Adds a copy of the constraint system in cs to *this.
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 expre...
Partially_Reduced_Product(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds an object having the specified properties.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
bool upper_bound_assign_if_exact(const Partially_Reduced_Product &y)
Assigns to *this an upper bound of *this and y computed on the corresponding components. If it is exact on each of the components of *this, true is returned, otherwise false is returned.
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions and does not embed the components in the new vector space.
A not necessarily closed convex polyhedron.
bool contains(const Partially_Reduced_Product &y) const
Returns true if and only if each component of *this contains the corresponding component of y...
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
A closed convex polyhedron.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void difference_assign(const Partially_Reduced_Product &y)
Assigns to *this an approximation of the set-theoretic difference of *this and y. ...
void concatenate_assign(const Partially_Reduced_Product &y)
Assigns to the first (resp., second) component of *this the "concatenation" of the first (resp...
bool OK() const
Checks if all the invariants are satisfied.
The universe element, i.e., the whole vector space.
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
The entire library is confined to this namespace.
Definition: version.hh:61
const D2 & domain2() const
Returns a constant reference to the second of the pair.
Constraint_System constraints() const
Returns a system of constraints which approximates *this.
void add_recycled_congruences(Congruence_System &cgs)
Adds the congruences in cgs to *this.
A bounded difference shape.
void add_congruence(const Congruence &cg)
Adds a copy of congruence cg to *this.
bool is_universe() const
Returns true if and only if both of the components of *this are the universe.
bool is_empty() const
Returns true if and only if either of the components of *this are empty.
void m_swap(Partially_Reduced_Product &y)
Swaps *this with product y. (*this and y can be dimension-incompatible.)
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
Partially_Reduced_Product< D1, D2, Shape_Preserving_Reduction< D1, D2 > > Shape_Preserving_Product
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void product_reduce(D1 &d1, D2 &d2)
The smash reduction operator for propagating emptiness between the domain elements d1 and d2...
bool reduced
Flag to record whether the components are reduced with respect to each other and the reduction class...
Coefficient c
Definition: PIP_Tree.cc:64
static dimension_type max_space_dimension()
Returns the maximum space dimension this product can handle.
This class provides the reduction method for the Smash_Product domain.
This class provides the reduction method for the Shape_Preserving_Product domain. ...
void widening_assign(const Partially_Reduced_Product &y, unsigned *tp=NULL)
Assigns to *this the result of computing the "widening" between *this and y.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
This class provides the reduction method for the Direct_Product domain.
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_topologically_closed() const
Returns true if and only if both of the components of *this are topologically closed subsets of the v...
void intersection_assign(const Partially_Reduced_Product &y)
Assigns to *this the componentwise intersection of *this and y.
bool strictly_contains(const Partially_Reduced_Product &y) const
Returns true if and only if each component of *this strictly contains the corresponding component of ...
The relation between a polyhedron and a generator.
const D1 & domain1() const
Returns a constant reference to the first of the pair.
The relation between a polyhedron and a constraint.
void throw_space_dimension_overflow(const char *method, const char *reason)