# Nested General Recursion and Partiality in Type Theory

## Abstract

We extend Bove’s technique for formalising simple general recursive algrithms in constructive type theory to nested recursive algorithms. The method consists in defining an inductive special-purpose accessibility predicate, that characterizes the inputs on which the algorithm terminates. As a result, the type-theoretic version of the algorithm can be defined by structural recursion on the proof that the input values satisfy this predicate. This technique results in definitions in which the computational and logical parts are clearly separated; hence, the type-theoretic version of the algorithm is given by its purely functional content, similarly to the corresponding program in a functional programming language. In the case of nested recursion, the special predicate and the type-theoretic algorithm must be defined simultaneously, because they depend on each other. This kind of definitions is not allowed in ordinary type theory, but it is provided in type theories extended with Dybjer’s schema for simultaneous inductive-recursive definitions. The technique applies also to the formalisation of partial functions as proper type-theoretic functions, rather than relations representing their graphs.

## Keywords

Natural Number Type Theory Partial Function Recursive Algorithm Recursive Call## Preview

Unable to display preview. Download preview PDF.

## References

- [Acz77]P. Aczel. An Introduction to Inductive Definitions. In J. Barwise, editor,
*Handbook of Mathematical Logic*, pages 739–782. North-Holland Publishing Company, 1977.Google Scholar - [AGNvS94]T. Altenkirch, V. Gaspes, B. Nordström, and B. von Sydow.
*A User’s Guide to ALF*. Chalmers University of Technology, Sweden, May 1994. Available on the WWW ftp://ftp.cs.chalmers.se/pub/users/alti/alf.ps.Z.Google Scholar - [Aud91]P. Audebaud. Partial Objects in the Calculus of Constructions. In
*6th Annual IEEE Symposium on Logic in Computer Science*,*Amsterdam*, pages 86–95, July 1991.Google Scholar - [BB00]Antonia Balaa and Yves Bertot. Fix-point equations for well-founded recursion in type theory. In M. Aagaard, editors.
*Theorem Proving in Higher Order Logics: 13th International Conference, TPHOLs 2000*, volume 1869 of*Lecture Notes in Computer Science*. Springer-Verlag, 2000. Harrison and Aagaard [HA00]}, pages 1–16.CrossRefGoogle Scholar - [Bov01]A. Bove. Simple general recursion in type theory.
*Nordic Journal of Computing*, 8(1):22–42, Spring 2001.zbMATHMathSciNetGoogle Scholar - [CH88]Thierry Coquand and Gérard Huet. The Calculus of Constructions.
*Information and Computation*, 76:95–120, 1988.CrossRefzbMATHMathSciNetGoogle Scholar - [CM85]R. L. Constable and N. P. Mendler. Recursive Definitions in Type Theory. In
*Logic of Programs, Brooklyn*, volume 193 of*Lecture Notes in Computer Science*, pages 61–78. Springer-Verlag, June 1985.Google Scholar - [Con83]R. L. Constable. Partial Functions in Constructive Type Theory. In
*Theoretical Computer Science, 6th GI-Conference*,*Dortmund*, volume 145 of*Lecture Notes in Computer Science*, pages 1–18. Springer-Verlag, January 1983.Google Scholar - [CS87]R. L. Constable and S. F. Smith. Partial Objects in Constructive Type Theory. In
*Logic in Computer Science*,*Ithaca, New York*, pages 183–193, June 1987.Google Scholar - [Dyb00]Peter Dybjer. A general formulation of simultaneous inductive-recursive definitions in type theory.
*Journal of Symbolic Logic*, 65(2), June 2000.Google Scholar - [Gie97]J. Giesl. Termination of nested and mutually recursive algorithms.
*Journal of Automated Reasoning*, 19:1–29, 1997.zbMATHCrossRefMathSciNetGoogle Scholar - [HA00]J. Harrison and M. Aagaard, editors.
*Theorem Proving in Higher Order Logics: 13th International Conference, TPHOLs 2000*, volume 1869 of*Lecture Notes in Computer Science*. Springer-Verlag, 2000.zbMATHGoogle Scholar - [JHe
^{+}99]_Simon Peyton Jones, John Hughes, (editors), Lennart Augustsson, Dave Barton, Brian Boutel, Warren Burton, Joseph Fasel, Kevin Hammond, Ralf Hinze, Paul Hudak, Thomas Johnsson, Mark Jones, John Launchbury, Erik Meijer, John Peterson, Alastair Reid, Colin Runciman, and Philip Wadler. Report on the Programming Language Haskell 98, a Non-strict, Purely Functional Language. Available from http://haskell.org, February 1999. - [ML84]P. Martin-Löf.
*Intuitionistic Type Theory*. Bibliopolis, Napoli, 1984.Google Scholar - [MN94]L. Magnusson and B. Nordström. The ALF proof editor and its proof engine. In
*Types for Proofs and Programs*, volume 806 of*LNCS*, pages 213–237, Nijmegen, 1994. Springer-Verlag.Google Scholar - [Nor88]B. Nordström. Terminating General Recursion.
*BIT*, 28(3):605–619, October 1988.Google Scholar - [Pau86]L. C. Paulson. Proving Termination of Normalization Functions for Conditional Expressions.
*Journal of Automated Reasoning*, 2:63–74, 1986.zbMATHCrossRefMathSciNetGoogle Scholar - [Sli00]K. Slind. Another look at nested recursion. In M. Aagaard, editors.
*Theorem Proving in Higher Order Logics: 13th International Conference, TPHOLs 2000*, volume 1869 of*Lecture Notes in Computer Science*. Springer-Verlag, 2000. Harrison and Aagaard [HA00]}, pages 498–518.CrossRefGoogle Scholar