skip to main content
article
Free Access

Termination analysis of logic programs through combination of type-based norms

Published:01 April 2007Publication History
Skip Abstract Section

Abstract

This article makes two contributions to the work on semantics-based termination analysis for logic programs. The first involves a novel notion of type-based norm where for a given type, a corresponding norm is defined to count in a term the number of subterms of that type. This provides a collection of candidate norms, one for each type defined in the program. The second enables an analyzer to base termination proofs on the combination of several different norms. This is useful when different norms are better suited to justify the termination of different parts of the program. Application of the two contributions together consists in considering the combination of the type-based candidate norms for a given program. This results in a powerful and practical technique. Both contributions have been introduced into a working termination analyzer. Experimentation indicates that they yield state-of-the-art results in a fully automatic analysis tool, improving with respect to methods that do not use both types and combined norms.

References

  1. Apt, K. R. 1990. Introduction to logic programming. In Handbook of Theoretical Computer Science, vol. B: Formal Models and Semantics, J. van Leeuwen, ed. Elsevier, Amsterdam, and MIT Press, Cambridge, MA. 495--574. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Apt, K. R. 1997. From Logic Programming to Prolog. Prentice Hall. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Apt, K. R. and Pedreschi, D. 1993. Reasoning about termination of pure Prolog programs. Inf. Comput. 106, 1 (Sept.), 109--157. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Benoy, F. and King, A. 1996. Inferring argument size relationships with CLP(R). In Proceedings of the 6th International Workshop on Logic Program Synthesis and Transformation (LOPSTR). 204--223. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Bossi, A., Cocco, N., Etalle, S., and Rossi, S. 2002. On modular termination proofs of general logic programs. Theory Pract. Logic Program. 2, 3, 263--291. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Bossi, A., Cocco, N., and Fabris, M. 1991. Proving termination of logic programs by exploiting term properties. In Proceedings of the International Joint Conference on Theory and Practice of Software Development (TAPSOFT), vol. 2. S. Abramsky and T. Maibaum Eds. Lecture Notes in Computer Science, vol. 494. Springer Verlag, Berlin. 153--180. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Bossi, A., Cocco, N., and Fabris, M. 1992. Typed norms. In Proceeedings of the 4th European Symposium on Programming (ESOP), B. Krieg-Brückner, ed. Lecture Notes in Computer Science, vol. 582. Springer Verlag, Berlin. 73--92. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Brodsky, A. and Sagiv, Y. 1989. Inference of monotonicity constraints in Datalog programs. In Proceedings of the 8th ACM SIGACT-SIGART-SIGMOD Symposium on Principles of Database Systems. 190--199. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Bruynooghe, M., Codish, M., Genaim, S., and Vanhoof, W. 2002. Reuse of results in termination analysis of typed logic programs. In Proceedings of the 9th International Static Analysis Symposium, M. Hermenegildo and G. Puebla, eds. Lecture Notes in Computer Science, vol. 2477. Springer Verlag. 477--492. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Bruynooghe, M., Codish, M., Genaim, S., and Vanhoof, W. 2003. A note on the reuse of the results of a termination analysis based on polymorphic types. Tech. Rep., Katholieke Universiteit Leuven, Department of Computer Science. Rep. CW 383. http://www.cs.kuleuven.ac.be/publicaties/rapporten/cw/CW383.abs.html.Google ScholarGoogle Scholar
  11. Bruynooghe, M., Gallagher, J. P., and Van Humbeeck, W. 2005. Inference of well-typings for logic programs with application to termination analysis. In Proceedings of the 12th International Static Analysis Symposium (SAS). C. Hankin and I. Siveroni Eds. Lecture Notes in Computer Science, vol. 3672, Springer Verlag, 35--51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Bruynooghe, M., Vanhoof, W., and Codish, M. 2001. Pos(T): Analyzing dependencies in typed logic programs. In Proceedings of the Perspectives of System Informatics, 4th International Andrei Ershov Memorial Conference, (PSI). Lecture Notes in Computer Science, vol. 2244. Springer Verlag. 406--420. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Codish, M. and Genaim, S. 2003. Proving termination one loop at time. In Proceedings of the 13th International Workshop on Logic Programming Environments, F. Mesnard and A. Serebrenik, eds. http://www.cs.kuleuven.ac.be/publicaties/rapporten/cw/CW371.abs.html.Google ScholarGoogle Scholar
  14. Codish, M., Genaim, S., Bruynooghe, M., Gallagher, J., and Vanhoof, W. 2003. One loop at a time. In 6th International Workshop on Termination. http://www.dsic.upv.es/rdp03/wst/proceedings.html.Google ScholarGoogle Scholar
  15. Codish, M. and Taboch, C. 1999. A semantic basis for the termination analysis of logic programs. J. Logic Program. 41, 1, 103--123.Google ScholarGoogle ScholarCross RefCross Ref
  16. Cousot, P. and Halbwachs, N. 1978. Automatic discovery of linear restraints among variables of a program. In Proceedings of the 5th Annual ACM Symposium on Principles of Programming Languages. 84--96. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. De Schreye, D. and Verschaetse, K. 1995. Deriving linear size relations for logic programs by abstract interpretation. New Gen. Comput. 13, 2, 117--154.Google ScholarGoogle ScholarCross RefCross Ref
  18. De Schreye, D., Verschaetse, K., and Bruynooghe, M. 1992. A framework for analyzing the termination of definite logic programs with respect to call patterns. In Proceedings of the International Conference on 5th Generation Computer Systems (Japan). 481--488.Google ScholarGoogle Scholar
  19. Decorte, S., De Schreye, D., and Fabris, M. 1993. Automatic inference of norms: A missing link in automatic termination analysis. In Logic Programming - Proceedings of the International Symposium (Vancouver, Canada), D. Miller, ed. MIT Press (Cambridge, MA.) 420--436. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Decorte, S., De Schreye, D., and Fabris, M. 1996. Integrating types in termination analysis. Tech. Rep. CW 222, K.U. Leuven, Department of Computer Science.Google ScholarGoogle Scholar
  21. Decorte, S., De Schreye, D., and Fabris, M. 1997. Exploiting the power of typed norms in automatic inference of interargument relations. Tech. Rep. CW 246, K.U. Leuven, Department of Computer Science.Google ScholarGoogle Scholar
  22. Dershowitz, N. 1995. 33 examples of termination. In French Spring School of Theoretical Computer Science Advanced Course on Term Rewriting (Font Romeux, France, May), H. Comon and J.-P. Jouannaud, eds. Lecture Notes in Computer Science, vol. 909. Springer Verlag. 16--26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Dershowitz, N., Lindenstrauss, N., Sagiv, Y., and Serebrenik, A. 2001. A general framework for automatic termination analysis of logic programs. App. Algebra Eng. Commun. Comput. 12, 1--2, 117--156.Google ScholarGoogle ScholarCross RefCross Ref
  24. Dershowitz, N. and Manna, Z. 1979. Proving termination with multiset orderings. Commun. ACM 22, 465--476. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Gabbrielli, M. and Giacobazzi, R. 1994. Goal independency and call patterns in the analysis of logic programs. In Proceedings of the 9th ACM Symposium on Applied Computing. ACM Press, New York, 394--399. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Gallagher, J. and Puebla, G. 2002. Abstract interpretation over non-deterministic finite tree automata for set-based analysis of logic programs. In Proceedings of the Practical Aspects of Declarative Languages, 4th International Symposium (Portland, OR, Jan. 19--20), S. Krishnamurthi and C. R. Ramakrishnan, eds. Lecture Notes in Computer Science, vol. 2257. Springer, Verlag. 243--261. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Gallagher, J. P. and de Waal, D. A. 1994. Fast and precise regular approximations of logic programs. In Proceedings of the 11th International Conference on Logic Programming (Santa Margherita Ligure, Italy), P. Van Hentenryck, ed. MIT Press, Cambridge, MA. 599--613. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Genaim, S. and Codish, M. 2005. Inferring termination conditions for logic programs using backwards analysis. Theory Pract. Logic Program. 5, 1--2, 75--91. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Genaim, S., Codish, M., Gallagher, J., and Lagoon, V. 2002. Combining norms to prove termination. In Proceedings of the 3rd International Workshop on Verification, Model Checking and Abstract Interpretation, A. Cortesi, ed. Lecture Notes in Computer Science, vol. 2294. Springer Verlag. 126--138. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Graham, R. L., Rothschild, B. L., and Spencer, J. H. 1980. Ramsey Theory. Wiley-Interscience Series in Discrete Mathematics. John Wiley, New York.Google ScholarGoogle Scholar
  31. Hill, P. M. and Topor, R. W. 1992. A semantics for typed logic programs. In Types in Logic Programming, F. Pfenning, ed. MIT Press, Cambridge, MA.Google ScholarGoogle Scholar
  32. Karr, M. 1976. Affine relationships among variables of a program. Acta Inf. 6, 133--151.Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. King, A., Shen, K., and Benoy, F. 1997. Lower-Bound time-complexity analysis of logic programs. In Proceedings of the International Symposium on Logic Programming, J. Maluszynski, ed. MIT Press, Cambridge, MA. 261--276. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Lagoon, V. 2004. Analysis of typed logic programs. Ph.D. thesis, the University of Melbourne, Australia.Google ScholarGoogle Scholar
  35. Lagoon, V., Mesnard, F., and Stuckey, P. 2003. Termination analysis with types is more accurate. In Proceedings of the 19th International Conference on Logic Programming, C. Palamidessi, ed. Lecture Notes in Computer Science, vol. 2916. Springer Verlag. 254--268.Google ScholarGoogle Scholar
  36. Lagoon, V. and Stuckey, P. 2001. A framework for analysis of typed logic programs. In Proceedings of the 5th International Symposium on Functional and Logic Programming (FLOPS). Lecture Notes in Computer Science, vol. 2024. Springer Verlag. 296--310. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Lee, C. S. 2002. Program termination analysis and termination of offline partial evaluation. Ph.D. thesis, University of Western Australia.Google ScholarGoogle Scholar
  38. Lee, C. S., Jones, N. D., and Ben-Amram, A. M. 2001. The size-change principle for program termination. ACM SIGPLAN Not. 36, 3, 81--92. In Proceedings of the Symposium on Principles of Programming Languages (POPL). Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Lindenstrauss, N. and Sagiv, Y. 1997. Automatic termination analysis of logic programs. In Proceedings of the 14th International Conference on Logic Programming (Leuven, Belgium), L. Naish, ed. MIT Press, Cambridge, MA. 63--77.Google ScholarGoogle Scholar
  40. Lloyd, J. 1987. Foundations of Logic Programming, 2nd ed. Springer-Verlag, Berlin. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Marriott, K. and Søndergaard, H. 1993. Precise and efficient groundness analysis for logic programs. ACM Lett. Program. Lang. Syst. 2, 1-4, 181--196. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Martin, J., King, A., and Soper, P. 1996. Typed norms for typed logic programs. In Logic Programming Synthesis and Transformation, 6th International Workshop (LOPSTR), J. P. Gallagher, ed. Lecture Notes in Computer Science, vol. 1207. Springer Verlag, 224--238. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Mesnard, F. 1996. Inferring left-terminating classes of queries for constraint logic programs. In Proceedings of the Joint International Conference and Syposium on Logic Programming (Bonn, Germany), M. J. Maher, ed. MIT Press, Cambridge, MA. 7--21.Google ScholarGoogle Scholar
  44. Mesnard, F. and Neumerkel, U. 2001. Applying static analysis techniques for inferring termination conditions of logic programs. In Static Analysis, 8th International Symposium, P. Cousot, ed. Lecture Notes in Computer Science, vol. Springer Verlag. 2126. 93--110. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Mycroft, A. and O'Keefe., R. 1984. A polymorphic type system for Prolog. Artif. Intell. 23, 3, 295--307. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Ramsey, F. 1930. On a problem of formal logic. In Proceedings of the London Mathematical Society, vol. 30. 264--286.Google ScholarGoogle ScholarCross RefCross Ref
  47. Serebrenik, A. and De Schreye, D. 2001. Non-Transformational termination analysis of logic programs, based on general term-orderings. In Logic Based Program Synthesis and Transformation, 10th International Workshop (LOPSTR). (London, UK, Jul. 24--28), K.-K. Lau, ed. Lecture Notes in Computer Science, vol. 2042. Springer Verlag. 69--85. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. Somogyi, Z., Henderson, F., and Conway, T. 1996. The execution algorithm of Mercury, an efficient purely declarative logic programming language. J. Logic Program. 29, 1--3, 17--64.Google ScholarGoogle ScholarCross RefCross Ref
  49. Sterling, L. and Shapiro, E. 1994. The Art of Prolog, 2nd ed. MIT Press, Cambridge, MA. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. Taboch, C., Genaim, S., and Codish, M. 2002. Terminweb: Semantic based termination analyser for logic programs. http://www.cs.bgu.ac.il/~mcodish/TerminWeb.Google ScholarGoogle Scholar
  51. Vanhoof, W. and Bruynooghe, M. 2002. When size does matter. In Logic Based Program Synthesis and Transformation, 11th International Workshop (LOPSTR), A. Pettorossi, ed. Lecture Notes in Computer Science, vol. 2372. Springer Verlag. 129--147. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Vaucheret, C. and Bueno, F. 2002. More precise yet efficient type inference for logic programs. In Proceedings of the 9th International Static Analysis Symposium. M. Hermenegildo and G. Puebla, eds. Lecture Notes in Computer Science, vol. 2477. Springer Verlag. 102--116. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Termination analysis of logic programs through combination of type-based norms

          Recommendations

          Reviews

          German Vidal

          Establishing that all computations terminate is a fundamental, though generally undecidable, property of computer programs. Therefore, termination analyses that approximate this property have been developed for different programming languages. This paper focuses on the definition of a termination analysis for logic programs (roughly speaking, simple Prolog programs). In this context, termination analyses proceed by first identifying the program loops and then by looking for a ranking function that maps every call to a well-founded domain so that its value decreases every time a loop is executed. The so-called global approach considers a single ranking function for all loops, while the more flexible local approach allows the use of different ranking functions. In the context of logic programs, ranking functions are often based on the notion of “norm,” a mapping used to measure the size of the arguments of a call. In this context, the authors show that by providing type declarations (which is not usually required in Prolog implementations), a collection of simple, type-based norms can be automatically inferred. Intuitively speaking, a type-based norm counts the number of subterms in a term of the given type. Then, the authors show that using the combination of different type-based norms as a basis for the definition of ranking functions (following the local approach) results in a more precise termination analysis than existing analyses. The paper is well written, includes a good introduction to its main subject, and contains many examples that illustrate the technical developments. It also includes formal proofs of correctness and provides a summary of results from a complete experimental evaluation. The results are not surprising, but show that the new approach is actually useful in practice. 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

          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!