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 FLOW ⊆ DESC (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.
- 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 ScholarDigital Library
- 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 Scholar
- Avery, J. 2005. The size-change termination principle on non well founded data types. Tech. Rep., DIKU, Denmark.Google Scholar
- 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 ScholarDigital Library
- Ben-Amram, A. and Lee, C. S. 2007. Program termination analysis in polynomial time. Trans. Program. Lang. Sys. 29, 1. Google ScholarDigital Library
- 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 ScholarDigital Library
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., and Stein, C. 2001. Introduction to Algorithms. MIT Press. Google ScholarDigital Library
- Dershowitz, N. and Manna, Z. 1979. Proving termination with multiset orderings. Comm. ACM 22, 8, 465--476. Google ScholarDigital Library
- Frederiksen, C. C. 2001. A simple implementation of the size-change principle. Tech. Rep. D-442, DIKU, Denmark.Google Scholar
- Frederiksen, C. C. 2002. Automatic runtime analysis for first order functional programs. Tech. Rep. D-470, DIKU, Denmark.Google Scholar
- Glenstrup, A. and Jones, N. 2004. Termination analysis and specialization-point insertion in off-line partial evaluation. Tech. Rep. D-498, DIKU, Denmark.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- Wahlstedt, D. 2000. Detecting termination using size-change in parameter values. Master's thesis, Göteborgs Universitet, Sweden.Google Scholar
Index Terms
- Ranking functions for size-change termination
Recommendations
Size-change termination with difference constraints
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 ...
Regular approximation and bounded domains for size-change termination
PEPM '10: Proceedings of the 2010 ACM SIGPLAN workshop on Partial evaluation and program manipulationAbstract The size-change principle devised by Lee, Jones and Ben-Amram, provides an effective method of determining program termination for recursive functions. It relies on a regular approximation to the call structure of the program, operates only ...
Size-change termination for term rewriting
RTA'03: Proceedings of the 14th international conference on Rewriting techniques and applicationsIn [13], a new size-change principle was proposed to verify termination of functional programs automatically. We extend this principle in order to prove termination and innermost termination of arbitrary term rewrite systems (TRSs). Moreover, we compare ...
Comments