skip to main content
research-article
Free Access

Automated termination proofs for haskell by term rewriting

Published:07 February 2011Publication History
Skip Abstract Section

Abstract

There are many powerful techniques for automated termination analysis of term rewriting. However, up to now they have hardly been used for real programming languages. We present a new approach which permits the application of existing techniques from term rewriting to prove termination of most functions defined in Haskell programs. In particular, we show how termination techniques for ordinary rewriting can be used to handle those features of Haskell which are missing in term rewriting (e.g., lazy evaluation, polymorphic types, and higher-order functions). We implemented our results in the termination prover AProVE and successfully evaluated them on existing Haskell libraries.

Skip Supplemental Material Section

Supplemental Material

References

  1. Abel, A. 2004. Termination checking with types. RAIRO Theor. Inform. Appl. 38, 4, 277--319.Google ScholarGoogle ScholarCross RefCross Ref
  2. Alarcón, B., Gutiérrez, R., and Lucas, S. 2006. Context-Sensitive dependency pairs. In Proceedings of the Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS'06). Lecture Notes in Computer Science, vol. 4337, Springer, 298--309. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Alarcón, B., Emmes, F., Fuhs, C., Giesl, J., Gutiérrez, R., Lucas, S., Schneider-Kamp, P., and Thiemann, R. 2008. Improving context-sensitive dependency pairs. In Proceedings of the International Conference on Logic Programming, Artificial Intelligence and Reasoning (LPAR'08). Lecture Notes in Artificial Intelligence, Springer, vol. 5330, 636--651. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Albert, E., Arenas, P., Codish, M., Genaim, S., Puebla, G., and Zanardini, D. 2008. Termination analysis of Java bytecode. In Proceedings of the International Conference on Formal Methods for Open Object-Based Distributed Systems (FMOODS'08). Lecture Notes in Computer Science, vol. 5051, Springer, 2--18. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Arts, T. and Giesl, J. 2000. Termination of term rewriting using dependency pairs. Theor. Comput. Sci. 236, 133--178. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Barthe, G., Frade, M. J., Giménez, E., Pinto, L., and Uustalu, T. 2000. Type-Based termination of recursive definitions. Math. Struct. Comput. Sci. 14, 1, 1--45. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Berdine, J., Cook, B., Distefano, D., and O'Hearn, P. 2006. Automatic termination proofs for programs with shape-shifting heaps. In Proceedings of the International Conference on Computer-Aided Verification (CAV'06). Lecture Notes in Computer Science, vol. 4144, Springer, 386--400. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Blanqui, F. 2004. A type-based termination criterion for dependently-typed higher-order rewrite systems. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'04). Lecture Notes in Computer Science, vol. 3091, Springer, 24--39.Google ScholarGoogle ScholarCross RefCross Ref
  9. Bradley, A. R., Manna, Z., and Sipma, H. B. 2005. Termination of polynomial programs. In Proceedings of the Conference on Verification, Model-Checking and Abstract Interpretation (VMCAI'05). Lecture Notes in Computer Science, vol. 3385, Springer, 113--129. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Brockschmidt, M., Otto, C., von Essen, C., and Giesl, J. 2010. Termination graphs for Java bytecode. In Verification, Induction, Termination Analysis. Lecture Notes in Computer Science, vol. 6463, Springer, 17--37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Chawdhary, A., Cook, B., Gulwani, S., Sagiv, M., and Yang, H. 2008. Ranking abstractions. In Proceedings of the European Symposium on Programming (ESOP'08). Lecture Notes in Computer Science, vol. 4960, Springer, 148--162. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Colón, M. and Sipma, H. 2002. Practical methods for proving program termination. In Proceedings of the International Conference on Computer-Aided Verification (CAV'02). Lecture Notes in Computer Science, vol. 2034, Springer, 442--454. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Cook, B., Podelski, A., and Rybalchenko, A. 2006. Termination proofs for systems code. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI'06). ACM Press, 415--426. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Dershowitz, N. 1987. Termination of rewriting. J. Symb. Comput. 3, 1-2, 69--116. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Endrullis, J., Waldmann, J., and Zantema, H. 2008. Matrix interpretations for proving termination of term rewriting. J. Autom. Reason. 40, 2-3, 195--220. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Endrullis, J. and Hendriks, D. 2009. From outermost to context-sensitive rewriting. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'09). Lecture Notes in Computer Science, vol. 5595, Springer, 305--319. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Falke, S. and Kapur, D. 2008. Dependency pairs for rewriting with built-in numbers and semantic data structures. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'08). Lecture Notes in Computer Science, vol. 5117, Springer, 94--109. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Fuhs, C., Giesl, J., Plücker, M., Schneider-Kamp, P., and Falke, S. 2009. Proving termination of integer term rewriting. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'09). Lecture Notes in Computer Science, vol. 5595, Springer, 32--47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Geser, A., Hofbauer, D., and Waldmann, J. 2004. Match-Bounded string rewriting systems. Applic. Algebr. Engin., Comm. Comput. 15, 3, 149--171. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Giesl, J. 1995. Termination analysis for functional programs using term orderings. In Proceedings of the International Static Analysis Symposium (SAS'95). Lecture Notes in Computer Science, vol. 983, Springer, 154--171. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Giesl, J. and Middeldorp, A. 2004. Transformation techniques for context-sensitive rewrite systems. J. Funct. Program. 14, 4, 379--427. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Giesl, J., Thiemann, R., and Schneider-Kamp, P. 2005a. The dependency pair framework: Combining techniques for automated termination proofs. In Proceedings of the International Conference on Logic Programming, Artificial Intelligence and Reasoning (LPAR'04). Lecture Notes in Artificial Intelligence, vol. 3452, 301--331.Google ScholarGoogle Scholar
  23. Giesl, J., Thiemann, R., and Schneider-Kamp, P. 2005b. Proving and disproving termination of higher-order functions. In Proceedings of the International Workshop on Frontiers of Combining Systems (FroCoS'05). Lecture Notes in Artificial Intelligence, vol. 3717, 216--231. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Giesl, J., Swiderski, S., Schneider-Kamp, P., and Thiemann, R. 2006a. Automated termination analysis for Haskell: From term rewriting to programming languages. In Proceedings of the International Conference on Rewriting Techniques and Applidations (RTA'06). Lecture Notes in Computer Science, Springer, vol. 4098, Springer, 297--312. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Giesl, J., Schneider-Kamp, P., and Thiemann, R. 2006b. AProVE 1.2: Automatic termination proofs in the dependency pair framework. In Proceedings of the International Conference on Automated Reasoning (IJCAR'06). Lecture Notes in Artificial Intelligence, Springer, vol. 4130, 281--286. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Giesl, J., Thiemann, R., Schneider-Kamp, P., and Falke, S. 2006c. Mechanizing and improving dependency pairs. J. Autom. Reason. 37, 3, 155--203. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Glenstrup, A. J. and Jones, N. D. 2005. Termination analysis and specialization-point insertion in offline partial evaluation. ACM Trans. Program. Lang. Syst. 27, 6, 1147--1215. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Gnaedig, I. and Kirchner, H. 2008. Termination of rewriting under strategies. ACM Trans. Comput. Logic 10, 3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Hanus, M. 2007. Multi-paradigm declarative languages. In Proceedings of the International Conference on Logic Programming (ICLP'07). Lecture Notes in Computer Science, vol. 4670, Springer, 45--75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Hirokawa, N. and Middeldorp, A. 2005. Automating the dependency pair method. Inform. Comput. 199, 1-2, 172--199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Hirokawa, N. and Middeldorp, A. 2007. Tyrolean termination tool: Techniques and features. Inform. Comput. 205, 4, 474--511. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Hirokawa, N., Middeldorp, A., and Zankl, H. 2008. Uncurrying for termination. In Proceedings of the International Conference on Logic Programming, Artificial Intelligence and Reasoning (LPAR'08). Lecture Notes in Artificial Intelligence, vol. 5330, 667--681. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Jones, M. and Peterson, J. 1999. The Hugs 98 user manual. http://www.haskell.org/hugs/Google ScholarGoogle Scholar
  34. Kennaway, R., Klop, J. W., Sleep, M. R., and de Vries, F. J. 1996. Comparing curried and uncurried rewriting. J. Symb. Comput. 21, 1, 15--39. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Kobayashi, N. 2009. Types and higher-order recursion schemes for verification of higher-order programs. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL'09). ACM Press, 416--428. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Korp, M., Sternagel, C., Zankl, H., and Middeldorp, A. 2009. Tyrolean termination tool 2. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'09). Lecture Notes in Computer Science, vol. 5595, Springer, 295--304. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Lee, C. S., Jones, N. D., and Ben-Amram, A. M. 2001. The size-change principle for program termination. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL'01). ACM Press, 81--92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Lucas, S. 1998. Context-Sensitive computations in functional and functional logic programs. J. Funct. Logic Program.1, 1--61.Google ScholarGoogle Scholar
  39. Manolios, P. and Vroon, D. 2006. Termination analysis with calling context graphs. In Proceedings of the International Conference on Computer-Aided Verification (CAV'06). Lecture Notes in Computer Science, vol. 4144, Springer, 401--414. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Ong, C.-H. L. 2006. On model-checking trees generated by higher-order recursion schemes. In Proceedings of the Annual IEEE Symposium on Logic in Computer Science (LICS'06). IEEE, 81--90. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Otto, C., Brockschmidt, M., von Essen, C., and Giesl, J. 2010. Automated termination analysis of Java bytecode by term rewriting. In Proceedings of the International Conference on Rewriting Techniques and Applications (RTA'10). LIPIcs, vol. 6, 259--276.Google ScholarGoogle Scholar
  42. Panitz, S. E. and Schmidt-Schauß, M. 1997. TEA: Automatically proving termination of programs in a non-strict higher-order functional language. In Proceedings of the International Static Analysis Symposium (SAS'97). Lecture Notes in Computer Science, vol. 1302, Springer, 345--360. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Panitz, S. E. 1997. Generierung statischer Programminformation zur Kompilierung verzögert ausgewerteter funktionaler Programmiersprachen. Ph.D. thesis, University of Frankfurt.Google ScholarGoogle Scholar
  44. Peyton Jones, S. 2003. Haskell 98 Languages and Libraries: The Revised Report. Cambridge University Press.Google ScholarGoogle Scholar
  45. Podelski, A. and Rybalchenko, A. 2004a. A complete method for the synthesis of linear ranking functions. In Proceedings of the Conference on Verification, Model-Checking and Abstract Interpretation (VMCAI'04). Lecture Notes in Computer Science, vol. 2937, Springer, 239--251.Google ScholarGoogle ScholarCross RefCross Ref
  46. Podelski, A. and Rybalchenko, A. 2004b. Transition invariants. In Proceedings of the Annual IEEE Symposium on Logic in Computer Science (LICS'04). IEEE, 32--41. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Raffelsieper, M. 2007. Improving efficiency and power of automated termination analysis for Haskell. Diploma thesis, RWTH Aachen. http://aprove.informatik.rwth-aachen.de/eval/Haskell/DA/Raffelsieper_DA.pdfGoogle ScholarGoogle Scholar
  48. Raffelsieper, M. and Zantema, H. 2009. A transformational approach to prove outermost termination automatically. In Proceedings of the International Workshop on Reduction Strategies in Rewriting and Programming (WRS'08). ENTCS, vol. 237, 3--21. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. Rondon, P. M., Kawaguchi, M., and Jhala, R. 2008. Liquid types. In Proceedings of the Conference on Programming Language Design and Implementation (PLDI'08). ACM Press, 159--169. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Schneider-Kamp, P., Giesl, J., Serebrenik, A., and Thiemann, R. 2009. Automated termination proofs for logic programs by term rewriting. ACM Trans. Comput.Logic 11, 1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Schneider-Kamp, P., Giesl, J., Ströder, T., Serebrenik, A., and Thiemann, R. 2010. Automated termination analysis for logic programs with cut. Theory Pract. Logic Program. 10, 4-6, 365--381. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Sereni, D. and Jones, N. D. 2005. Termination analysis of higher-order functional programs. In Proceedings of the Asian Symposium on Programming Languages and Systems (APLAS'05). Lecture Notes in Computer Science, vol. 3780, Springer, 281--297. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. Sereni, D. 2007. Termination analysis and call graph construction for higher-order functional programs. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP'07). ACM Press, 71--84. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Sørensen, M. H. and Glück, R. 1995. An algorithm of generalization in positive supercompilation. In Proceedings of the International Logic Programming Symposium (ILPS'95). MIT Press, 465--479.Google ScholarGoogle Scholar
  55. Spoto, F., Mesnard, F., and Payet, É. 2010. A termination analyser for Java Bytecode based on path length. ACM Trans. Program. Lang. Syst. 32, 3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Swiderski, S. 2005. Terminierungsanalyse von Haskellprogrammen. Diploma thesis, RWTH Aachen. http://aprove.informatik.rwth-aachen.de/eval/Haskell/DA/Swiderski_DA.pdfGoogle ScholarGoogle Scholar
  57. Telford, A. and Turner, D. 2000. Ensuring termination in ESFP. J. Universal Comput. Sci. 6, 4, 474--488.Google ScholarGoogle Scholar
  58. Thiemann, R. and Giesl, J. 2005. The size-change principle and dependency pairs for termination of term rewriting. Applic. Algebr. Engin., Comm. Comput. 16, 4, 229--270. Google ScholarGoogle ScholarCross RefCross Ref
  59. Thiemann, R. 2009. From outermost termination to innermost termination. In Proceedings of the Conference on Current Trends in Theory and Practice of Informatics (SOFSEM'09). Lecture Notes in Computer Science, vol. 5404, Springer, 533--545. Google ScholarGoogle ScholarDigital LibraryDigital Library
  60. Tiwari, A. 2004. Termination of linear programs. In Proceedings of the International Conference on Computer-Aided Verification (CAV'04). Lecture Notes in Artificial Intelligence, Springer, vol. 3097, 70--82.Google ScholarGoogle ScholarCross RefCross Ref
  61. Walther, C. 1994. On proving the termination of algorithms by machine. Artif. Intell. 71, 1, 101--157. Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. Xi, H. 2002. Dependent types for program termination verification. Artif. Intell. 15, 1, 91--131. Google ScholarGoogle ScholarDigital LibraryDigital Library
  63. Xu, D. N., Peyton Jones, S., and Claessen, K. 2009. Static contract checking for Haskell. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL '09). ACM Press, 41--52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Zantema, H. 2003. Termination. In Term Rewriting Systems, Terese, Ed. Cambridge University Press, Chapter 6, 181--259.Google ScholarGoogle Scholar

Index Terms

  1. Automated termination proofs for haskell by term rewriting

            Recommendations

            Reviews

            Jacques Carette

            Automated analysis of software code is a fast-evolving field. Termination analysis is probably the most famous aspect, since it corresponds to the halting problem in computability. This undecidable problem is prototypical of an interesting phenomenon: though impossible to solve in all generality, in practice, there are powerful methods that frequently succeed in proving termination. Furthermore, recent advances also mean that the resulting tools can provide proofs in a reasonable amount of time-that is, they may soon be practical enough to be a part of one's standard development toolbox. Though the problem of (automatically) proving termination of imperative programs still seems quite difficult, the situation for functional programs seems otherwise, as this paper shows. This is likely due to the fact that the invariants in imperative programs more often seem to be arithmetic in nature, while invariants in functional programs are frequently structural. Thus, the latter are rather well suited to the powerful tools developed for proving termination of term rewriting. This well-written paper has a pleasant pedagogical style that is appropriate for someone who is knowledgeable in the area of programming languages but new to automated termination techniques. The authors formally define, lucidly explain, and motivate various ideas, such as H-termination, termination graphs, termination graph formation rules, and dependency pairs. The authors do an equally good job with the move to higher order and better handling of types. The treatment of type classes, though adequate, does not rise to the same level and appears somewhat overcomplicated. The paper ends with a set of experiments. While these certainly convey the authors' message that their techniques-implemented on top of the automated program verification environment (AProVE)-are rather effective, the analysis of the results seems rather shallow. For example, why would it be relevant to report absolute times__?__ As we continue to see rapid changes in this area, wouldn't the relative time of the analysis to type checking or compilation times be a more appropriate metric__?__ It is disconcerting to read that a 94-node graph is considered large, while most compiler writers would consider a 10,000-line program to be medium sized. Particularly intriguing is how much their rules resemble similar rules in partial evaluation and supercompilation. The key rule, instantiation, corresponds to generalization in partial evaluators; however, the set of heuristics used in both cases seems to be quite different. There might be an opportunity for further research in that area. Similarly, it is very natural to consider the relation between this analysis and abstract interpretation. The two are naturally related, but the details might be rather instructive. Anyone interested in automated analysis of functional programs would benefit from reading this paper, whether or not they are interested in termination analysis or Haskell in particular. Online Computing Reviews Service

            Access critical reviews of Computing literature here

            Become a reviewer for Computing Reviews.

            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 33, Issue 2
              January 2011
              128 pages
              ISSN:0164-0925
              EISSN:1558-4593
              DOI:10.1145/1890028
              Issue’s Table of Contents

              Copyright © 2011 ACM

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 7 February 2011
              • Accepted: 1 May 2010
              • Revised: 1 March 2010
              • Received: 1 July 2009
              Published in toplas Volume 33, Issue 2

              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
            About Cookies On This Site

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

            Learn more

            Got it!