PPL  1.2
Polyhedron_defs.hh
Go to the documentation of this file.
1 /* Polyhedron 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_Polyhedron_defs_hh
25 #define PPL_Polyhedron_defs_hh 1
26 
27 #include "Polyhedron_types.hh"
28 #include "globals_types.hh"
29 #include "Variable_defs.hh"
30 #include "Variables_Set_types.hh"
34 #include "Generator_System_defs.hh"
38 #include "Bit_Matrix_defs.hh"
39 #include "Constraint_types.hh"
40 #include "Generator_types.hh"
41 #include "Congruence_types.hh"
45 #include "H79_Certificate_types.hh"
46 #include "Box_types.hh"
47 #include "BD_Shape_types.hh"
48 #include "Octagonal_Shape_types.hh"
49 #include "Interval_types.hh"
50 #include "Linear_Form_types.hh"
51 #include <vector>
52 #include <iosfwd>
53 
54 namespace Parma_Polyhedra_Library {
55 
56 namespace IO_Operators {
57 
59 
67 std::ostream&
68 operator<<(std::ostream& s, const Polyhedron& ph);
69 
70 } // namespace IO_Operators
71 
73 
74 void swap(Polyhedron& x, Polyhedron& y);
75 
84 bool operator==(const Polyhedron& x, const Polyhedron& y);
85 
94 bool operator!=(const Polyhedron& x, const Polyhedron& y);
95 
96 namespace Interfaces {
97 
98 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
99 
103 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
104 bool is_necessarily_closed_for_interfaces(const Polyhedron& ph);
105 
106 } // namespace Interfaces
107 
108 } // namespace Parma_Polyhedra_Library
109 
110 
112 
370 public:
373 
376 
381  static bool can_recycle_constraint_systems();
382 
384  static void initialize();
385 
387  static void finalize();
388 
392  static bool can_recycle_congruence_systems();
393 
394 protected:
396 
406  Polyhedron(Topology topol,
407  dimension_type num_dimensions,
408  Degenerate_Element kind);
409 
411 
414  Polyhedron(const Polyhedron& y,
415  Complexity_Class complexity = ANY_COMPLEXITY);
416 
418 
430  Polyhedron(Topology topol, const Constraint_System& cs);
431 
433 
452 
454 
467  Polyhedron(Topology topol, const Generator_System& gs);
468 
470 
490 
492 
505  template <typename Interval>
506  Polyhedron(Topology topol, const Box<Interval>& box,
507  Complexity_Class complexity = ANY_COMPLEXITY);
508 
513  Polyhedron& operator=(const Polyhedron& y);
514 
515 public:
517 
518 
521 
528 
530  const Constraint_System& constraints() const;
531 
534 
536  const Generator_System& generators() const;
537 
539  const Generator_System& minimized_generators() const;
540 
543 
550 
559 
567  Poly_Gen_Relation relation_with(const Generator& g) const;
568 
576  Poly_Con_Relation relation_with(const Congruence& cg) const;
577 
582  bool is_empty() const;
583 
588  bool is_universe() const;
589 
594  bool is_topologically_closed() const;
595 
597 
602  bool is_disjoint_from(const Polyhedron& y) const;
603 
605  bool is_discrete() const;
606 
611  bool is_bounded() const;
612 
617  bool contains_integer_point() const;
618 
626  bool constrains(Variable var) const;
627 
635  bool bounds_from_above(const Linear_Expression& expr) const;
636 
644  bool bounds_from_below(const Linear_Expression& expr) const;
645 
670  bool maximize(const Linear_Expression& expr,
671  Coefficient& sup_n, Coefficient& sup_d, bool& maximum) const;
672 
701  bool maximize(const Linear_Expression& expr,
702  Coefficient& sup_n, Coefficient& sup_d, bool& maximum,
703  Generator& g) const;
704 
729  bool minimize(const Linear_Expression& expr,
730  Coefficient& inf_n, Coefficient& inf_d, bool& minimum) const;
731 
760  bool minimize(const Linear_Expression& expr,
761  Coefficient& inf_n, Coefficient& inf_d, bool& minimum,
762  Generator& g) const;
763 
792  bool frequency(const Linear_Expression& expr,
793  Coefficient& freq_n, Coefficient& freq_d,
794  Coefficient& val_n, Coefficient& val_d) const;
795 
797 
802  bool contains(const Polyhedron& y) const;
803 
805 
810  bool strictly_contains(const Polyhedron& y) const;
811 
813 
829  bool OK(bool check_not_empty = false) const;
830 
832 
834 
835 
848  void add_constraint(const Constraint& c);
849 
859  void add_generator(const Generator& g);
860 
870  void add_congruence(const Congruence& cg);
871 
884  void add_constraints(const Constraint_System& cs);
885 
903 
917  void add_generators(const Generator_System& gs);
918 
937 
950  void add_congruences(const Congruence_System& cgs);
951 
969 
976  void refine_with_constraint(const Constraint& c);
977 
984  void refine_with_congruence(const Congruence& cg);
985 
997 
1008  void refine_with_congruences(const Congruence_System& cgs);
1009 
1035  template <typename FP_Format, typename Interval_Info>
1039  bool is_strict = false);
1040 
1069  template <typename FP_Format, typename Interval_Info>
1073  Relation_Symbol relsym);
1074 
1076 
1080  template <typename FP_Format, typename Interval_Info>
1083  const;
1084 
1095  void unconstrain(Variable var);
1096 
1109  void unconstrain(const Variables_Set& vars);
1110 
1118  void intersection_assign(const Polyhedron& y);
1119 
1127  void poly_hull_assign(const Polyhedron& y);
1128 
1130  void upper_bound_assign(const Polyhedron& y);
1131 
1141  void poly_difference_assign(const Polyhedron& y);
1142 
1144  void difference_assign(const Polyhedron& y);
1145 
1156 
1246  void affine_image(Variable var,
1247  const Linear_Expression& expr,
1248  Coefficient_traits::const_reference denominator
1249  = Coefficient_one());
1250 
1251  // FIXME: To be completed.
1273  template <typename FP_Format, typename Interval_Info>
1274  void affine_form_image(Variable var,
1276 
1364  void affine_preimage(Variable var,
1365  const Linear_Expression& expr,
1366  Coefficient_traits::const_reference denominator
1367  = Coefficient_one());
1368 
1396  Relation_Symbol relsym,
1397  const Linear_Expression& expr,
1398  Coefficient_traits::const_reference denominator
1399  = Coefficient_one());
1400 
1427  void
1429  Relation_Symbol relsym,
1430  const Linear_Expression& expr,
1431  Coefficient_traits::const_reference denominator
1432  = Coefficient_one());
1433 
1455  Relation_Symbol relsym,
1456  const Linear_Expression& rhs);
1457 
1479  Relation_Symbol relsym,
1480  const Linear_Expression& rhs);
1481 
1508  void bounded_affine_image(Variable var,
1509  const Linear_Expression& lb_expr,
1510  const Linear_Expression& ub_expr,
1511  Coefficient_traits::const_reference denominator
1512  = Coefficient_one());
1513 
1541  const Linear_Expression& lb_expr,
1542  const Linear_Expression& ub_expr,
1543  Coefficient_traits::const_reference denominator
1544  = Coefficient_one());
1545 
1554  void time_elapse_assign(const Polyhedron& y);
1555 
1565  void positive_time_elapse_assign(const Polyhedron& y);
1566 
1613  void wrap_assign(const Variables_Set& vars,
1617  const Constraint_System* cs_p = 0,
1618  unsigned complexity_threshold = 16,
1619  bool wrap_individually = true);
1620 
1633  = ANY_COMPLEXITY);
1634 
1651  Complexity_Class complexity
1652  = ANY_COMPLEXITY);
1653 
1656 
1673  void BHRZ03_widening_assign(const Polyhedron& y, unsigned* tp = 0);
1674 
1697  const Constraint_System& cs,
1698  unsigned* tp = 0);
1699 
1722  const Constraint_System& cs,
1723  unsigned* tp = 0);
1724 
1741  void H79_widening_assign(const Polyhedron& y, unsigned* tp = 0);
1742 
1744  void widening_assign(const Polyhedron& y, unsigned* tp = 0);
1745 
1768  const Constraint_System& cs,
1769  unsigned* tp = 0);
1770 
1793  const Constraint_System& cs,
1794  unsigned* tp = 0);
1795 
1797 
1799 
1800 
1827 
1854 
1866  void concatenate_assign(const Polyhedron& y);
1867 
1869 
1878  void remove_space_dimensions(const Variables_Set& vars);
1879 
1888  void remove_higher_space_dimensions(dimension_type new_dimension);
1889 
1930  template <typename Partial_Function>
1931  void map_space_dimensions(const Partial_Function& pfunc);
1932 
1934 
1955 
1957 
1979  void fold_space_dimensions(const Variables_Set& vars, Variable dest);
1980 
1982 
1983  friend bool operator==(const Polyhedron& x, const Polyhedron& y);
1984 
1986 
1987 
1989  ~Polyhedron();
1990 
1998  void m_swap(Polyhedron& y);
1999 
2001 
2007  bool ascii_load(std::istream& s);
2008 
2011 
2014 
2021  int32_t hash_code() const;
2022 
2024 
2025 private:
2028 
2031 
2034 
2037 
2040 
2041 #define PPL_IN_Polyhedron_CLASS
2042 #include "Ph_Status_idefs.hh"
2043 #undef PPL_IN_Polyhedron_CLASS
2044 
2047 
2050 
2052  Topology topology() const;
2053 
2058  bool is_necessarily_closed() const;
2059 
2060  friend bool
2063 
2071  void refine_no_check(const Constraint& c);
2072 
2074 
2075 
2077 
2081  bool marked_empty() const;
2082 
2084  bool constraints_are_up_to_date() const;
2085 
2087  bool generators_are_up_to_date() const;
2088 
2090 
2094  bool constraints_are_minimized() const;
2095 
2097 
2101  bool generators_are_minimized() const;
2102 
2104  bool has_pending_constraints() const;
2105 
2107  bool has_pending_generators() const;
2108 
2113  bool has_something_pending() const;
2114 
2116  bool can_have_something_pending() const;
2117 
2122  bool sat_c_is_up_to_date() const;
2123 
2128  bool sat_g_is_up_to_date() const;
2129 
2131 
2133 
2134 
2139  void set_zero_dim_univ();
2140 
2145  void set_empty();
2146 
2149 
2152 
2155 
2157  void set_generators_minimized();
2158 
2160  void set_constraints_pending();
2161 
2163  void set_generators_pending();
2164 
2166  void set_sat_c_up_to_date();
2167 
2169  void set_sat_g_up_to_date();
2170 
2172 
2174 
2175 
2177  void clear_empty();
2178 
2180 
2185 
2187 
2192 
2195 
2198 
2201 
2203  void clear_pending_generators();
2204 
2206  void clear_sat_c_up_to_date();
2207 
2209  void clear_sat_g_up_to_date();
2210 
2212 
2214 
2215 
2227  bool process_pending() const;
2228 
2230 
2237  bool process_pending_constraints() const;
2238 
2240 
2243  void process_pending_generators() const;
2244 
2253 
2266 
2268 
2270 
2271 
2273 
2278  void update_constraints() const;
2279 
2281 
2292  bool update_generators() const;
2293 
2295 
2309  void update_sat_c() const;
2310 
2312 
2326  void update_sat_g() const;
2327 
2329 
2338  void obtain_sorted_constraints() const;
2339 
2341 
2350  void obtain_sorted_generators() const;
2351 
2353 
2361 
2363 
2371 
2373 
2375 
2376 
2378 
2386  bool minimize() const;
2387 
2389 
2394  bool strongly_minimize_constraints() const;
2395 
2397 
2402  bool strongly_minimize_generators() const;
2403 
2406 
2408 
2413  };
2414 
2417 
2419  bool is_included_in(const Polyhedron& y) const;
2420 
2422 
2438  bool bounds(const Linear_Expression& expr, bool from_above) const;
2439 
2441 
2471  bool max_min(const Linear_Expression& expr,
2472  bool maximize,
2473  Coefficient& ext_n, Coefficient& ext_d, bool& included,
2474  Generator& g) const;
2475 
2477 
2478 
2483  void select_CH78_constraints(const Polyhedron& y,
2484  Constraint_System& cs_selection) const;
2485 
2491  void select_H79_constraints(const Polyhedron& y,
2492  Constraint_System& cs_selected,
2493  Constraint_System& cs_not_selected) const;
2494 
2496  const BHRZ03_Certificate& y_cert,
2497  const Polyhedron& H79,
2498  const Constraint_System& x_minus_H79_cs);
2499 
2500  bool BHRZ03_evolving_points(const Polyhedron& y,
2501  const BHRZ03_Certificate& y_cert,
2502  const Polyhedron& H79);
2503 
2504  bool BHRZ03_evolving_rays(const Polyhedron& y,
2505  const BHRZ03_Certificate& y_cert,
2506  const Polyhedron& H79);
2507 
2509  const Linear_Expression& x,
2510  const Linear_Expression& y);
2511 
2513 
2515 
2542  template <typename Linear_System1, typename Linear_System2>
2543  static void add_space_dimensions(Linear_System1& sys1,
2544  Linear_System2& sys2,
2545  Bit_Matrix& sat1,
2546  Bit_Matrix& sat2,
2547  dimension_type add_dim);
2548 
2550 
2551 
2553  // Detailed Doxygen comment to be found in file minimize.cc.
2554  template <typename Source_Linear_System, typename Dest_Linear_System>
2555  static bool minimize(bool con_to_gen,
2556  Source_Linear_System& source,
2557  Dest_Linear_System& dest,
2558  Bit_Matrix& sat);
2559 
2564  // Detailed Doxygen comment to be found in file minimize.cc.
2565  template <typename Source_Linear_System1, typename Source_Linear_System2,
2566  typename Dest_Linear_System>
2567  static bool add_and_minimize(bool con_to_gen,
2568  Source_Linear_System1& source1,
2569  Dest_Linear_System& dest,
2570  Bit_Matrix& sat,
2571  const Source_Linear_System2& source2);
2572 
2577  // Detailed Doxygen comment to be found in file minimize.cc.
2578  template <typename Source_Linear_System, typename Dest_Linear_System>
2579  static bool add_and_minimize(bool con_to_gen,
2580  Source_Linear_System& source,
2581  Dest_Linear_System& dest,
2582  Bit_Matrix& sat);
2583 
2585  // Detailed Doxygen comment to be found in file conversion.cc.
2586  template <typename Source_Linear_System, typename Dest_Linear_System>
2587  static dimension_type conversion(Source_Linear_System& source,
2588  dimension_type start,
2589  Dest_Linear_System& dest,
2590  Bit_Matrix& sat,
2591  dimension_type num_lines_or_equalities);
2592 
2597  // Detailed Doxygen comment to be found in file simplify.cc.
2598  template <typename Linear_System1>
2599  static dimension_type simplify(Linear_System1& sys, Bit_Matrix& sat);
2600 
2602 
2611 
2619 
2620  template <typename Interval> friend class Parma_Polyhedra_Library::Box;
2621  template <typename T> friend class Parma_Polyhedra_Library::BD_Shape;
2622  template <typename T> friend class Parma_Polyhedra_Library::Octagonal_Shape;
2626 
2627 protected:
2628 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2629 
2643 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2645 
2649 
2650 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2651 
2653 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2654 protected:
2655  void throw_invalid_argument(const char* method, const char* reason) const;
2656 
2657  void throw_topology_incompatible(const char* method,
2658  const char* ph_name,
2659  const Polyhedron& ph) const;
2660  void throw_topology_incompatible(const char* method,
2661  const char* c_name,
2662  const Constraint& c) const;
2663  void throw_topology_incompatible(const char* method,
2664  const char* g_name,
2665  const Generator& g) const;
2666  void throw_topology_incompatible(const char* method,
2667  const char* cs_name,
2668  const Constraint_System& cs) const;
2669  void throw_topology_incompatible(const char* method,
2670  const char* gs_name,
2671  const Generator_System& gs) const;
2672 
2673  void throw_dimension_incompatible(const char* method,
2674  const char* other_name,
2675  dimension_type other_dim) const;
2676  void throw_dimension_incompatible(const char* method,
2677  const char* ph_name,
2678  const Polyhedron& ph) const;
2679  void throw_dimension_incompatible(const char* method,
2680  const char* le_name,
2681  const Linear_Expression& le) const;
2682  void throw_dimension_incompatible(const char* method,
2683  const char* c_name,
2684  const Constraint& c) const;
2685  void throw_dimension_incompatible(const char* method,
2686  const char* g_name,
2687  const Generator& g) const;
2688  void throw_dimension_incompatible(const char* method,
2689  const char* cg_name,
2690  const Congruence& cg) const;
2691  void throw_dimension_incompatible(const char* method,
2692  const char* cs_name,
2693  const Constraint_System& cs) const;
2694  void throw_dimension_incompatible(const char* method,
2695  const char* gs_name,
2696  const Generator_System& gs) const;
2697  void throw_dimension_incompatible(const char* method,
2698  const char* cgs_name,
2699  const Congruence_System& cgs) const;
2700  template <typename C>
2701  void throw_dimension_incompatible(const char* method,
2702  const char* lf_name,
2703  const Linear_Form<C>& lf) const;
2704  void throw_dimension_incompatible(const char* method,
2705  const char* var_name,
2706  Variable var) const;
2707  void throw_dimension_incompatible(const char* method,
2708  dimension_type required_space_dim) const;
2709 
2710  // Note: the following three methods need to be static, because they
2711  // can be called inside constructors (before actually constructing the
2712  // polyhedron object).
2713  static dimension_type
2715  const Topology topol,
2716  const char* method, const char* reason);
2717 
2718  static dimension_type
2720  const char* method, const char* reason);
2721 
2722  template <typename Object>
2723  static Object&
2724  check_obj_space_dimension_overflow(Object& input, Topology topol,
2725  const char* method, const char* reason);
2726 
2727  void throw_invalid_generator(const char* method,
2728  const char* g_name) const;
2729 
2730  void throw_invalid_generators(const char* method,
2731  const char* gs_name) const;
2732 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
2733 
2734 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
2735 
2751  void drop_some_non_integer_points(const Variables_Set* vars_p,
2752  Complexity_Class complexity);
2753 
2755 
2772  template <typename FP_Format, typename Interval_Info>
2775  const dimension_type lf_dimension,
2777 
2797  template <typename FP_Format, typename Interval_Info>
2798  static void convert_to_integer_expression(
2800  const dimension_type lf_dimension,
2801  Linear_Expression& result);
2802 
2804 
2829  template <typename FP_Format, typename Interval_Info>
2830  static void
2832  Interval_Info> >&
2833  lf,
2834  const dimension_type lf_dimension,
2835  Linear_Expression& res,
2836  Coefficient& res_low_coeff,
2837  Coefficient& res_hi_coeff,
2838  Coefficient& denominator);
2839 
2840  template <typename Linear_System1, typename Row2>
2841  static bool
2842  add_to_system_and_check_independence(Linear_System1& eq_sys,
2843  const Row2& eq);
2844 
2853 };
2854 
2855 #include "Ph_Status_inlines.hh"
2856 #include "Polyhedron_inlines.hh"
2857 #include "Polyhedron_templates.hh"
2862 
2863 #endif // !defined(PPL_Polyhedron_defs_hh)
void add_space_dimensions_and_embed(dimension_type m)
Adds m new space dimensions and embeds the old polyhedron in the new vector space.
bool has_pending_constraints() const
Returns true if there are pending constraints.
bool constraints_are_minimized() const
Returns true if the system of constraints is minimized.
void topological_closure_assign()
Assigns to *this its topological closure.
void refine_with_congruence(const Congruence &cg)
Uses a copy of 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 widening_assign(const Polyhedron &y, unsigned *tp=0)
Same as H79_widening_assign(y, tp).
bool marked_empty() const
Returns true if the polyhedron is known to be empty.
bool operator!=(const Box< ITV > &x, const Box< ITV > &y)
Definition: Box_inlines.hh:264
int32_t hash_code() const
Returns a 32-bit hash code for *this.
void map_space_dimensions(const Partial_Function &pfunc)
Remaps the dimensions of the vector space according to a partial function.
void set_sat_g_up_to_date()
Sets status to express that sat_g is up-to-date.
A linear equality or inequality.
bool bounds_from_above(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from above in *this.
void swap(CO_Tree &x, CO_Tree &y)
bool minimize() const
Applies (weak) minimization to both the constraints and generators.
void clear_constraints_up_to_date()
Sets status to express that constraints are no longer up-to-date.
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 strongly_minimize_constraints() const
Applies strong minimization to the constraints of an NNC polyhedron.
void select_CH78_constraints(const Polyhedron &y, Constraint_System &cs_selection) const
Copies to cs_selection the constraints of y corresponding to the definition of the CH78-widening of *...
bool remove_pending_to_obtain_generators() const
Lazily integrates the pending descriptions of the polyhedron to obtain a generator system without pen...
size_t dimension_type
An unsigned integral type for representing space dimensions.
void update_constraints() const
Updates constraints starting from generators and minimizes them.
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
bool max_min(const Linear_Expression &expr, bool maximize, Coefficient &ext_n, Coefficient &ext_d, bool &included, Generator &g) const
Maximizes or minimizes expr subject to *this.
An std::set of variables' indexes.
bool constrains(Variable var) const
Returns true if and only if var is constrained in *this.
void poly_difference_assign(const Polyhedron &y)
Assigns to *this the poly-difference of *this and y.
Generator_System gen_sys
The system of generators.
A line, ray, point or closure point.
bool generators_are_minimized() const
Returns true if the system of generators is minimized.
bool is_empty() const
Returns true if and only if *this is an empty polyhedron.
void set_generators_up_to_date()
Sets status to express that generators are up-to-date.
Congruence_System minimized_congruences() const
Returns a system of (equality) congruences satisfied by *this, with no redundant congruences and havi...
void set_constraints_pending()
Sets status to express that constraints are pending.
void clear_pending_generators()
Sets status to express that there are no longer pending generators.
void add_congruences(const Congruence_System &cgs)
Adds a copy of the congruences in cgs to *this, if all the congruences can be exactly represented by ...
void add_constraint(const Constraint &c)
Adds a copy of constraint c to the system of constraints of *this (without minimizing the result)...
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 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...
std::ostream & operator<<(std::ostream &s, const Ask_Tell< D > &x)
bool contains_integer_point() const
Returns true if and only if *this contains at least one integer point.
bool strongly_minimize_generators() const
Applies strong minimization to the generators of an NNC polyhedron.
bool is_disjoint_from(const Polyhedron &y) const
Returns true if and only if *this and y are disjoint.
void generalized_refine_with_linear_form_inequality(const Linear_Form< Interval< FP_Format, Interval_Info > > &left, const Linear_Form< Interval< FP_Format, Interval_Info > > &right, Relation_Symbol relsym)
Refines *this with the constraint expressed by left right, where is the relation symbol specified b...
static bool can_recycle_congruence_systems()
Returns false indicating that this domain cannot recycle congruences.
void BHRZ03_widening_assign(const Polyhedron &y, unsigned *tp=0)
Assigns to *this the result of computing the BHRZ03-widening between *this and y. ...
bool sat_c_is_up_to_date() const
Returns true if the saturation matrix sat_c is up-to-date.
bool update_generators() const
Updates generators starting from constraints and minimizes them.
void add_space_dimensions_and_project(dimension_type m)
Adds m new space dimensions to the polyhedron and does not embed it in the new vector space...
void set_constraints_up_to_date()
Sets status to express that constraints are up-to-date.
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the vector space.
static bool add_to_system_and_check_independence(Linear_System1 &eq_sys, const Row2 &eq)
bool sat_g_is_up_to_date() const
Returns true if the saturation matrix sat_g is up-to-date.
void throw_dimension_incompatible(const char *method, const char *other_name, dimension_type other_dim) const
bool strictly_contains(const Polyhedron &y) const
Returns true if and only if *this strictly contains y.
const Constraint_System & constraints() const
Returns the system of constraints.
void H79_widening_assign(const Polyhedron &y, unsigned *tp=0)
Assigns to *this the result of computing the H79_widening between *this and y.
bool bounds_from_below(const Linear_Expression &expr) const
Returns true if and only if expr is bounded from below in *this.
bool is_topologically_closed() const
Returns true if and only if *this is a topologically closed subset of the vector space.
Polyhedron & operator=(const Polyhedron &y)
The assignment operator. (*this and y can be dimension-incompatible.)
void obtain_sorted_constraints() const
Sorts the matrix of constraints keeping status consistency.
Polyhedron(Topology topol, dimension_type num_dimensions, Degenerate_Element kind)
Builds a polyhedron having the specified properties.
bool BFT00_poly_hull_assign_if_exact(const Polyhedron &y)
If the poly-hull of *this and y is exact it is assigned to *this and true is returned, otherwise false is returned.
static dimension_type simplify(Linear_System1 &sys, Bit_Matrix &sat)
Uses Gauss' elimination method to simplify the result of conversion().
void limited_BHRZ03_extrapolation_assign(const Polyhedron &y, const Constraint_System &cs, unsigned *tp=0)
Assigns to *this the result of computing the limited extrapolation between *this and y using the BHRZ...
static Object & check_obj_space_dimension_overflow(Object &input, Topology topol, const char *method, const char *reason)
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_with_linear_form_inequality(const Linear_Form< Interval< FP_Format, Interval_Info > > &left, const Linear_Form< Interval< FP_Format, Interval_Info > > &right, bool is_strict=false)
Refines *this with the constraint expressed by left right if is_strict is set, with the constraint l...
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 there exist a unique value val such that *this saturates the equality exp...
void add_recycled_constraints(Constraint_System &cs)
Adds the constraints in cs to the system of constraints of *this (without minimizing the result)...
void add_recycled_congruences(Congruence_System &cgs)
Adds the congruences in cgs to *this, if all the congruences can be exactly represented by a polyhedr...
bool can_have_something_pending() const
Returns true if the polyhedron can have something pending.
void refine_with_constraint(const Constraint &c)
Uses a copy of constraint c to refine *this.
A dimension of the vector space.
static dimension_type conversion(Source_Linear_System &source, dimension_type start, Dest_Linear_System &dest, Bit_Matrix &sat, dimension_type num_lines_or_equalities)
Performs the conversion from constraints to generators and vice versa.
Complexity_Class
Complexity pseudo-classes.
The base class for convex polyhedra.
void limited_H79_extrapolation_assign(const Polyhedron &y, const Constraint_System &cs, unsigned *tp=0)
Assigns to *this the result of computing the limited extrapolation between *this and y using the H79-...
void set_sat_c_up_to_date()
Sets status to express that sat_c is up-to-date.
static void modify_according_to_evolution(Linear_Expression &ray, const Linear_Expression &x, const Linear_Expression &y)
bool BHZ09_C_poly_hull_assign_if_exact(const Polyhedron &y)
void update_sat_g() const
Updates sat_g using the updated constraints and generators.
Constraint_System simplified_constraints() const
If constraints are up-to-date, obtain a simplified copy of them.
#define PPL_OUTPUT_DECLARATIONS
void affine_form_image(Variable var, const Linear_Form< Interval< FP_Format, Interval_Info > > &lf)
void add_recycled_generators(Generator_System &gs)
Adds the generators in gs to the system of generators of *this (without minimizing the result)...
void throw_invalid_generators(const char *method, const char *gs_name) const
Topology topology() const
Returns the topological kind of the polyhedron.
bool generators_are_up_to_date() const
Returns true if the system of generators is up-to-date.
void add_generators(const Generator_System &gs)
Adds a copy of the generators in gs to the system of generators of *this (without minimizing the resu...
void throw_invalid_argument(const char *method, const char *reason) const
Constraint_System con_sys
The system of constraints.
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
static void finalize()
Finalizes the class.
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...
bool process_pending() const
Processes the pending rows of either description of the polyhedron and obtains a minimized polyhedron...
static void convert_to_integer_expressions(const Linear_Form< Interval< FP_Format, Interval_Info > > &lf, const dimension_type lf_dimension, Linear_Expression &res, Coefficient &res_low_coeff, Coefficient &res_hi_coeff, Coefficient &denominator)
Normalization helper function.
void clear_pending_constraints()
Sets status to express that there are no longer pending constraints.
static dimension_type check_space_dimension_overflow(dimension_type dim, dimension_type max, const Topology topol, const char *method, const char *reason)
bool is_universe() const
Returns true if and only if *this is a universe polyhedron.
Relation_Symbol
Relation symbols.
Degenerate_Element
Kinds of degenerate abstract elements.
bool constraints_are_up_to_date() const
Returns true if the system of constraints is up-to-date.
void refine_no_check(const Constraint &c)
Uses a copy of constraint c to refine the system of constraints of *this.
void throw_topology_incompatible(const char *method, const char *ph_name, const Polyhedron &ph) const
bool BHZ09_NNC_poly_hull_assign_if_exact(const Polyhedron &y)
void obtain_sorted_generators_with_sat_g() const
Sorts the matrix of generators and updates sat_g.
void obtain_sorted_constraints_with_sat_c() const
Sorts the matrix of constraints and updates sat_c.
A linear form with interval coefficients.
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.
Bit_Matrix sat_g
The saturation matrix having generators on its columns.
void set_generators_minimized()
Sets status to express that generators are minimized.
void refine_with_constraints(const Constraint_System &cs)
Uses a copy of the constraints in cs to refine *this.
static dimension_type max_space_dimension()
Returns the maximum space dimension all kinds of Polyhedron can handle.
const Generator_System & generators() const
Returns the system of generators.
bool eq(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
const Generator_System & minimized_generators() const
Returns the system of generators, with no redundant generator.
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 refine_fp_interval_abstract_store(Box< Interval< FP_Format, Interval_Info > > &store) const
Refines store with the constraints defining *this.
void intersection_assign(const Polyhedron &y)
Assigns to *this the intersection of *this and y.
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.
bool BHRZ03_combining_constraints(const Polyhedron &y, const BHRZ03_Certificate &y_cert, const Polyhedron &H79, const Constraint_System &x_minus_H79_cs)
void process_pending_generators() const
Processes the pending generators and obtains a minimized polyhedron.
void clear_empty()
Clears the status flag indicating that the polyhedron is empty.
void add_generator(const Generator &g)
Adds a copy of generator g to the system of generators of *this (without minimizing the result)...
Status status
The status flags to keep track of the polyhedron's internal state.
bool is_included_in(const Polyhedron &y) const
Returns true if and only if *this is included in y.
void add_constraints(const Constraint_System &cs)
Adds a copy of the constraints in cs to the system of constraints of *this (without minimizing the re...
void positive_time_elapse_assign_impl(const Polyhedron &y)
Assuming *this is NNC, assigns to *this the result of the "positive time-elapse" between *this and y...
void remove_pending_to_obtain_constraints() const
Lazily integrates the pending descriptions of the polyhedron to obtain a constraint system without pe...
bool BHRZ03_evolving_rays(const Polyhedron &y, const BHRZ03_Certificate &y_cert, const Polyhedron &H79)
A generic, not necessarily closed, possibly restricted interval.
bool BHRZ03_evolving_points(const Polyhedron &y, const BHRZ03_Certificate &y_cert, const Polyhedron &H79)
void set_empty()
Sets status to express that the polyhedron is empty, clearing all corresponding matrices.
A conjunctive assertion about a polyhedron.
The convergence certificate for the BHRZ03 widening operator.
The entire library is confined to this namespace.
Definition: version.hh:61
static void convert_to_integer_expression(const Linear_Form< Interval< FP_Format, Interval_Info > > &lf, const dimension_type lf_dimension, Linear_Expression &result)
Helper function that makes result become a Linear_Expression obtained by normalizing the denominators...
dimension_type space_dim
The number of dimensions of the enclosing vector space.
void difference_assign(const Polyhedron &y)
Same as poly_difference_assign(y).
bool bounds(const Linear_Expression &expr, bool from_above) const
Checks if and how expr is bounded in *this.
void upper_bound_assign(const Polyhedron &y)
Same as poly_hull_assign(y).
Congruence_System congruences() const
Returns a system of (equality) congruences satisfied by *this.
void poly_hull_assign(const Polyhedron &y)
Assigns to *this the poly-hull of *this and y.
bool contains(const Polyhedron &y) const
Returns true if and only if *this contains y.
bool is_necessarily_closed() const
Returns true if and only if the polyhedron is necessarily closed.
void add_congruence(const Congruence &cg)
Adds a copy of congruence cg to *this, if cg can be exactly represented by a polyhedron.
A bounded difference shape.
void clear_sat_g_up_to_date()
Sets status to express that sat_g is no longer up-to-date.
void fold_space_dimensions(const Variables_Set &vars, Variable dest)
Folds the space dimensions in vars into dest.
void select_H79_constraints(const Polyhedron &y, Constraint_System &cs_selected, Constraint_System &cs_not_selected) const
Splits the constraints of `x' into two subsets, depending on whether or not they are selected to comp...
Dense representation: the coefficient sequence is represented as a vector of coefficients, including the zero coefficients. If there are only a few nonzero coefficients, this representation is faster and also uses a bit less memory.
static dimension_type * simplify_num_saturators_p
Pointer to an array used by simplify().
bool OK(bool check_not_empty=false) const
Checks if all the invariants are satisfied.
bool process_pending_constraints() const
Processes the pending constraints and obtains a minimized polyhedron.
void clear_constraints_minimized()
Sets status to express that constraints are no longer minimized.
static const Representation default_con_sys_repr
void expand_space_dimension(Variable var, dimension_type m)
Creates m copies of the space dimension corresponding to var.
void overapproximate_linear_form(const Linear_Form< Interval< FP_Format, Interval_Info > > &lf, const dimension_type lf_dimension, Linear_Form< Interval< FP_Format, Interval_Info > > &result)
Helper function that overapproximates an interval linear form.
bool simplify_using_context_assign(const Polyhedron &y)
Assigns to *this a meet-preserving simplification of *this with respect to y. If false is returned...
static size_t simplify_num_saturators_size
Dimension of an array used by simplify().
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 ...
bool operator==(const Box< ITV > &x, const Box< ITV > &y)
void concatenate_assign(const Polyhedron &y)
Assigns to *this the concatenation of *this and y, taken in this order.
void update_sat_c() const
Updates sat_c using the updated constraints and generators.
Three_Valued_Boolean quick_equivalence_test(const Polyhedron &y) const
Polynomial but incomplete equivalence test between polyhedra.
void obtain_sorted_generators() const
Sorts the matrix of generators keeping status consistency.
bool BHZ09_poly_hull_assign_if_exact(const Polyhedron &y)
memory_size_type total_memory_in_bytes() const
Returns the total size in bytes of the memory occupied by *this.
bool has_pending_generators() const
Returns true if there are pending generators.
dimension_type affine_dimension() const
Returns , if *this is empty; otherwise, returns the affine dimension of *this.
void clear_sat_c_up_to_date()
Sets status to express that sat_c is no longer up-to-date.
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void time_elapse_assign(const Polyhedron &y)
Assigns to *this the result of computing the time-elapse between *this and y.
Coefficient c
Definition: PIP_Tree.cc:64
void bounded_BHRZ03_extrapolation_assign(const Polyhedron &y, const Constraint_System &cs, unsigned *tp=0)
Assigns to *this the result of computing the bounded extrapolation between *this and y using the BHRZ...
friend bool operator==(const Polyhedron &x, const Polyhedron &y)
Bit_Matrix sat_c
The saturation matrix having constraints on its columns.
static const Representation default_gen_sys_repr
void throw_invalid_generator(const char *method, const char *g_name) const
void set_constraints_minimized()
Sets status to express that constraints are minimized.
static bool can_recycle_constraint_systems()
Returns true indicating that this domain has methods that can recycle constraints.
Coefficient_traits::const_reference Coefficient_one()
Returns a const reference to a Coefficient with value 1.
A convergence certificate for the H79 widening operator.
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 set_generators_pending()
Sets status to express that generators are pending.
void positive_time_elapse_assign(const Polyhedron &y)
Assigns to *this (the best approximation of) the result of computing the positive time-elapse between...
void unconstrain(Variable var)
Computes the cylindrification of *this with respect to space dimension var, assigning the result to *...
static bool add_and_minimize(bool con_to_gen, Source_Linear_System1 &source1, Dest_Linear_System &dest, Bit_Matrix &sat, const Source_Linear_System2 &source2)
Adds given constraints and builds minimized corresponding generators or vice versa.
void bounded_H79_extrapolation_assign(const Polyhedron &y, const Constraint_System &cs, unsigned *tp=0)
Assigns to *this the result of computing the bounded extrapolation between *this and y using the H79-...
const Constraint_System & minimized_constraints() const
Returns the system of constraints, with no redundant constraint.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void refine_with_congruences(const Congruence_System &cgs)
Uses a copy of the congruences in cgs to refine *this.
bool is_necessarily_closed_for_interfaces(const Polyhedron &ph)
Returns true if and only if ph.topology() == NECESSARILY_CLOSED.
static void add_space_dimensions(Linear_System1 &sys1, Linear_System2 &sys2, Bit_Matrix &sat1, Bit_Matrix &sat2, dimension_type add_dim)
Adds new space dimensions to the given linear systems.
void m_swap(Polyhedron &y)
Swaps *this with polyhedron y. (*this and y can be dimension-incompatible.)
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
void clear_generators_up_to_date()
Sets status to express that generators are no longer up-to-date.
The relation between a polyhedron and a generator.
bool is_bounded() const
Returns true if and only if *this is a bounded polyhedron.
void set_zero_dim_univ()
Sets status to express that the polyhedron is the universe 0-dimension vector space, clearing all corresponding matrices.
bool is_discrete() const
Returns true if and only if *this is discrete.
Topology
Kinds of polyhedra domains.
void clear_generators_minimized()
Sets status to express that generators are no longer minimized.
static void initialize()
Initializes the class.
Poly_Con_Relation relation_with(const Constraint &c) const
Returns the relations holding between the polyhedron *this and the constraint c.
Coefficient coefficient_type
The numeric type of coefficients.
The relation between a polyhedron and a constraint.
bool has_something_pending() const
Returns true if there are either pending constraints or pending generators.