Advertisement

Higher-Order and Symbolic Computation

, Volume 15, Issue 1, pp 91–131 | Cite as

Dependent Types for Program Termination Verification

  • Hongwei Xi
Article

Abstract

Program termination verification is a challenging research subject of significant practical importance. While there is already a rich body of literature on this subject, it is still undeniably a difficult task to design a termination checker for a realistic programming language that supports general recursion. In this paper, we present an approach to program termination verification that makes use of a form of dependent types developed in Dependent ML (DML), demonstrating a novel application of such dependent types to establishing a liveness property. We design a type system that enables the programmer to supply metrics for verifying program termination and prove that every well-typed program in this type system is terminating. We also provide realistic examples, which are all verified in a prototype implementation, to support the effectiveness of our approach to program termination verification as well as its unobtrusiveness to programming. The main contribution of the paper lies in the design of an approach to program termination verification that smoothly combines types with metrics, yielding a type system capable of guaranteeing program termination that supports a general form of recursion (including mutual recursion), higher-order functions, algebraic datatypes, and polymorphism.

termination dependent types 

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abel, A. and Altenkirch, T. A predicative strong normalisation proof for a λ-calculus with interleaving inductive types. In Proceedings of International Workshop on Types for Proof and Programs (TYPES '99), T. Coquand, P. Dybjer, B. Nordström, and J. Smith (Eds.). LNCS,Vol. 1956, Springer-Verlag, 2000, pp. 21–40.Google Scholar
  2. 2.
    BenCherifa, A. and Lescanne, P. Termination of rewriting systems by polynomial interpretations and its implementation. SCP, 9(2) (1987) 137–160.Google Scholar
  3. 3.
    Chang, C.C. and Keisler, H.J. Model Theory, Studies in Logic and Mathematical Foundations, Vol. 73. North-Holland, Amsterdam, The Netherlands, 1977.Google Scholar
  4. 4.
    Chin, W.-N. and Khoo, S.-C. Calculating sized types. Higher-Order and Symbolic Computation, 14(2/3), to appear.Google Scholar
  5. 5.
    Constable, R.L. et al. Implementing Mathematics with the NuPrl Proof Development System. Prentice-Hall, Englewood Cliffs, New Jersey, 1986.Google Scholar
  6. 6.
    Crary, K. and Weirich, S. Resource bound certification. In Proceedings of 27th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2000), Boston, 2000, pp. 184–198.Google Scholar
  7. 7.
    Dershowitz, N. Orderings for term rewriting systems. Theoretical Computer Science, 17(3) (1982) 279–301.Google Scholar
  8. 8.
    Dowek, G., Felty, A., Herbelin, H., Huet, G., Murthy, C., Parent, C., Paulin-Mohring, C., and Werner, B. The Coq proof assistant user's guide. Rapport Technique 154, INRIA, Rocquencourt, France. Version 5.8. 1993.Google Scholar
  9. 9.
    Girard, J.-Y. Interprétation Fonctionnelle et Élimination des Coupures dans l'Arithmétique d'Ordre Supérieur. Thèse de doctorat d'état, Université de Paris VII, Paris, France, 1972.Google Scholar
  10. 10.
    Girard, J.-Y., Lafont, Y., and Taylor, P. Proofs and Types, Cambridge Tracts in Theoretical Computer Science, Vol. 7, Cambridge University Press, Cambridge, England, 1989.Google Scholar
  11. 11.
    Grobauer, B. Cost recurrences for DML programs. In Proceedings of Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP'01), Florence, Italy, 2001, pp. 253–264.Google Scholar
  12. 12.
    Harper, R. Proof-directed debugging. Journal of Functional Programming, 9(4) (1999) 471–477.Google Scholar
  13. 13.
    Hughes, J., Pareto, L., and Sabry, A. Proving the correctness of reactive systems using sized types. In Conference Record of 23rd ACM SIGPLAN Symposium on Principles of Programming Languages (POPL '96), 1996, pp. 410–423.Google Scholar
  14. 14.
    Jouannaud, J.-P. and Rubio, A. The higher-order recursive path ordering. In Proceedings of 14th IEEE Symposium on Logic in Computer Science (LICS '99), Trento, Italy, 1999, pp. 402–411.Google Scholar
  15. 15.
    Lee, C.S., Jones, N.D., and Ben-Amram, A.M. The size-change principle for program termination. In Proceeding of the 28th ACM Symposium on Principles of Programming Languages (POPL '01), London, UK, 2001, pp. 81–92.Google Scholar
  16. 16.
    Milner, R., Tofte, M., Harper, R.W., and MacQueen, D. The Definition of Standard ML (Revised). MIT Press, Cambridge, Massachusetts, 1997.Google Scholar
  17. 17.
    Necula, G. Proof-carrying code. In Conference Record of 24th Annual ACM Symposium on Principles of Programming Languages, ACM Press, Paris, France, 1997, pp. 106–119.Google Scholar
  18. 18.
    Owre, S., Rajan, S., Rushby, J., Shankar, N., and Srivas, M. PVS: Combining specification, proof checking, and model checking. In Proceedings of the 8th International Conference on Computer-Aided Verification (CAV '96), R. Alur and T.A. Henzinger (Eds.). New Brunswick, NJ, LNCS, Vol. 1102, Springer-Verlag, 1996, pp. 411–414.Google Scholar
  19. 19.
    Paulson, L. Isabelle: A Generic Theorem Prover. LNCS, Vol. 828, Springer-Verlag, 1994.Google Scholar
  20. 20.
    Pientka, B. and Pfenning, F. Termination and reduction checking in the logical framework. In Proceedings of Workshop on Automation of Proofs by Mathematical Induction, Pittsburgh, PA, 2000.Google Scholar
  21. 21.
    Speirs, C., Somogyi, Z., and Søndergaard, H. Termination Analysis for Mercury. In Proceedings of the 4th Static Analysis Symposium (SAS '97), P.V. Hentenryck (Ed.). Paris, France, LNCS,Vol. 1302, Springer-Verlag, 1997, pp. 157–171.Google Scholar
  22. 22.
    Tait, W.W. Intensional interpretations of functionals of finite type I. Journal of Symbolic Logic, 32(2) (1967) 198–212.Google Scholar
  23. 23.
    Ullman, J.D. and Van Gelder, A. Efficient tests for top-down termination of logic rules. Journal of the ACM, 35(2) (1988) 345–373.Google Scholar
  24. 24.
    Xi, H. Dependent types in practical programming. Ph.D. Thesis, Carnegie Mellon University, 1998, pp. viii+189. Available as http://www.cs.cmu.edu/~hwxi/DML/thesis.ps.Google Scholar
  25. 25.
    Xi, H. Dependent ML, 1999. Available at http://www.cs.bu.edu/~hwxi/DML/DML.html.Google Scholar
  26. 26.
    Xi, H. Dependently typed data structures. In Proceedings of Workshop on Algorithmic Aspects of Advanced Programming Languages, Paris, France, 1999, pp. 17–33.Google Scholar
  27. 27.
    Xi, H. Dependent types for program termination verification, 2000. Available as http://www.cs.bu.edu/~hwxi/DML/Term.Google Scholar
  28. 28.
    Xi, H. and Pfenning, F. Eliminating array bound checking through dependent types. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, Montréal, Canada, 1998, pp. 249–257.Google Scholar
  29. 29.
    Xi, H. and Pfenning, F. Dependent types in practical programming. In Proceedings of ACM SIGPLAN Symposium on Principles of Programming Languages, San Antonio, Texas, 1999, pp. 214–227.Google Scholar
  30. 30.
    Zantema, H. Termination of term rewriting by semantic labelling. Fundamenta Informaticae, 24 (1995) 89–105.Google Scholar

Copyright information

© Kluwer Academic Publishers 2002

Authors and Affiliations

  • Hongwei Xi
    • 1
  1. 1.Computer Science DepartmentBoston UniversityBostonUSA

Personalised recommendations