PPL  1.2
Grid_defs.hh
Go to the documentation of this file.
1 /* Grid 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_Grid_defs_hh
25 #define PPL_Grid_defs_hh 1
26 
27 #include "Grid_types.hh"
28 #include "globals_defs.hh"
29 #include "Variable_defs.hh"
30 #include "Variables_Set_types.hh"
32 #include "Constraint_types.hh"
39 #include "Grid_Generator_types.hh"
43 #include "Box_types.hh"
44 #include "Polyhedron_types.hh"
45 #include "BD_Shape_types.hh"
46 #include "Octagonal_Shape_types.hh"
47 #include <vector>
48 #include <iosfwd>
49 
50 namespace Parma_Polyhedra_Library {
51 
52 namespace IO_Operators {
53 
55 
63 std::ostream&
64 operator<<(std::ostream& s, const Grid& gr);
65 
66 } // namespace IO_Operators
67 
69 
70 void swap(Grid& x, Grid& y);
71 
80 bool operator==(const Grid& x, const Grid& y);
81 
90 bool operator!=(const Grid& x, const Grid& y);
91 
92 } // namespace Parma_Polyhedra_Library
93 
94 
96 
364 public:
367 
370 
375  static bool can_recycle_congruence_systems();
376 
381  static bool can_recycle_constraint_systems();
382 
384 
395  explicit Grid(dimension_type num_dimensions = 0,
397 
399 
409  explicit Grid(const Congruence_System& cgs);
410 
412 
427  Grid(Congruence_System& cgs, Recycle_Input dummy);
428 
430 
443  explicit Grid(const Constraint_System& cs);
444 
446 
465 
467 
480  explicit Grid(const Grid_Generator_System& ggs);
481 
483 
501 
503 
518  template <typename Interval>
519  explicit Grid(const Box<Interval>& box,
520  Complexity_Class complexity = ANY_COMPLEXITY);
521 
523 
538  template <typename U>
539  explicit Grid(const BD_Shape<U>& bd,
540  Complexity_Class complexity = ANY_COMPLEXITY);
541 
543 
558  template <typename U>
559  explicit Grid(const Octagonal_Shape<U>& os,
560  Complexity_Class complexity = ANY_COMPLEXITY);
561 
580  explicit Grid(const Polyhedron& ph,
581  Complexity_Class complexity = ANY_COMPLEXITY);
582 
584 
587  Grid(const Grid& y,
588  Complexity_Class complexity = ANY_COMPLEXITY);
589 
594  Grid& operator=(const Grid& y);
595 
597 
598 
601 
607 
613 
619 
621  const Congruence_System& congruences() const;
622 
625 
627  const Grid_Generator_System& grid_generators() const;
628 
631 
633  /*
634  \exception std::invalid_argument
635  Thrown if \p *this and congruence \p cg are dimension-incompatible.
636  */
637  // FIXME: Poly_Con_Relation seems to encode exactly what we want
638  // here. We must find a new name for that class. Temporarily,
639  // we keep using it without changing the name.
640  Poly_Con_Relation relation_with(const Congruence& cg) const;
641 
643  /*
644  \exception std::invalid_argument
645  Thrown if \p *this and generator \p g are dimension-incompatible.
646  */
647  // FIXME: see the comment for Poly_Con_Relation above.
649  relation_with(const Grid_Generator& g) const;
650 
652  /*
653  \exception std::invalid_argument
654  Thrown if \p *this and generator \p g are dimension-incompatible.
655  */
656  // FIXME: see the comment for Poly_Con_Relation above.
658  relation_with(const Generator& g) const;
659 
661  /*
662  \exception std::invalid_argument
663  Thrown if \p *this and constraint \p c are dimension-incompatible.
664  */
665  // FIXME: Poly_Con_Relation seems to encode exactly what we want
666  // here. We must find a new name for that class. Temporarily,
667  // we keep using it without changing the name.
669 
671  bool is_empty() const;
672 
674  bool is_universe() const;
675 
682  bool is_topologically_closed() const;
683 
691  bool is_disjoint_from(const Grid& y) const;
692 
694 
699  bool is_discrete() const;
700 
702  bool is_bounded() const;
703 
708  bool contains_integer_point() const;
709 
717  bool constrains(Variable var) const;
718 
720 
726  bool bounds_from_above(const Linear_Expression& expr) const;
727 
729 
735  bool bounds_from_below(const Linear_Expression& expr) const;
736 
764  bool maximize(const Linear_Expression& expr,
765  Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
766 
798  bool maximize(const Linear_Expression& expr,
799  Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
800  Generator& point) const;
801 
829  bool minimize(const Linear_Expression& expr,
830  Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
831 
863  bool minimize(const Linear_Expression& expr,
864  Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
865  Generator& point) const;
866 
897  bool frequency(const Linear_Expression& expr,
898  Coefficient& freq_n, Coefficient& freq_d,
899  Coefficient& val_n, Coefficient& val_d) const;
900 
902 
906  bool contains(const Grid& y) const;
907 
915  bool strictly_contains(const Grid& y) const;
916 
918 
934  bool OK(bool check_not_empty = false) const;
935 
937 
939 
940 
942 
947  void add_congruence(const Congruence& cg);
948 
957  void add_grid_generator(const Grid_Generator& g);
958 
960 
968  void add_congruences(const Congruence_System& cgs);
969 
971 
984 
995  void add_constraint(const Constraint& c);
996 
1008  void add_constraints(const Constraint_System& cs);
1009 
1026 
1028 
1035  void refine_with_congruence(const Congruence& cg);
1036 
1038 
1045  void refine_with_congruences(const Congruence_System& cgs);
1046 
1048 
1056  void refine_with_constraint(const Constraint& c);
1057 
1059 
1067 
1082 
1099 
1110  void unconstrain(Variable var);
1111 
1124  void unconstrain(const Variables_Set& vars);
1125 
1132  void intersection_assign(const Grid& y);
1133 
1140  void upper_bound_assign(const Grid& y);
1141 
1150  bool upper_bound_assign_if_exact(const Grid& y);
1151 
1162  void difference_assign(const Grid& y);
1163 
1173  bool simplify_using_context_assign(const Grid& y);
1174 
1236  void affine_image(Variable var,
1237  const Linear_Expression& expr,
1238  Coefficient_traits::const_reference denominator
1239  = Coefficient_one());
1240 
1300  void affine_preimage(Variable var,
1301  const Linear_Expression& expr,
1302  Coefficient_traits::const_reference denominator
1303  = Coefficient_one());
1304 
1335  void
1337  Relation_Symbol relsym,
1338  const Linear_Expression& expr,
1339  Coefficient_traits::const_reference denominator
1340  = Coefficient_one(),
1341  Coefficient_traits::const_reference modulus
1342  = Coefficient_zero());
1343 
1374  void
1376  Relation_Symbol relsym,
1377  const Linear_Expression& expr,
1378  Coefficient_traits::const_reference denominator
1379  = Coefficient_one(),
1380  Coefficient_traits::const_reference modulus
1381  = Coefficient_zero());
1382 
1407  void
1409  Relation_Symbol relsym,
1410  const Linear_Expression& rhs,
1411  Coefficient_traits::const_reference modulus
1412  = Coefficient_zero());
1413 
1438  void
1440  Relation_Symbol relsym,
1441  const Linear_Expression& rhs,
1442  Coefficient_traits::const_reference modulus
1443  = Coefficient_zero());
1444 
1471  void bounded_affine_image(Variable var,
1472  const Linear_Expression& lb_expr,
1473  const Linear_Expression& ub_expr,
1474  Coefficient_traits::const_reference denominator
1475  = Coefficient_one());
1476 
1504  const Linear_Expression& lb_expr,
1505  const Linear_Expression& ub_expr,
1506  Coefficient_traits::const_reference denominator
1507  = Coefficient_one());
1508 
1516  void time_elapse_assign(const Grid& y);
1517 
1563  void wrap_assign(const Variables_Set& vars,
1567  const Constraint_System* cs_p = 0,
1568  unsigned complexity_threshold = 16,
1569  bool wrap_individually = true);
1570 
1580  = ANY_COMPLEXITY);
1581 
1595  Complexity_Class complexity
1596  = ANY_COMPLEXITY);
1597 
1600 
1616  void congruence_widening_assign(const Grid& y, unsigned* tp = NULL);
1617 
1633  void generator_widening_assign(const Grid& y, unsigned* tp = NULL);
1634 
1654  void widening_assign(const Grid& y, unsigned* tp = NULL);
1655 
1677  const Congruence_System& cgs,
1678  unsigned* tp = NULL);
1679 
1701  const Congruence_System& cgs,
1702  unsigned* tp = NULL);
1703 
1723  void limited_extrapolation_assign(const Grid& y,
1724  const Congruence_System& cgs,
1725  unsigned* tp = NULL);
1726 
1728 
1730 
1731 
1759 
1787 
1796  void concatenate_assign(const Grid& y);
1797 
1799 
1808  void remove_space_dimensions(const Variables_Set& vars);
1809 
1819  void remove_higher_space_dimensions(dimension_type new_dimension);
1820 
1868  template <typename Partial_Function>
1869  void map_space_dimensions(const Partial_Function& pfunc);
1870 
1872 
1895 
1897 
1920  void fold_space_dimensions(const Variables_Set& vars, Variable dest);
1921 
1923 
1924  friend bool operator==(const Grid& x, const Grid& y);
1925 
1927 
1928  template <typename Interval> friend class Parma_Polyhedra_Library::Box;
1929 
1931 
1932 
1934  ~Grid();
1935 
1940  void m_swap(Grid& y);
1941 
1943 
1949  bool ascii_load(std::istream& s);
1950 
1953 
1956 
1963  int32_t hash_code() const;
1964 
1966 
1967 private:
1968 
1971 
1974 
1975 #define PPL_IN_Grid_CLASS
1976 #include "Grid_Status_idefs.hh"
1977 #undef PPL_IN_Grid_CLASS
1978 
1981 
1984 
1987  LINE = 1,
1992  };
1993 
1994  typedef std::vector<Dimension_Kind> Dimension_Kinds;
1995 
1996  // The type of row associated with each dimension. If the virtual
1997  // rows existed then the reduced systems would be square and upper
1998  // or lower triangular, and the rows in each would have the types
1999  // given in this vector. As the congruence system is reduced to an
2000  // upside-down lower triangular form the ordering of the congruence
2001  // types is last to first.
2002  Dimension_Kinds dim_kinds;
2003 
2005 
2012  void construct(dimension_type num_dimensions, Degenerate_Element kind);
2013 
2015 
2022  void construct(Congruence_System& cgs);
2023 
2025 
2032  void construct(Grid_Generator_System& ggs);
2033 
2035 
2036 
2038 
2042  bool marked_empty() const;
2043 
2045  bool congruences_are_up_to_date() const;
2046 
2048  bool generators_are_up_to_date() const;
2049 
2051  bool congruences_are_minimized() const;
2052 
2054  bool generators_are_minimized() const;
2055 
2057 
2059 
2060 
2065  void set_zero_dim_univ();
2066 
2071  void set_empty();
2072 
2075 
2078 
2081 
2083  void set_generators_minimized();
2084 
2086 
2088 
2089 
2091  void clear_empty();
2092 
2095 
2098 
2101 
2104 
2106 
2108 
2109 
2111  void update_congruences() const;
2112 
2114 
2122  bool update_generators() const;
2123 
2125 
2127 
2128 
2130 
2138  bool minimize() const;
2139 
2141 
2146  };
2147 
2150 
2152  bool is_included_in(const Grid& y) const;
2153 
2155 
2172  bool bounds(const Linear_Expression& expr, const char* method_call) const;
2173 
2175 
2206  bool max_min(const Linear_Expression& expr,
2207  const char* method_call,
2208  Coefficient& ext_n, Coefficient& ext_d, bool& included,
2209  Generator* point = NULL) const;
2210 
2243  bool frequency_no_check(const Linear_Expression& expr,
2244  Coefficient& freq_n, Coefficient& freq_d,
2245  Coefficient& val_n, Coefficient& val_d) const;
2246 
2248 
2257  bool bounds_no_check(const Linear_Expression& expr) const;
2258 
2267  void add_congruence_no_check(const Congruence& cg);
2268 
2282  void add_constraint_no_check(const Constraint& c);
2283 
2295  void refine_no_check(const Constraint& c);
2296 
2298 
2299 
2301  void select_wider_congruences(const Grid& y,
2302  Congruence_System& selected_cgs) const;
2303 
2305  void select_wider_generators(const Grid& y,
2306  Grid_Generator_System& widened_ggs) const;
2307 
2309 
2311 
2326  dimension_type dims);
2327 
2329 
2343  Congruence_System& cgs,
2344  dimension_type dims);
2345 
2347 
2348 
2350 
2367  static void
2369  Coefficient& divisor,
2370  const Grid_Generator* first_point = NULL);
2371 
2373 
2381  static void
2383 
2385 
2401  static void normalize_divisors(Grid_Generator_System& sys,
2402  Grid_Generator_System& gen_sys);
2403 
2408  static void conversion(Congruence_System& source,
2409  Grid_Generator_System& dest,
2410  Dimension_Kinds& dim_kinds);
2411 
2416  static void conversion(Grid_Generator_System& source,
2417  Congruence_System& dest,
2418  Dimension_Kinds& dim_kinds);
2419 
2421 
2425  static bool simplify(Congruence_System& cgs,
2426  Dimension_Kinds& dim_kinds);
2427 
2429 
2432  static void simplify(Grid_Generator_System& ggs,
2433  Dimension_Kinds& dim_kinds);
2434 
2436 
2440  // A member of Grid for access to Matrix<Dense_Row>::rows.
2441  static void reduce_line_with_line(Grid_Generator& row,
2442  Grid_Generator& pivot,
2443  dimension_type column);
2444 
2446 
2451  // A member of Grid for access to Matrix<Dense_Row>::rows.
2452  static void reduce_equality_with_equality(Congruence& row,
2453  const Congruence& pivot,
2454  dimension_type column);
2455 
2457 
2468  // Part of Grid for access to Matrix<Dense_Row>::rows.
2469  template <typename R>
2470  static void reduce_pc_with_pc(R& row,
2471  R& pivot,
2472  dimension_type column,
2473  dimension_type start,
2474  dimension_type end);
2475 
2477 
2482  // This takes a parameter with type Swapping_Vector<Grid_Generator> (instead
2483  // of Grid_Generator_System) to simplify the implementation of `simplify()'.
2484  // NOTE: This may invalidate `row' and the rows in `sys'. Client code must
2485  // fix/check this.
2486  static void reduce_parameter_with_line(Grid_Generator& row,
2487  const Grid_Generator& pivot,
2488  dimension_type column,
2490  dimension_type num_columns);
2491 
2493 
2498  // A member of Grid for access to Matrix<Dense_Row>::rows.
2499  // This takes a parameter with type Swapping_Vector<Congruence> (instead of
2500  // Congruence_System) to simplify the implementation of `conversion()'.
2502  const Congruence& pivot,
2503  dimension_type column,
2505 
2507 
2539  template <typename M>
2540  // This takes a parameter with type `Swapping_Vector<M::row_type>'
2541  // instead of `M' to simplify the implementation of simplify().
2542  // NOTE: This may invalidate the rows in `sys'. Client code must
2543  // fix/check this.
2545  dimension_type dim,
2546  dimension_type pivot_index,
2547  dimension_type start, dimension_type end,
2548  const Dimension_Kinds& sys_dim_kinds,
2549  bool generators = true);
2550 
2552  // A member of Grid for access to Matrix<Dense_Row>::rows and cgs::operator[].
2553  // The type of `dest' is Swapping_Vector<Congruence> instead of
2554  // Congruence_System to simplify the implementation of conversion().
2555  static void multiply_grid(const Coefficient& multiplier,
2556  Congruence& cg,
2558  dimension_type num_rows);
2559 
2561  // A member of Grid for access to Grid_Generator::operator[].
2562  // The type of `dest' is Swapping_Vector<Grid_Generator> instead of
2563  // Grid_Generator_System to simplify the implementation of conversion().
2564  // NOTE: This does not check whether the rows are OK(). Client code
2565  // should do that.
2566  static void multiply_grid(const Coefficient& multiplier,
2567  Grid_Generator& gen,
2569  dimension_type num_rows);
2570 
2575  static bool lower_triangular(const Congruence_System& sys,
2576  const Dimension_Kinds& dim_kinds);
2577 
2582  static bool upper_triangular(const Grid_Generator_System& sys,
2583  const Dimension_Kinds& dim_kinds);
2584 
2585 #ifndef NDEBUG
2586 
2595  template <typename M, typename R>
2596  static bool rows_are_zero(M& system,
2597  dimension_type first,
2598  dimension_type last,
2599  dimension_type row_size);
2600 #endif
2601 
2603 
2604 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2605 
2607 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2608 protected:
2609  void throw_dimension_incompatible(const char* method,
2610  const char* other_name,
2611  dimension_type other_dim) const;
2612  void throw_dimension_incompatible(const char* method,
2613  const char* gr_name,
2614  const Grid& gr) const;
2615  void throw_dimension_incompatible(const char* method,
2616  const char* le_name,
2617  const Linear_Expression& le) const;
2618  void throw_dimension_incompatible(const char* method,
2619  const char* cg_name,
2620  const Congruence& cg) const;
2621  void throw_dimension_incompatible(const char* method,
2622  const char* c_name,
2623  const Constraint& c) const;
2624  void throw_dimension_incompatible(const char* method,
2625  const char* g_name,
2626  const Grid_Generator& g) const;
2627  void throw_dimension_incompatible(const char* method,
2628  const char* g_name,
2629  const Generator& g) const;
2630  void throw_dimension_incompatible(const char* method,
2631  const char* cgs_name,
2632  const Congruence_System& cgs) const;
2633  void throw_dimension_incompatible(const char* method,
2634  const char* cs_name,
2635  const Constraint_System& cs) const;
2636  void throw_dimension_incompatible(const char* method,
2637  const char* gs_name,
2638  const Grid_Generator_System& gs) const;
2639  void throw_dimension_incompatible(const char* method,
2640  const char* var_name,
2641  Variable var) const;
2642  void throw_dimension_incompatible(const char* method,
2643  dimension_type required_space_dim) const;
2644 
2645  static void throw_invalid_argument(const char* method,
2646  const char* reason);
2647  static void throw_invalid_constraint(const char* method,
2648  const char* c_name);
2649  static void throw_invalid_constraints(const char* method,
2650  const char* cs_name);
2651  static void throw_invalid_generator(const char* method,
2652  const char* g_name);
2653  static void throw_invalid_generators(const char* method,
2654  const char* gs_name);
2655 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2656 
2657 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2658 
2659 };
2660 
2661 #include "Grid_Status_inlines.hh"
2662 #include "Grid_inlines.hh"
2663 #include "Grid_templates.hh"
2664 
2665 #endif // !defined(PPL_Grid_defs_hh)
Grid_Generator_System gen_sys
The system of generators.
Definition: Grid_defs.hh:1973
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
void add_space_dimensions(Congruence_System &cgs, Grid_Generator_System &gs, dimension_type dims)
Adds new space dimensions to the given systems.
Definition: Grid_chdims.cc:34
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old grid in the new vector space.
Definition: Grid_chdims.cc:77
void drop_some_non_integer_points(Complexity_Class complexity=ANY_COMPLEXITY)
Possibly tightens *this by dropping all points with non-integer coordinates.
void congruence_widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y using congruence syste...
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
Definition: Grid_chdims.cc:406
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
void limited_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the Grid widening computation by also enforcing those congruences in cgs that ...
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
Definition: Grid_public.cc:886
Status status
The status flags to keep track of the grid's internal state.
Definition: Grid_defs.hh:1980
static void reduce_pc_with_pc(R &row, R &pivot, dimension_type column, dimension_type start, dimension_type end)
Reduces row using pivot.
void clear_congruences_minimized()
Sets status to express that congruences are no longer minimized.
Definition: Grid_inlines.hh:87
A linear equality or inequality.
void generalized_affine_image(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero())
Assigns to *this the image of *this with respect to the generalized affine relation ...
void swap(CO_Tree &x, CO_Tree &y)
bool is_universe() const
Returns true if and only if *this is a universe grid.
Definition: Grid_public.cc:769
void clear_generators_up_to_date()
Sets status to express that generators are out of date.
bool is_included_in(const Grid &y) const
Returns true if and only if *this is included in y.
friend bool operator==(const Grid &x, const Grid &y)
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The convergence certificate for the Grid widening operator.
void difference_assign(const Grid &y)
Assigns to *this the grid-difference of *this and y.
void limited_generator_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the generator variant of the Grid widening computation by also enforcing those...
void generator_widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y using generator system...
void set_empty()
Sets status to express that the grid is empty, clearing all corresponding matrices.
Grid(dimension_type num_dimensions=0, Degenerate_Element kind=UNIVERSE)
Builds a grid having the specified properties.
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...
Definition: Grid_chdims.cc:318
void add_constraints(const Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
size_t dimension_type
An unsigned integral type for representing space dimensions.
static void throw_invalid_generator(const char *method, const char *g_name)
An std::set of variables' indexes.
Congruence_System con_sys
The system of congruences.
Definition: Grid_defs.hh:1970
const Congruence_System & congruences() const
Returns the system of congruences.
Definition: Grid_public.cc:300
A line, ray, point or closure point.
void clear_generators_minimized()
Sets status to express that generators are no longer minimized.
Definition: Grid_inlines.hh:92
const Grid_Generator_System & minimized_grid_generators() const
Returns the minimized system of generators.
Definition: Grid_public.cc:356
void add_congruence_no_check(const Congruence &cg)
Adds the congruence cg to *this.
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
Constraint_System minimized_constraints() const
Returns a minimal system of equality constraints satisfied by *this with the same affine dimension as...
static void conversion(Congruence_System &source, Grid_Generator_System &dest, Dimension_Kinds &dim_kinds)
Converts generator system dest to be equivalent to congruence system source.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
static bool can_recycle_constraint_systems()
Returns true indicating that this domain has methods that can recycle constraints.
int32_t hash_code() const
Returns a 32-bit hash code for *this.
A conjunctive assertion about a grid.
Definition: Grid_defs.hh:72
bool is_disjoint_from(const Grid &y) const
Returns true if and only if *this and y are disjoint.
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 . ...
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
void add_constraint_no_check(const Constraint &c)
Uses the constraint c to refine *this.
bool is_discrete() const
Returns true if and only if *this is discrete.
Definition: Grid_public.cc:836
void widening_assign(const Grid &y, unsigned *tp=NULL)
Assigns to *this the result of computing the Grid widening between *this and y.
void add_congruences(const Congruence_System &cgs)
Adds a copy of each congruence in cgs to *this.
Poly_Con_Relation relation_with(const Congruence &cg) const
Returns the relations holding between *this and cg.
Definition: Grid_public.cc:386
bool contains_integer_point() const
Returns true if and only if *this contains at least one integer point.
Definition: Grid_public.cc:861
Coefficient coefficient_type
The numeric type of coefficients.
Definition: Grid_defs.hh:366
void refine_with_constraints(const Constraint_System &cs)
Uses a copy of the constraints in cs to refine *this.
static bool simplify(Congruence_System &cgs, Dimension_Kinds &dim_kinds)
Converts cgs to upper triangular (i.e. minimized) form.
bool congruences_are_up_to_date() const
Returns true if the system of congruences is up-to-date.
Definition: Grid_inlines.hh:40
bool strictly_contains(const Grid &y) const
Returns true if and only if *this strictly contains y.
void clear_congruences_up_to_date()
Sets status to express that congruences are out of date.
Definition: Grid_inlines.hh:97
static void normalize_divisors(Grid_Generator_System &sys, Coefficient &divisor, const Grid_Generator *first_point=NULL)
Normalizes the divisors in sys.
void refine_with_congruence(const Congruence &cg)
Uses a copy of the congruence cg to refine *this.
void time_elapse_assign(const Grid &y)
Assigns to *this the result of computing the time-elapse between *this and y.
void set_generators_minimized()
Sets status to express that generators are minimized.
Definition: Grid_inlines.hh:76
void throw_dimension_incompatible(const char *method, const char *other_name, dimension_type other_dim) const
A dimension of the vector space.
bool simplify_using_context_assign(const Grid &y)
Assigns to *this a meet-preserving simplification of *this with respect to y. If false is returned...
Complexity_Class
Complexity pseudo-classes.
void add_recycled_grid_generators(Grid_Generator_System &gs)
Adds the generators in gs to the system of generators of this.
The base class for convex polyhedra.
Three_Valued_Boolean quick_equivalence_test(const Grid &y) const
Polynomial but incomplete equivalence test between grids.
bool upper_bound_assign_if_exact(const Grid &y)
If the upper bound of *this and y is exact it is assigned to this and true is returned, otherwise false is returned.
#define PPL_OUTPUT_DECLARATIONS
bool max_min(const Linear_Expression &expr, const char *method_call, Coefficient &ext_n, Coefficient &ext_d, bool &included, Generator *point=NULL) const
Maximizes or minimizes expr subject to *this.
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
Definition: Grid_public.cc:958
void intersection_assign(const Grid &y)
Assigns to *this the intersection of *this and y.
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...
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
Definition: Grid_chdims.cc:273
static void reduce_reduced(Swapping_Vector< typename M::row_type > &sys, dimension_type dim, dimension_type pivot_index, dimension_type start, dimension_type end, const Dimension_Kinds &sys_dim_kinds, bool generators=true)
Reduce column dim in rows preceding pivot_index in sys.
Relation_Symbol
Relation symbols.
bool bounds(const Linear_Expression &expr, const char *method_call) const
Checks if and how expr is bounded in *this.
Degenerate_Element
Kinds of degenerate abstract elements.
static bool can_recycle_congruence_systems()
Returns true indicating that this domain has methods that can recycle congruences.
std::vector< Dimension_Kind > Dimension_Kinds
Definition: Grid_defs.hh:1994
const Congruence_System & minimized_congruences() const
Returns the system of congruences in minimal form.
Definition: Grid_public.cc:319
bool is_topologically_closed() const
Returns true if and only if *this is a topologically closed subset of the vector space.
Definition: Grid_public.cc:856
void limited_congruence_extrapolation_assign(const Grid &y, const Congruence_System &cgs, unsigned *tp=NULL)
Improves the result of the congruence variant of Grid widening computation by also enforcing those co...
void set_generators_up_to_date()
Sets status to express that generators are up-to-date.
Definition: Grid_inlines.hh:60
void add_grid_generator(const Grid_Generator &g)
Adds a copy of grid generator g to the system of generators of *this.
void refine_with_congruences(const Congruence_System &cgs)
Uses a copy of the congruences in cgs to refine *this.
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 ...
void refine_no_check(const Constraint &c)
Uses the constraint c to refine *this.
A not necessarily closed, iso-oriented hyperrectangle.
Definition: Box_defs.hh:299
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
const Grid_Generator_System & grid_generators() const
Returns the system of generators.
Definition: Grid_public.cc:334
bool contains(const Grid &y) const
Returns true if and only if *this contains y.
bool frequency_no_check(const Linear_Expression &expr, Coefficient &freq_n, Coefficient &freq_d, Coefficient &val_n, Coefficient &val_d) const
Returns true if and only if *this is not empty and frequency for *this with respect to expr is define...
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.
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
void select_wider_generators(const Grid &y, Grid_Generator_System &widened_ggs) const
Copies widened generators from y to widened_ggs.
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
Definition: Grid_inlines.hh:45
void set_zero_dim_univ()
Sets status to express that the grid is the universe 0-dimension vector space, clearing all correspon...
The universe element, i.e., the whole vector space.
dimension_type space_dim
The number of dimensions of the enclosing vector space.
Definition: Grid_defs.hh:1983
Coefficient_traits::const_reference Coefficient_zero()
Returns a const reference to a Coefficient with value 0.
Constraint_System constraints() const
Returns a system of equality constraints satisfied by *this with the same affine dimension as *this...
The entire library is confined to this namespace.
Definition: version.hh:61
void refine_with_constraint(const Constraint &c)
Uses a copy of the constraint c to refine *this.
dimension_type affine_dimension() const
Returns , if *this is empty; otherwise, returns the affine dimension of *this.
Definition: Grid_public.cc:273
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
Definition: Grid_chdims.cc:458
static void throw_invalid_generators(const char *method, const char *gs_name)
bool marked_empty() const
Returns true if the grid is known to be empty.
Definition: Grid_inlines.hh:35
static bool rows_are_zero(M &system, dimension_type first, dimension_type last, dimension_type row_size)
Checks that trailing rows contain only zero terms.
static bool upper_triangular(const Grid_Generator_System &sys, const Dimension_Kinds &dim_kinds)
If sys is upper triangular return true, else return false.
bool congruences_are_minimized() const
Returns true if the system of congruences is minimized.
Definition: Grid_inlines.hh:50
A bounded difference shape.
void add_congruence(const Congruence &cg)
Adds a copy of congruence cg to *this.
static void throw_invalid_constraints(const char *method, const char *cs_name)
void clear_empty()
Clears the status flag indicating that the grid is empty.
Definition: Grid_inlines.hh:82
bool frequency(const Linear_Expression &expr, Coefficient &freq_n, Coefficient &freq_d, Coefficient &val_n, Coefficient &val_d) const
Returns true if and only if *this is not empty and frequency for *this with respect to expr is define...
void add_constraint(const Constraint &c)
Adds to *this a congruence equivalent to constraint c.
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.
static void throw_invalid_argument(const char *method, const char *reason)
void add_recycled_constraints(Constraint_System &cs)
Adds to *this congruences equivalent to the constraints in cs.
static void reduce_equality_with_equality(Congruence &row, const Congruence &pivot, dimension_type column)
Reduces the equality row using the equality pivot.
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Grid can handle.
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
bool is_bounded() const
Returns true if and only if *this is bounded.
Definition: Grid_public.cc:810
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
void update_congruences() const
Updates and minimizes the congruences from the generators.
static bool lower_triangular(const Congruence_System &sys, const Dimension_Kinds &dim_kinds)
If sys is lower triangular return true, else return false.
static void reduce_congruence_with_equality(Congruence &row, const Congruence &pivot, dimension_type column, Swapping_Vector< Congruence > &sys)
Reduce row using pivot.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded in *this.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void add_grid_generators(const Grid_Generator_System &gs)
Adds a copy of the generators in gs to the system of generators of *this.
Coefficient c
Definition: PIP_Tree.cc:64
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the grid and does not embed it in the new vector space.
Definition: Grid_chdims.cc:154
void generalized_affine_preimage(Variable var, Relation_Symbol relsym, const Linear_Expression &expr, Coefficient_traits::const_reference denominator=Coefficient_one(), Coefficient_traits::const_reference modulus=Coefficient_zero())
Assigns to *this the preimage of *this with respect to the generalized affine relation ...
static void reduce_parameter_with_line(Grid_Generator &row, const Grid_Generator &pivot, dimension_type column, Swapping_Vector< Grid_Generator > &sys, dimension_type num_columns)
Reduce row using pivot.
void set_congruences_up_to_date()
Sets status to express that congruences are up-to-date.
Definition: Grid_inlines.hh:65
static void multiply_grid(const Coefficient &multiplier, Congruence &cg, Swapping_Vector< Congruence > &dest, dimension_type num_rows)
Multiply the elements of dest by multiplier.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
void m_swap(Grid &y)
Swaps *this with grid y. (*this and y can be dimension-incompatible.)
bool generators_are_minimized() const
Returns true if the system of generators is minimized.
Definition: Grid_inlines.hh:55
Grid & operator=(const Grid &y)
The assignment operator. (*this and y can be dimension-incompatible.)
Definition: Grid_public.cc:251
void select_wider_congruences(const Grid &y, Congruence_System &selected_cgs) const
Copies a widened selection of congruences from y to selected_cgs.
bool bounds_no_check(const Linear_Expression &expr) const
Checks if and how expr is bounded in *this.
void concatenate_assign(const Grid &y)
Assigns to *this the concatenation of *this and y, taken in this order.
Definition: Grid_chdims.cc:225
void add_recycled_congruences(Congruence_System &cgs)
Adds the congruences in cgs to *this.
static void throw_invalid_constraint(const char *method, const char *c_name)
void construct(dimension_type num_dimensions, Degenerate_Element kind)
Builds a grid universe or empty grid.
void upper_bound_assign(const Grid &y)
Assigns to *this the least upper bound of *this and y.
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...
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
The relation between a polyhedron and a generator.
bool update_generators() const
Updates and minimizes the generators from the congruences.
A grid line, parameter or grid point.
void set_congruences_minimized()
Sets status to express that congruences are minimized.
Definition: Grid_inlines.hh:70
bool is_empty() const
Returns true if and only if *this is an empty grid.
Definition: Grid_public.cc:742
void topological_closure_assign()
Assigns to *this its topological closure.
The relation between a polyhedron and a constraint.
static void reduce_line_with_line(Grid_Generator &row, Grid_Generator &pivot, dimension_type column)
Reduces the line row using the line pivot.
bool minimize() const
Minimizes both the congruences and the generators.