skip to main content
research-article
Free Access

Size-change termination with difference constraints

Published:21 May 2008Publication History
Skip Abstract Section

Abstract

This article considers an algorithmic problem related to the termination analysis of programs. More specifically, we are given bounds on differences in sizes of data values before and after every transition in the program's control-flow graph. Our goal is to infer program termination via the following reasoning (“the size-change principle”): if in any infinite (hypothetic) execution of the program, some size must descend unboundedly, the program must always terminate, since infinite descent of a natural number is impossible.

The problem of inferring termination from such abstract information is not the halting problem for programs and may well be decidable. If this is the case, the decision algorithm forms a “back end” of a termination verifier, and it is interesting to find out the computational complexity of the problem.

A restriction of the problem described above, which only uses monotonicity information (but not difference bounds), is already known to be decidable. We prove that the unrestricted problem is undecidable, which gives a theoretical argument for studying restricted cases. We consider a case where the termination proof is allowed to make use of at most one bound per target variable in each transition. For this special case, which we claim is practically significant, we give (for the first time) an algorithm and show that the problem is in PSPACE, in fact that it is PSPACE-complete. The algorithm is based on combinatorial arguments and results from the theory of integer programming not previously used for similar problems.

The algorithm has interesting connections to other work in termination, in particular to methods for generating linear ranking functions or invariants.

