PPL  1.2
Parma_Polyhedra_Library::Termination_Helpers Class Reference

#include <termination_defs.hh>

Static Public Member Functions

static void all_affine_ranking_functions_PR (const Constraint_System &cs_before, const Constraint_System &cs_after, NNC_Polyhedron &mu_space)
 
static bool one_affine_ranking_function_PR (const Constraint_System &cs_before, const Constraint_System &cs_after, Generator &mu)
 
static bool one_affine_ranking_function_PR_original (const Constraint_System &cs, Generator &mu)
 
static void all_affine_ranking_functions_PR_original (const Constraint_System &cs, NNC_Polyhedron &mu_space)
 
template<typename PSET >
static void assign_all_inequalities_approximation (const PSET &pset_before, const PSET &pset_after, Constraint_System &cs)
 

Detailed Description

Definition at line 36 of file termination_defs.hh.

Member Function Documentation

void Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR ( const Constraint_System cs_before,
const Constraint_System cs_after,
NNC_Polyhedron mu_space 
)
static

Definition at line 784 of file termination.cc.

References Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Linear_Expression::all_homogeneous_terms_are_zero(), Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Generator::CLOSURE_POINT, Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Generator::divisor(), Parma_Polyhedra_Library::EMPTY, Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Generator_System::end(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::Variable::get_output_function(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Boundary_NS::le(), Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Linear_Expression::linear_combine(), Parma_Polyhedra_Library::Implementation::num_constraints(), Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, Parma_Polyhedra_Library::Polyhedron::remove_higher_space_dimensions(), row_index, Parma_Polyhedra_Library::Variable::set_output_function(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Constraint_System::space_dimension(), and Parma_Polyhedra_Library::Generator::type().

Referenced by Parma_Polyhedra_Library::Implementation::Termination::all_affine_ranking_functions_PR().

786  {
787  Constraint_System cs_eqs;
788  Linear_Expression le_ineq;
790  ::fill_constraint_system_PR(cs_before, cs_after, cs_eqs, le_ineq);
791 
792 #if PRINT_DEBUG_INFO
793  Variable::output_function_type* p_default_output_function
795  Variable::set_output_function(output_function_PR);
796 
797  output_function_PR_r = num_constraints(cs_before);
798  output_function_PR_s = num_constraints(cs_after);
799 
800  std::cout << "*** cs_eqs ***" << std::endl;
801  using namespace IO_Operators;
802  std::cout << cs_eqs << std::endl;
803  std::cout << "*** le_ineq ***" << std::endl;
804  std::cout << le_ineq << std::endl;
805 #endif
806 
807  NNC_Polyhedron ph(cs_eqs);
808  ph.add_constraint(le_ineq < 0);
809  // u_3 corresponds to space dimensions 0, ..., s - 1.
811  ph.remove_higher_space_dimensions(s);
812 
813 #if PRINT_DEBUG_INFO
814  std::cout << "*** ph ***" << std::endl;
815  std::cout << ph << std::endl;
816 
817  Variable::set_output_function(p_default_output_function);
818 #endif
819 
820  const dimension_type n = cs_before.space_dimension();
821 
822  const Generator_System& gs_in = ph.generators();
823  Generator_System gs_out;
824  Generator_System::const_iterator gs_in_it = gs_in.begin();
825  Generator_System::const_iterator gs_in_end = gs_in.end();
826  if (gs_in_it == gs_in_end) {
827  // The system is unsatisfiable.
828  mu_space = NNC_Polyhedron(n + 1, EMPTY);
829  }
830  else {
831  for ( ; gs_in_it != gs_in_end; ++gs_in_it) {
832  const Generator& g = *gs_in_it;
833  Linear_Expression le;
834  le.set_space_dimension(n);
835  // Set le to the multiplication of Linear_Expression(g) by E'_C.
837  for (Constraint_System::const_iterator i = cs_after.begin(),
838  cs_after_end = cs_after.end();
839  i != cs_after_end;
840  ++i, ++row_index) {
841  Coefficient_traits::const_reference
842  g_i = g.coefficient(Variable(row_index));
843  if (g_i != 0) {
844  le.linear_combine(i->expr, 1, -g_i, 1, n + 1);
845  }
846  }
847 
848  // Add to gs_out the transformed generator.
849  switch (g.type()) {
850  case Generator::LINE:
851  if (!le.all_homogeneous_terms_are_zero()) {
852  gs_out.insert(line(le));
853  }
854  break;
855  case Generator::RAY:
856  if (!le.all_homogeneous_terms_are_zero()) {
857  gs_out.insert(ray(le));
858  }
859  break;
860  case Generator::POINT:
861  gs_out.insert(point(le, g.divisor()));
862  break;
864  gs_out.insert(closure_point(le, g.divisor()));
865  break;
866  }
867  }
868 
869  mu_space = NNC_Polyhedron(gs_out);
870  // mu_0 is zero.
871  mu_space.add_space_dimensions_and_embed(1);
872  }
873 }
The empty element, i.e., the empty set.
size_t dimension_type
An unsigned integral type for representing space dimensions.
static output_function_type * get_output_function()
Returns the pointer to the current output function.
dimension_type num_constraints(const Constraint_System &cs)
Helper returning number of constraints in system.
void output_function_type(std::ostream &s, const Variable v)
Type of output functions.
void fill_constraint_system_PR(const Constraint_System &cs_before, const Constraint_System &cs_after, Constraint_System &cs_out, Linear_Expression &le_out)
Fill the constraint system(s) for the application of the Podelski and Rybalchenko improved terminatio...
Definition: termination.cc:348
dimension_type row_index
Definition: PIP_Tree.cc:615
Generator_System_const_iterator const_iterator
static void set_output_function(output_function_type *p)
Sets the output function to be used for printing Variable objects.
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Constraint_System_const_iterator const_iterator
void Parma_Polyhedra_Library::Termination_Helpers::all_affine_ranking_functions_PR_original ( const Constraint_System cs,
NNC_Polyhedron mu_space 
)
static

Definition at line 877 of file termination.cc.

References Parma_Polyhedra_Library::Polyhedron::add_constraint(), Parma_Polyhedra_Library::Polyhedron::add_space_dimensions_and_embed(), Parma_Polyhedra_Library::Linear_Expression::all_homogeneous_terms_are_zero(), Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator_System::begin(), Parma_Polyhedra_Library::Generator::CLOSURE_POINT, Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Generator::divisor(), Parma_Polyhedra_Library::EMPTY, Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Generator_System::end(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Polyhedron::generators(), Parma_Polyhedra_Library::Generator_System::insert(), Parma_Polyhedra_Library::Boundary_NS::le(), Parma_Polyhedra_Library::Generator::LINE, Parma_Polyhedra_Library::Linear_Expression::linear_combine(), Parma_Polyhedra_Library::Implementation::num_constraints(), Parma_Polyhedra_Library::Generator::POINT, Parma_Polyhedra_Library::Generator::RAY, Parma_Polyhedra_Library::Polyhedron::remove_space_dimensions(), row_index, Parma_Polyhedra_Library::Variable::set_output_function(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), Parma_Polyhedra_Library::Constraint_System::space_dimension(), and Parma_Polyhedra_Library::Generator::type().

Referenced by Parma_Polyhedra_Library::Implementation::Termination::all_affine_ranking_functions_PR_original().

878  {
879  PPL_ASSERT(cs.space_dimension() % 2 == 0);
880  const dimension_type n = cs.space_dimension() / 2;
882 
883  if (m == 0) {
884  // If there are no constraints at all, we have non-termination,
885  // i.e., no affine ranking function at all.
886  mu_space = NNC_Polyhedron(n + 1, EMPTY);
887  return;
888  }
889 
890  Constraint_System cs_eqs;
891  Linear_Expression le_ineq;
893  ::fill_constraint_system_PR_original(cs, cs_eqs, le_ineq);
894 
895  NNC_Polyhedron ph(cs_eqs);
896  ph.add_constraint(le_ineq < 0);
897  // lambda_2 corresponds to space dimensions m, ..., 2*m-1.
898  const Variables_Set lambda1(Variable(0), Variable(m-1));
899  ph.remove_space_dimensions(lambda1);
900 
901 #if PRINT_DEBUG_INFO
902  std::cout << "*** ph ***" << std::endl;
903  std::cout << ph << std::endl;
904 
905  Variable::set_output_function(p_default_output_function);
906 #endif
907 
908  const Generator_System& gs_in = ph.generators();
909  Generator_System::const_iterator gs_in_it = gs_in.begin();
910  Generator_System::const_iterator gs_in_end = gs_in.end();
911  if (gs_in_it == gs_in_end) {
912  // The system is unsatisfiable.
913  mu_space = NNC_Polyhedron(n + 1, EMPTY);
914  }
915  else {
916  Generator_System gs_out;
917  for ( ; gs_in_it != gs_in_end; ++gs_in_it) {
918  const Generator& g = *gs_in_it;
919  Linear_Expression le;
920  le.set_space_dimension(n);
921  // Set le to the multiplication of Linear_Expression(g) by E'_C.
923  for (Constraint_System::const_iterator i = cs.begin(),
924  cs_end = cs.end(); i != cs_end; ++i, ++row_index) {
925  const Variable lambda2_i(row_index);
926  Coefficient_traits::const_reference g_i = g.coefficient(lambda2_i);
927  if (g_i != 0) {
928  le.linear_combine(i->expr, 1, -g_i, 1, n + 1);
929  }
930  }
931 
932  // Add to gs_out the transformed generator.
933  switch (g.type()) {
934  case Generator::LINE:
935  if (!le.all_homogeneous_terms_are_zero()) {
936  gs_out.insert(line(le));
937  }
938  break;
939  case Generator::RAY:
940  if (!le.all_homogeneous_terms_are_zero()) {
941  gs_out.insert(ray(le));
942  }
943  break;
944  case Generator::POINT:
945  gs_out.insert(point(le, g.divisor()));
946  break;
948  gs_out.insert(closure_point(le, g.divisor()));
949  break;
950  }
951  }
952 
953  mu_space = NNC_Polyhedron(gs_out);
954  // mu_0 is zero.
955  mu_space.add_space_dimensions_and_embed(1);
956  }
957 }
The empty element, i.e., the empty set.
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_constraints(const Constraint_System &cs)
Helper returning number of constraints in system.
void fill_constraint_system_PR_original(const Constraint_System &cs, Constraint_System &cs_out, Linear_Expression &le_out)
Definition: termination.cc:431
dimension_type row_index
Definition: PIP_Tree.cc:615
Generator_System_const_iterator const_iterator
static void set_output_function(output_function_type *p)
Sets the output function to be used for printing Variable objects.
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Constraint_System_const_iterator const_iterator
template<typename PSET >
void Parma_Polyhedra_Library::Termination_Helpers::assign_all_inequalities_approximation ( const PSET &  pset_before,
const PSET &  pset_after,
Constraint_System cs 
)
static

Definition at line 224 of file termination_templates.hh.

References Parma_Polyhedra_Library::Implementation::Termination::assign_all_inequalities_approximation(), Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Constraint_System::shift_space_dimensions(), and Parma_Polyhedra_Library::Constraint_System::space_dimension().

226  {
229  cs.shift_space_dimensions(Variable(0), cs.space_dimension());
230  Constraint_System cs_after;
232  ::assign_all_inequalities_approximation(pset_after, cs_after);
233  // FIXME: provide an "append" for constraint systems.
234  for (Constraint_System::const_iterator i = cs_after.begin(),
235  cs_after_end = cs_after.end(); i != cs_after_end; ++i) {
236  cs.insert(*i);
237  }
238 }
void assign_all_inequalities_approximation(const PSET &pset, Constraint_System &cs)
Constraint_System_const_iterator const_iterator
bool Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR ( const Constraint_System cs_before,
const Constraint_System cs_after,
Generator mu 
)
static

Definition at line 675 of file termination.cc.

References Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR(), Parma_Polyhedra_Library::Variable::get_output_function(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Generator::is_point(), Parma_Polyhedra_Library::Boundary_NS::le(), Parma_Polyhedra_Library::Linear_Expression::linear_combine(), Parma_Polyhedra_Library::Implementation::num_constraints(), row_index, Parma_Polyhedra_Library::Variable::set_output_function(), Parma_Polyhedra_Library::Linear_Expression::set_space_dimension(), and Parma_Polyhedra_Library::Constraint_System::space_dimension().

677  {
678  Constraint_System cs_mip;
679  Linear_Expression le_ineq;
681  ::fill_constraint_system_PR(cs_before, cs_after, cs_mip, le_ineq);
682 
683 #if PRINT_DEBUG_INFO
684  Variable::output_function_type* p_default_output_function
686  Variable::set_output_function(output_function_PR);
687 
688  output_function_PR_r = num_constraints(cs_before);
689  output_function_PR_s = num_constraints(cs_after);
690 
691  std::cout << "*** cs_mip ***" << std::endl;
692  using namespace IO_Operators;
693  std::cout << cs_mip << std::endl;
694  std::cout << "*** le_ineq ***" << std::endl;
695  std::cout << le_ineq << std::endl;
696 
697  Variable::set_output_function(p_default_output_function);
698 #endif
699 
700  // Turn minimization problem into satisfiability.
701  cs_mip.insert(le_ineq <= -1);
702 
703  const MIP_Problem mip(cs_mip.space_dimension(), cs_mip);
704  if (!mip.is_satisfiable()) {
705  return false;
706  }
707 
708  const Generator& fp = mip.feasible_point();
709  PPL_ASSERT(fp.is_point());
710 
711  // u_3 corresponds to space dimensions 0, ..., s - 1.
712  const dimension_type n = cs_before.space_dimension();
713  // mu_0 is zero: properly set space dimension.
714  Linear_Expression le;
715  le.set_space_dimension(1 + n);
716  // Multiply u_3 by E'_C to obtain mu_1, ..., mu_n.
718  for (Constraint_System::const_iterator i = cs_after.begin(),
719  cs_after_end = cs_after.end();
720  i != cs_after_end;
721  ++i, ++row_index) {
722  Coefficient_traits::const_reference
723  fp_i = fp.coefficient(Variable(row_index));
724  if (fp_i != 0) {
725  le.linear_combine(i->expr, 1, -fp_i, 1, n + 1);
726  }
727  }
728  // Note that we can neglect the divisor of `fp' since it is positive.
729  mu = point(le);
730  return true;
731 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
static output_function_type * get_output_function()
Returns the pointer to the current output function.
dimension_type num_constraints(const Constraint_System &cs)
Helper returning number of constraints in system.
void output_function_type(std::ostream &s, const Variable v)
Type of output functions.
void fill_constraint_system_PR(const Constraint_System &cs_before, const Constraint_System &cs_after, Constraint_System &cs_out, Linear_Expression &le_out)
Fill the constraint system(s) for the application of the Podelski and Rybalchenko improved terminatio...
Definition: termination.cc:348
dimension_type row_index
Definition: PIP_Tree.cc:615
static void set_output_function(output_function_type *p)
Sets the output function to be used for printing Variable objects.
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Constraint_System_const_iterator const_iterator
bool Parma_Polyhedra_Library::Termination_Helpers::one_affine_ranking_function_PR_original ( const Constraint_System cs,
Generator mu 
)
static

Definition at line 735 of file termination.cc.

References Parma_Polyhedra_Library::Constraint_System::begin(), Parma_Polyhedra_Library::Generator::coefficient(), Parma_Polyhedra_Library::Constraint_System::end(), Parma_Polyhedra_Library::MIP_Problem::feasible_point(), Parma_Polyhedra_Library::Implementation::Termination::fill_constraint_system_PR_original(), Parma_Polyhedra_Library::Constraint_System::insert(), Parma_Polyhedra_Library::Generator::is_point(), Parma_Polyhedra_Library::MIP_Problem::is_satisfiable(), Parma_Polyhedra_Library::Boundary_NS::le(), Parma_Polyhedra_Library::Implementation::num_constraints(), row_index, and Parma_Polyhedra_Library::Constraint_System::space_dimension().

Referenced by Parma_Polyhedra_Library::Implementation::Termination::one_affine_ranking_function_PR_original().

736  {
737  PPL_ASSERT(cs.space_dimension() % 2 == 0);
738  const dimension_type n = cs.space_dimension() / 2;
740 
741  Constraint_System cs_mip;
742  Linear_Expression le_ineq;
744  ::fill_constraint_system_PR_original(cs, cs_mip, le_ineq);
745 
746 #if PRINT_DEBUG_INFO
747  std::cout << "*** cs_mip ***" << std::endl;
748  using namespace IO_Operators;
749  std::cout << cs_mip << std::endl;
750  std::cout << "*** le_ineq ***" << std::endl;
751  std::cout << le_ineq << std::endl;
752 #endif
753 
754  // Turn minimization problem into satisfiability.
755  cs_mip.insert(le_ineq <= -1);
756 
757  const MIP_Problem mip = MIP_Problem(cs_mip.space_dimension(), cs_mip);
758  if (!mip.is_satisfiable()) {
759  return false;
760  }
761  const Generator& fp = mip.feasible_point();
762  PPL_ASSERT(fp.is_point());
763  // mu_0 is zero: properly set space dimension.
764  Linear_Expression le;
765  le.set_space_dimension(1 + n);
766  // Multiply -lambda_2 by A' to obtain mu_1, ..., mu_n.
767  // lambda_2 corresponds to space dimensions m, ..., 2*m - 1.
769  for (Constraint_System::const_iterator i = cs.begin(),
770  cs_end = cs.end(); i != cs_end; ++i, ++row_index) {
771  const Variable lambda_2(row_index);
772  Coefficient_traits::const_reference fp_i = fp.coefficient(lambda_2);
773  if (fp_i != 0) {
774  le.linear_combine(i->expr, 1, -fp_i, 1, n + 1);
775  }
776  }
777  // Note that we can neglect the divisor of `fp' since it is positive.
778  mu = point(le);
779  return true;
780 }
size_t dimension_type
An unsigned integral type for representing space dimensions.
dimension_type num_constraints(const Constraint_System &cs)
Helper returning number of constraints in system.
void fill_constraint_system_PR_original(const Constraint_System &cs, Constraint_System &cs_out, Linear_Expression &le_out)
Definition: termination.cc:431
dimension_type row_index
Definition: PIP_Tree.cc:615
bool le(Boundary_Type type1, const T1 &x1, const Info1 &info1, Boundary_Type type2, const T2 &x2, const Info2 &info2)
Constraint_System_const_iterator const_iterator

The documentation for this class was generated from the following files: