Termination analysis for Mercury

  • Chris Speirs
  • Zoltan Somogyi
  • Harald Søndergaard
Logic Programming II
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1302)


Since the late eighties, much progress has been made in the theory of termination analysis for logic programs. However, the practical significance of much of this work is hard to judge, since experimental evaluations rarely get published. Here we describe and evaluate a termination analyzer for Mercury, a strongly typed and moded logic-functional programming language. Mercury's high degree of referential transparency and the guaranteed availability of reliable mode information simplify termination analysis. Our analyzer uses a variant of a method developed by Plümer. It deals with full Mercury, including modules and I/O. In spite of these obstacles, it produces state-of-the-art termination information, while having a negligible impact on the running time of the compiler of which it is part, even for large programs.


Logic Program Recursive Call Execution Path Mode Information Program Point 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    K.R. Apt and D. Pedreschi. Reasoning about termination of pure Prolog programs. In Advances in Logic Programming Theory, pages 183–229. Oxford University Press, 1994.Google Scholar
  2. 2.
    Michel Berkelaar. lp-solve v. 2.0. Scholar
  3. 3.
    Roland N. Bol. Loop Checking in Logic Programming. PhD thesis, University of Amsterdam, The Netherlands, 1991.Google Scholar
  4. 4.
    A. Bossi, N. Cocco, and M. Fabris. Proving termination of logic programs by exploiting term properties. In S. Abramsky and T. S. E. Maibaum, editors, Proc. TAPSOFT'91, vol. 2, LNCS 494, pages 153–180. Springer-Verlag, 1991.Google Scholar
  5. 5.
    A. Bossi, N. Cocco, and M. Fabris. Typed norms. In B. Krieg-Brückner, editor, Proc. ESOP'92, LNCS 582, pages 73–92. Springer-Verlag, 1992.Google Scholar
  6. 6.
    A. Brodsky and Y. Sagiv. Inference of inequality constraints in logic programs (extended abstract). In Proc. Tenth ACM Symp. Principles of Database Systems, pages 227–240. ACM Press, 1991.Google Scholar
  7. 7.
    F. Bueno, M. Garcia de la Banda, and M. Hermenegildo. Effectiveness of global analysis in strict independence-based automatic program parallelization. In M. Bruynooghe, editor, Proc. ILPS'94, pages 320–336. MIT Press, 1994.Google Scholar
  8. 8.
    Danny De Schreye and Stefaan Decorte. Termination of logic programs: The neverending story. Journal of Logic Programming, 19/20:199–260, 1994.Google Scholar
  9. 9.
    Gerhard Gröger and Lutz Plümer. Handling of mutual recursion in automatic termination proofs for logic programs. In K. Apt, editor, Proc. Joint Int. Conf. Symp. Logic Programming, pages 336–350. MIT Press, 1992.Google Scholar
  10. 10.
    F. Henderson, T. Conway, Z. Somogyi, and D. Jeffery. The Mercury language reference manual. Technical Report 96/10, Dept. of Computer Science, University of Melbourne, 1996.Google Scholar
  11. 11.
    N. Lindenstrauss and Y. Sagiv. Automatic termination analysis of logic programs (with detailed experimental results).; Shorter version to appear in L. Naish, editor, Logic Programming: Proc. Int. Conf. Logic Programming, MIT Press, 1997.Google Scholar
  12. 12.
    Lutz Plümer. Termination Proofs for Logic Programs. LNAI 446. Springer-Verlag, 1990.Google Scholar
  13. 13.
    Kirack Sohn and Allen Van Gelder. Termination detection in logic programs using argument sizes (extended abstract). In Proc. Tenth ACM Symp. Principles of Database Systems, pages 216–226. ACM Press, 1991.Google Scholar
  14. 14.
    C. Speirs, Z. Somogyi, and H. Søndergaard. Termination analysis for Mercury. Technical Report 97/9, Dept. of Computer Science, University of Melbourne, 1997. Scholar
  15. 15.
    Jeffrey D. Ullman and Allen Van Gelder. Efficient tests for top-down termination of logical rules. Journal of the ACM, 35(2):345–373, 1988.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1997

Authors and Affiliations

  • Chris Speirs
    • 1
  • Zoltan Somogyi
    • 1
  • Harald Søndergaard
    • 1
  1. 1.Dept. of Computer ScienceUniversity of MelbourneParkvilleAustralia

Personalised recommendations