skip to main content
research-article
Open Access

Ranking functions for size-change termination

Published:21 April 2009Publication History
Skip Abstract Section

Abstract

This article explains how to construct a ranking function for any program that is proved terminating by size-change analysis.

The “principle of size-change termination” for a first-order functional language with well-ordered data is intuitive: A program terminates on all inputs, if every infinite call sequence (following program control flow) would imply an infinite descent in some data values. Size-change analysis is based on information associated with the subject program's call-sites. This information indicates, for each call-site, strict or weak data decreases observed as a computation traverses the call-site. The set DESC of call-site sequences for which the size-changes imply infinite descent is ω-regular, as is the set FLOW of infinite call-site sequences following the program flowchart. If FLOWDESC (a decidable problem), every infinite call sequence would imply infinite descent in a well-ordering—an impossibility—so the program must terminate.

This analysis accounts for termination arguments applicable to different call-site sequences, without indicating a ranking function for the program's termination. In this article, it is explained how one can be constructed whenever size-change analysis succeeds. The constructed function has an unexpectedly simple form; it is expressed using only min, max, and lexicographic tuples of parameters and constants. In principle, such functions can be tested to determine whether size-change analysis will be successful. As a corollary, if a program verified as terminating performs only multiply recursive operations, the function that it computes is multiply recursive.

The ranking function construction is connected with the determinization of the Büchi automaton for DESC. While the result is not practical, it is of value in addressing the scope of size-change reasoning. This reasoning has been applied broadly, in the analysis of functional and logic programs, as well as term rewrite systems.

References

  1. Althoff, C. S., Thomas, W., and Wallmeier, N. 2005. Observations on Determinization of Büchi Automata. In Proceedings of the 10th International Conference on Implementation and Application of Automata, (CIAA'05). Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Anderson, H. and Khoo, S. C. 2003. Affine-based size-change termination. In Proceedings of the 1st Asian Symposium on Programming Languages and Systems (APLAS'03), Ohori, Ed. Lecture Notes in Computer Science, vol. 2895. Springer, 122--140.Google ScholarGoogle Scholar
  3. Avery, J. 2005. The size-change termination principle on non well founded data types. Tech. Rep., DIKU, Denmark.Google ScholarGoogle Scholar
  4. Ben-Amram, A. 2002. General size-change termination and lexicographic descent. In The Essence of Computation: Complexity, Analysis, Transformation. Essays Dedicated to Neil D. Jones, T. Mogensen, D. Schmidt, and H. Sudborough, Eds. Lecture Notes in Computer Science, vol. 2566. Springer, 3--17. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Ben-Amram, A. and Lee, C. S. 2007. Program termination analysis in polynomial time. Trans. Program. Lang. Sys. 29, 1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Codish, M. Lagoon, V. and Stuckey, P. 2005. Testing for termination with monotonicity constraints. In Proceedings of the 21st International Conf. on Logic Programming, (ICLP'05). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Cormen, T. H., Leiserson, C. E., Rivest, R. L., and Stein, C. 2001. Introduction to Algorithms. MIT Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Dershowitz, N. and Manna, Z. 1979. Proving termination with multiset orderings. Comm. ACM 22, 8, 465--476. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Frederiksen, C. C. 2001. A simple implementation of the size-change principle. Tech. Rep. D-442, DIKU, Denmark.Google ScholarGoogle Scholar
  10. Frederiksen, C. C. 2002. Automatic runtime analysis for first order functional programs. Tech. Rep. D-470, DIKU, Denmark.Google ScholarGoogle Scholar
  11. Glenstrup, A. and Jones, N. 2004. Termination analysis and specialization-point insertion in off-line partial evaluation. Tech. Rep. D-498, DIKU, Denmark.Google ScholarGoogle Scholar
  12. 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, 1--23.Google ScholarGoogle Scholar
  13. Lee, C. S., Jones, N. D., and Ben-Amram, A. 2001. The size-change principle for program termination. In Proceedings of the 28th ACM Symposium on Principles of Programming Languages, (POPL'01). ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Manolios, P. and Vroon, D. 2006. Termination Analysis with Calling Context Graphs. In Proceedings of the 18th International Conf. on Computer Aided Verification (CAV'06). Springer, 401--414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Muller, D. and Schupp, P. 1995. Simulating Alternating Tree Automata by Nondeterministic Automata: New Results and New Proofs of the Theorems of Rabin, McNaughton and Safra. Theo. Comput. Sci. 141, 1&2, 69--107. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Safra, S. 1988. On the Complexity of ω-Automata. In Proceedings of the 29th Symposium on Foundations of Computer Science (FOCS'88). IEEE, 319--327. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Thiemann, R. and Giesl, J. 2003. Size-change termination for term rewriting. In Proceedings of the 14th International Conf. on Rewriting Techniques and Applications (RTA'03). Lecture Notes in Computer Science, vol. 2706. Springer, 264--278. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Vardi, M. 1996. An automata-theoretic approach to linear temporal logic. In Banff Higher Order Workshop. Lecture Notes in Computer Science, vol. 1043. Springer, 238--266. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Wahlstedt, D. 2000. Detecting termination using size-change in parameter values. Master's thesis, Göteborgs Universitet, Sweden.Google ScholarGoogle Scholar

Index Terms

  1. Ranking functions for size-change termination

              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

              • Published in

                cover image ACM Transactions on Programming Languages and Systems
                ACM Transactions on Programming Languages and Systems  Volume 31, Issue 3
                April 2009
                185 pages
                ISSN:0164-0925
                EISSN:1558-4593
                DOI:10.1145/1498926
                Issue’s Table of Contents

                Copyright © 2009 ACM

                Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 21 April 2009
                • Accepted: 1 April 2008
                • Revised: 1 October 2007
                • Received: 1 April 2007
                Published in toplas Volume 31, Issue 3

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • research-article
                • Research
                • Refereed

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader