Article

Mutual General Recursion in Type Theory

Authors:
To read the full-text of this research, you can request a copy directly from the author.

Abstract

We show how the methodology presented by Bove for the formalisation of simple general recursive algorithms and extended by Bove and Capretta to treat nested recursion can also be used in the formalisation of mutual general recursive algorithms. The methodology consists of de ning special-purpose accessibility predicates that characterise the inputs on which the algorithms terminate. Each algorithm is then formalised in type theory by structural recursion on the proof that its input satis es the corresponding special-purpose accessibility predicate. When the mutually recursive algorithms are also nested, we make use of a generalisation of Dybjer's schema for simultaneous inductive-recursive de nitions, which we also present in this work. Hence, some of the formalisations we present in this work are not allowed in ordinary type theory, but they can be carried out in type theories extended with such a schema. Similarly to what happens for simple and nested recursive algorithms, this methodology results in de nitions in which the computational and logical parts are clearly separated also when the algorithms are mutually recursive. Hence, the type-theoretic version of the algorithms is given by its purely functional content, similarly to the corresponding program in a functional programming language.

No full-text available

Request Full-text Paper PDF

To read the full-text of this research,
you can request a copy directly from the author.

... All these papers have been collected in the first author's Ph.D. thesis (Bove 2002a), which also includes an earlier version of this paper. A tutorial on the method can also be found in Bove (2003). Since our method separates the computational part from the logical part of a definition, formalising partial functions becomes possible (Bove and Capretta 2001;Bove 2003). ...
... A tutorial on the method can also be found in Bove (2003). Since our method separates the computational part from the logical part of a definition, formalising partial functions becomes possible (Bove and Capretta 2001;Bove 2003). Proving that a certain function is total amounts to proving that the corresponding special-purpose accessibility predicate (or domain predicate) is satisfied by every input. ...
... In previous publications (Bove 2001;Bove and Capretta 2001;Bove 2002b;Bove 2003), we have presented our method purely by means of examples. The purpose of the current paper is to give a general presentation of the method. ...
Article
Full-text available
Constructive type theory is an expressive programming language in which both algorithms and proofs can be represented. A limitation of constructive type theory as a programming language is that only terminating programs can be defined in it. Hence, general recursive algorithms have no direct formalisation in type theory since they contain recursive calls that satisfy no syntactic condition guaranteeing termination. In this work, we present a method to formalise general recursive algorithms in type theory. Given a general recursive algorithm, our method is to define an inductive special-purpose accessibility predicate that characterises the inputs on which the algorithm terminates. The type-theoretic version of the algorithm is then defined by structural recursion on the proof that the input values satisfy this predicate. The method separates the computational and logical parts of the definitions and thus the resulting type-theoretic algorithms are clear, compact and easy to understand. They are as simple as their equivalents in a functional programming language, where there is no restriction on recursive calls. Here, we give a formal definition of the method and discuss its power and its limitations.
... Recent research has tried to find good representations of general recursive functions in type theory following various avenues: Balaa and Bertot used well-founded recursion [3]; Dubois and Donzeau-Gouge and, independently, Bove and Capretta used inductive characterizations of domain predicates [26,14,15,16,17]; Bertot, Capretta, and Das Barman combined the two methods to give a semantics of imperative programming [13] and Bertot extended the work to coinductive types [12]; Barthe and others used type labeling to strengthen termination conditions [7,9]; McBride and McKinna used views, that is, different potential inductive characterizations of data types [41]. ...
... First of all, some of the techniques, for example that of Balaa and Bertot [3] and that of Barthe and others [7,9], do not address the question of partiality but present ways of extending the definition schemes for total recursive functions. The method of Bove and Capretta [14,15,16,17] allows the definition of partial functions by restricting them to their domain of convergence. However, it is still not possible to apply a function freely to an argument, but it is necessary first to prove that the argument satisfies the domain predicate. ...
Article
Full-text available
A fertile field of research in theoretical computer science investigates the representation of general recursive functions in intensional type theories. Among the most successful approaches are: the use of wellfounded relations, implementation of operational semantics, formalization of domain theory, and inductive definition of domain predicates. Here, a different solution is proposed: exploiting coinductive types to model infinite computations. To every type A we associate a type of partial elements Partial(A), coinductively generated by two constructors: the first, return(a) just returns an element a:A; the second, step(x), adds a computation step to a recursive element x:Partial(A). We show how this simple device is sufficient to formalize all recursive functions between two given types. It allows the definition of fixed points of finitary, that is, continuous, operators. We will compare this approach to different ones from the literature. Finally, we mention that the formalization, with appropriate structural maps, defines a strong monad.
... However, their approach is limited, since only proofs which can be converted into proofs not using Y are valid -this doesn't allow any reasoning about partial functions in general. The current article is heavily based on the approach by Bove and Capretta [BC05a,BC05b,Bov02a,Bov02b]. Capretta [Cap05] has recently proposed the use of the delay monad in order to represent partial objects. ...
Article
Full-text available
In this article we investigate how to represent partial-recursive functions in Martin-Lof's type theory. Our representation will be based on the approach by Bove and Capretta, which makes use of indexed inductive-recursive definitions (IIRD). We will show how to restrict the IIRD used so that we obtain directly executable partial recursive functions, Then we introduce a data type of partial recursive functions. We show how to evaluate elements of this data type inside Martin-Lof's type theory, and that therefore the functions defined by this data type are in fact partial-recursive. The data type formulates a very general schema for defining functions recursively in dependent type theory. The initial version of this data type, for which we introduce an induction principle, needs to be expanded, in order to obtain closure under composition. We will obtain two versions of this expanded data type, and prove that they define the same set of partial-recursive functions. Both versions will be large types. Next we prove a Kleene-style normal form theorem. Using it we will show how to obtain a data type of partial recursive functions which is a small set. Finally, we show how to define self-evaluation as a partial recursive function. We obtain a correct version of this evaluation function, which not only computes recursively a result, but as well a proof that the result is correct.
... Bove and Capretta [7] proposed representing a partial function f : A B as a total function f : Πa : A. P (a) → B, defined by recursion over an inductively defined predicative P : A → prop, expressing the domain of the partial function. This allows the definition of partial computations by general recursion, but does not model non-termination, as f can only be applied to arguments on which it terminates. ...
Conference Paper
Full-text available
Partial type theories allow reasoning about recursively- defined computations using fixed-point induction. However, fixed-point induction is only sound for admissible types and not all types are admissible in sufficiently expressive dependent type theories. Previous solutions have either introduced explicit admissibility conditions on the use of fixed points, or limited the underlying type theory. In this paper we propose a third approach, which supports Hoare-style partial correctness reasoning, without admissibility conditions, but at a tradeoff that one cannot reason equationally about effectful computations. The resulting system is still quite expressive and useful in practice, which we confirm by an implementation as an extension of Coq.
... Sometimes the domain of definition of a function can be characterized independently of the function by an inductive predicate called accessibility [11,7,5,3]. This simply states that an element of a can be proved to be in the domain if the application of f on a calls f recursively on elements that have already been proved to be in the domain. ...
Conference Paper
Full-text available
We describe the operational and denotational semantics of a small imperative language in type theory with inductive and recursive de nitions. The operational semantics is given by natural inference rules, implemented as an inductive relation. The realization of the denotational semantics is more delicate: The nature of the language imposes a few dif- culties on us. First, the language is Turing-complete, and therefore the interpretation function we consider is necessarily partial. Second, the language contains strict sequential operators, and therefore the function necessarily exhibits nested recursion. Our solution combines and extends recent work by the authors and others on the treatment of general recursive functions and partial and nested recursive functions. The rst new result is a technique to encode the approach of Bove and Capretta for partial and nested recursive functions in type theories that do not provide simultaneous induction-recursion. A second result is a clear understanding of the characterization of the de nition domain for general recursive functions, a key aspect in the approach by iteration of Balaa and Bertot. In this respect, the work on operational semantics is a meaningful example, but the applicability of the technique should extend to other circumstances where complex recursive functions need to be described formally.
Article
Abstract We prove normalization for a dependently typed lambda-calculus extended with first-order data types and computation schemata for first-order size-change terminating recursive functions. Size-change termination, introduced by C.S. Lee, N.D. Jones and A.M. Ben- Amram, can be seen as a generalized form of structural induction, which allows inductive computations and proofs to be defined in a straight-forward manner. The language can be used as a proof system—an extension of Martin-L¨of’s Logical Framework. Keywords: Type Theory, Dependent types, Lambda-calculus,
Conference Paper
In this work, a method to formalise general recursive algorithms in constructive type theory is presented throughout examples. The method separates the computational and logical parts of the definitions. As a consequence, the resulting type-theoretic algorithms are clear, compact and easy to understand. They are as simple as their equivalents in a functional programming language, where there is no restriction on recursive calls. 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
Conference Paper
Full-text available
Our goal is to define a type of partial recursive functions in constructive type theory. In a series of previous articles, we studied two different formulations of partial functions and general recursion. We could obtain a type only by extending the theory with either an impredicative universe or with coinductive definitions. Here we present a new type constructor that eludes such entities of dubious constructive credentials. We start by showing how to break down a recursive function definition into three components: the first component generates the arguments of the recursive calls, the second evaluates them, and the last computes the output from the results of the recursive calls. We use this dissection as the basis for the introduction rule of the new type constructor. Every partial recursive function is associated with an inductive domain predicate; evaluation of the function requires a proof that the input values satisfy the predicate. We give a constructive justification for the new construct by interpreting it into the base type theory. This shows that the extended theory is consistent and constructive.
Conference Paper
Full-text available
We describe a new method to represent (partial) recursive functions in type theory. For every recursive definition, we define a co-inductive type of prophecies that characterises the traces of the computation of the function. The structure of a prophecy is a possibly infinite tree, which is coerced by linearisation to a type of partial results defined by applying the delay monad to the co-domain of the function. Using induction on a weight relation defined on the prophecies, we can reason about them and prove that the formal type-theoretic version of the recursive function, resulting from the present method, satisfies the recursive equations of the original function. The advantages of this technique over the method previously developed by the authors via a special-purpose accessibility (domain) predicate are: there is no need of extra logical arguments in the definition of the recursive function; the function can be applied to any element in its domain, regardless of termination properties; we obtain a type of partial recursive functions between any two given types; and composition of recursive functions can be easily defined.
Conference Paper
Full-text available
In a series of articles, we developed a method to translate general recursive functions written in a functional programming style into constructive type theory. Three problems remained: the method could not properly deal with functions taking functional arguments, the translation of terms containing λ-abstractions was too strict, and par- tial application of general recursive functions was not allowed. Here, we show how the three problems can be solved by defining a type of partial functions between given types. Every function, including arguments to higher order functions, λ-abstractions and partially applied functions, is then translated as a pair consisting of a domain predicate and a func- tion dependent on the predicate. Higher order functions are assigned domain predicates that inherit termination conditions from their func- tional arguments. The translation of a λ-abstraction does not need to be total anymore, but generates a local termination condition. The domain predicate of a partially applied function is defined by fixing the given arguments in the domain of the original function. As in our previous articles, simultaneous induction-recursion is required to deal with nested recursive functions. Since by using our method the inductive definition of the domain predicate can refer globally to the domain predicate itself, here we need to work on an impredicative type theory for the method to apply to all functions. However, in most practical cases the method can be adapted to work on a predicative type theory with type universes.
ResearchGate has not been able to resolve any references for this publication.