# General Recursion in Type Theory

[Doktorsavhandling]

This thesis deals with the use of constructive type theory as a programming language. In particular, it presents a method to translate general recursive functional programs into their type-theoretic equivalents.

A key notion in functional programming is recursion, which allows that the object being defined refers to itself. Associated with recursion is the problem of termination since, in general, there is no guarantee that a recursive function will always terminate. It is hence very important to have mechanisms to prove that a certain function terminates or even to ensure the termination of the function by the form of its definition. Examples of the latter are structurally recursive definitions, where every recursive call is performed on a structurally smaller argument.

Standard functional programming languages impose no restrictions on recursive programs and thus, they allow the definition of any general recursive function. There exist, though, less conventional functional programming languages where only terminating recursive definitions are allowed. Constructive type theory can be seen as one of them. In addition, logic can also be represented in constructive type theory by identifying propositions with types and proofs with programs of the corresponding type. Therefore, a type can encode a complete specification, requiring also logical properties from an algorithm. As a consequence, algorithms are correct by construction or can be proved correct by using the expressive power of constructive type theory. This is clearly an advantage of constructive type theory over standard programming languages. A computational limitation of type theory is that, to keep the logic consistent and type-checking decidable, only structurally recursive definitions are allowed.

Many important algorithms are general recursive. Although many such algorithms can be proved to terminate, there is no syntactic condition that guarantees their termination and thus, general recursive algorithms have no direct translation into type theory.

In this thesis, a method to formalise general recursive algorithms in type theory that separates the computational and logical parts of the definitions is presented. As a consequence, the resulting type-theoretic algorithms are clear, compact and easy to understand. Given a general recursive algorithm, the method consists in defining an inductive special-purpose accessibility predicate that characterises the inputs on which the algorithm terminates. The type-theoretic version of the algorithm can then be defined by structural recursion on the proof that the input values satisfy this predicate. When formalising nested algorithms, the special-purpose accessibility predicate and the type-theoretic version of the algorithm must be defined simultaneously because they depend on each other. Since the method separates the computational part from the logical part of a definition, formalising partial functions becomes also possible.

Denna post skapades 2006-08-25. Senast ändrad 2013-09-25.

CPL Pubid: 332