References

  1. Anderson, H. and Khoo, S.-C. 2003. Affine-based size-change termination. In Proceedings of the First Asian Symposium on Programming Languages and Systems (APLAS 2003) (Beijing, China), A. Ohori, Ed. Lecture Notes in Computer Science, vol. 2895. Springer-Verlag, New York, 122--140.Google ScholarGoogle Scholar
  2. Apt, K. R. and Pedreschi, D. 1994. Modular termination proofs for logic and pure prolog programs. In Advances in Logic Programming Theory. Oxford University Press, Oxford, UK, 183--229. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Avery, J. 2006. Size-change termination and bound analysis. In Proceedings of the 8th International Symposium on Functional and Logic Programming (FLOPS 2006) M. Hagiya and P. Wadler, Eds. Lecture Notes in Computer Science, vol. 3945. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Ben-Amram, A. M. and Lee, C. S. 2007. Size-change analysis in polynomial time. ACM Trans. Prog. Lang. Syst. 29, 1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Brodsky, A. and Sagiv, Y. 1991. Inference of inequality constraints in logic programs. In Proceedings of the 10th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS). ACM, New York, 227--240. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Bueno, F., García de la Banda, M., and Hermenegildo, M. 1994. Effectiveness of global analysis in strict independence-based automatic program parallelization. In Proceedings of the International Symposium on Logic Programming. MIT Press, Cambridge, MA, 320--336. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Codish, M., Lagoon, V., and Stuckey, P. J. 2005. Testing for termination with monotonicity constraints. In Logic Programming, 21st International Conference, ICLP 2005, M. Gabbrielli and G. Gupta, Eds. Lecture Notes in Computer Science, vol. 3668. Springer-Verlag, New York, 326--340. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Codish, M. and Taboch, C. 1999. A semantic basis for termination analysis of logic programs. The Journal of Logic Programming 41, 1, 103--123. (Preliminary (conference) version in LNCS 1298 (1997)). Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Colón, M. and Sipma, H. 2002. Practical methods for proving program termination. In Proceedings of the 14th International Conference on Computer Aided Verification (CAV). Lecture Notes in Computer Science, vol. 2404. Springer-Verlag, New York, 442--454. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Cook, B., Podelski, A., and Rybalchenko, A. 2005. Abstraction refinement for termination. In Proceedings of the 12th International Symposium on Static Analysis (SAS'05) (London, UK, Sept. 7--9) Lecture Notes in Computer Science, vol. 3672. Springer-Verlag, New York, 87--101. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Cook, B., Podelski, A., and Rybalchenko, A. 2006. Terminator: Beyond safety. In Proceedings of the 18th International Conference on Computer Aided Verification (CAV 2006), (Seattle, WA, Aug.), T. Ball and R. B. Jones, Eds. Lecture Notes in Computer Science, vol. 4144. Springer-Verlag, New York, 415--418. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Dershowitz, N., Lindenstrauss, N., Sagiv, Y., and Serebrenik, A. 2001. A general framework for automatic termination analysis of logic programs. Applic. Algebra Eng. Commun. Comput. 12, 1--2, 117--156.Google ScholarGoogle ScholarCross RefCross Ref
  13. Downey, R. G. and Fellows, M. R. 1995. Fixed-parameter tractability and completeness. I. basic results. SIAM J. Comput. 24, 4 (Aug.), 873--921. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Graham, R. L. 1981. Rudiments of Ramsey Theory. American Mathematical Society.Google ScholarGoogle Scholar
  15. Jones, N. D. 1988. Automatic program specialization: A re-examination from basic principles. In Partial Evaluation and Mixed Computation, D. Bjørner, A. P. Ershov, and N. D. Jones, Eds. North-Holland, Amsterdam, The Netherlands, 225--282.Google ScholarGoogle Scholar
  16. Jones, N. D. 1997. Computability and Complexity from a Programming Perspective. Foundations of Computing Series. MIT Press, Cambridge, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Jones, N. D. and Bohr, N. 2004. Termination analysis of the untyped lambda calculus. In Proceedings of the 15th International Conference on Rewriting Techniques and Applications (RTA'04). Lecture Notes in Computer Science, vol. 3091. Springer-Verlag, New York, 1--23.Google ScholarGoogle Scholar
  18. Jones, N. D., Gomard, C. K., and Sestoft, P. 1993. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Englewood Cliffs, NJ. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Jones, N. D., Landweber, L. H., and Lien, Y. E. 1977. Complexity of some problems in Petri nets. Theoret. Comput. Sci. 4, 3 (June), 277--299.Google ScholarGoogle ScholarCross RefCross Ref
  20. Lee, C. S. 2002. Program termination analysis and termination of offline partial evaluation. Ph.D. dissertation, University of Western Australia.Google ScholarGoogle Scholar
  21. Lee, C. S. 2008. Ranking functions for size-change termination. Submitted for publication in ACM Trans. Prog. Lang. Syst. (Levven, Belgium). Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Lee, C. S., Jones, N. D., and Ben-Amram, A. M. 2001. The size-change principle for program termination. In Proceedings of the 28th ACM Symposium on Principles of Programming Languages. ACM, New York, 81--92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Lindenstrauss, N. and Sagiv, Y. 1997a. Automatic termination analysis of logic programs (with detailed experimental results). http://www.cs.huji.ac.il/~naomil/.Google ScholarGoogle Scholar
  24. Lindenstrauss, N. and Sagiv, Y. 1997b. Automatic termination analysis of Prolog programs. In Proceedings of the 14th International Conference on Logic Programming (Leuven, Belgium). L. Naish, Ed. MIT Press, Cambridge, MA, 64--77.Google ScholarGoogle Scholar
  25. Manolios, P. and Vroon, D. 2006. Termination analysis with calling context graphs. In Proceedings of the 18th International Conference on Computer Aided Verification (CAV 2006) (Seattle, WA Aug.). Lecture Notes in Computer Science, vol. 4144. Springer-Verlag, New York, 401--414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Naish, L. 1985. Automating control for logic programs. J. Logic Prog. 2, 3 (Oct.), 167--183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Papadimitriou, C. H. 1981. On the complexity of integer programming. J. ACM 28, 4, 765--768. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Plümer, L. 1990. Termination Proofs for Logic Programs. Lecture Notes in Artificial Intelligence, vol. 446. Springer-Verlag, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Podelski, A. and Rybalchenko, A. 2004. Transition invariants. In Proceedings of the Symposium on Logic in Computer Science (LICS'04). H. Ganzinger, Ed. IEEE Computer Society Press, Los Alamitos, CA, 32--41. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Ramsey, F. P. 1930. On a problem of formal logic. In Proceedings of the London Mathematical Society. The London Mathematical Society, London, UK, 264--286.Google ScholarGoogle ScholarCross RefCross Ref
  31. Sagiv, Y. 1991. A termination test for logic programs. In Proceedings of the International Symposium on Logic Programming (San Diego, CA). V. Saraswat and K. Ueda, Eds. MIT Press, Cambridge, MA, 518--532.Google ScholarGoogle Scholar
  32. Schreye, D. D. and Decorte, S. 1994. Termination of logic programs: The never-ending story. J. Logic Prog. 19-20, 199--260.Google ScholarGoogle ScholarCross RefCross Ref
  33. Sohn, K. and Van Gelder, A. 1991. Termination detection in logic programs using argument sizes (extended abstract). In Proceedings of the 10th ACM SIGACT-SIGMOD-SOGART Symposium on Principles of Database Systems (PODS) (Denver, CO, May). ACM, New York, 216--226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Thiemann, R. and Giesl, J. 2005. The size-change principle and dependency pairs for termination of term rewriting. Applic. Algebra Eng. Commun. Comput. 16, 4 (Sept.), 229--270. Google ScholarGoogle ScholarCross RefCross Ref
  35. Ullman G. D. and Gelder, V. 1988. Efficient tests for top-down termination of logical rules. J. ACM 35, 2, 345--373. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Size-change termination with difference constraints

              Recommendations

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in

              Full Access

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader
              About Cookies On This Site

              We use cookies to ensure that we give you the best experience on our website.

              Learn more

              Got it!