Conference Paper

General Recursion in Type Theory

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

Abstract

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

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.

... Thus, we can define a function computing a disagreement set of two given atoms, or a function applying substitutions, and some other functions, and then compose them into a more complex function that is able to unify terms. There exist several functional formalisations of the algorithm of unification in different functional languages, [6] [10] [29]. It can be quite hard to formalise this algorithm, as [6] [10] [29] indicate. ...
... There exist several functional formalisations of the algorithm of unification in different functional languages, [6] [10] [29]. It can be quite hard to formalise this algorithm, as [6] [10] [29] indicate. ...
... Thus, we can define a function computing a disagreement set of two given atoms, or a function applying substitutions, and some other functions, and then compose them into a more complex function that is able to unify terms. There exist several functional formalisations of the algorithm of unification in different functional languages, [6, 10, 29]. It can be quite hard to formalise this algorithm, as [6, 10, 29] indicate. ...
Article
Full-text available
The paper formalises the famous algorithm of first-order unification by Robinson by means of the error-correction learning in neural networks. The significant achievement of this formalisation is that, for the first time, the first-order unification of two arbitrary first-order atoms is performed by finite (two-neuron) network.
... We have previously worked on two methods to tackle this issue. The first method [6,4,7] consists in characterising the inputs on which the function terminates by an inductive (domain) predicate easily defined from the recursive equations, and then defining the function itself by recursion on the proof that the input argument satisfies this domain predicate. The second method [8] consists in defining co-inductive types of partial elements and implementing general recursive functions by co-recursion on these types. ...
... For a complete description of this method and for more examples of its application , the reader is referred to [6,4,7]. ...
... This article describes a new method to represent (partial) recursive functions in type theory. It combines ideas from our previous work on the subject, namely, the one characterising the inputs on which a function terminates by an inductive (domain) predicate [6,4,7], and the one implementing recursive functions by co-recursion on co-inductive types of partial elements [8]. Given the recursive equations for a computable function f : A → B, we define a co-inductive set B f of prophecies representing the traces of the computation of the function. ...
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.
... There are many useful functions and algorithms that are not structurally recursive, but general recursive. They are not accepted by Coq or similar proof assistants directly, but they can be defined using various forms of well-founded induction or induction with respect to a predicate [5, 8]. It is perhaps worth mentioning that there exists an approach to termination called " type-based termination " [1, 3, 17]. ...
... However, yet it gives little from the point of view of practical programming and automated proving. Therefore the value of this paper, as well as (e.g.) [5, 7, 8] is in the technical elegance and practical implementation in the existing proof assistants. ...
Conference Paper
Full-text available
We propose a (limited) solution to the problem of constructing stream values defined by recursive equations that do not respect the guardedness condition. The guardedness condition is imposed on definitions of corecursive functions in Coq, AGDA, and other higher-order proof assistants. In this paper, we concentrate in particular on those non-guarded equations where recursive calls appear under functions. We use a correspondence between streams and functions over natural numbers to show that some classes of non-guarded definitions can be modelled through the encoding as structural recursive functions. In practice, this work extends the class of stream values that can be defined in a constructive type theory-based theorem prover with inductive and coinductive types, structural recursion and guarded corecursion
... For another direction, we plan to extend and automate the method, covering more features of functional programming not present in type theory: possibly non-terminating general recursion, lazy evaluation manipulating infinite objects , IO operations, etc. Bove [2] provides a uniform method for representing general recursive partial programs in type theory. Hancock and Setzer [16] model interactive systems in type theory with a structure related to the Haskell's IO-monad. ...
... For a start, we are integrating the very BDD program we verified here in our tool. For another direction, we plan to extend and automate the method, covering more features of functional programming not present in type theory: possibly non-terminating general recursion, lazy evaluation manipulating infinite objects, IO operations, etc. Bove[2]provides a uniform method for representing general recursive partial programs in type theory. Hancock and Setzer[16]model interactive systems in type theory with a structure related to the Haskell's IO-monad. ...
Conference Paper
Full-text available
We propose a method for improving confidence in the correctness of Haskell programs by combining testing and proving. Testing is used for debugging programs and specification before a costly proof attempt. During a proof development, testing also quickly eliminates wrong conjectures. Proving helps us to decompose a testing task in a way that is guaranteed to be correct. To demonstrate the method, we have extended the Agda/Alfa proof assistant for dependent type theory with a tool for random testing. As an example, we show how the correctness of a BDD-algorithm written in Haskell is verified by testing properties of component functions. We also discuss faithful translations from Haskell to type theory.
... When the translation falls outside that set, any correctness proofs constructed in Alfa entail only partial correctness, and we leave it to the user to judge the value of such proofs. In the future, we might use a more sophisticated termination checker and/or change the translation to use domain predicates [3] to make partiality explicit and to make the user responsible for providing termination proofs. ...
Article
Full-text available
With ever increasing use of computers in safety and security critical applications, the need for trustworthy computer systems has never been greater. But how can such trust be established? For example, how can we be sure that our computer systems will not destroy or corrupt valuable data, compromise privacy, or trigger serious failures that could, in the worst cases, lead to loss of life? Industry and academia have attacked this problem in many different ways, demonstrating concretely that the use of techniques such as systematic design processes, rigorous testing, or formal methods can each contribute significantly to increased reliability, security, and trustworthiness. There are obviously some significant differences between these techniques, but there is also a unifying feature: each one results in some tangible form of {\em evidence}\/ that provides a basis for trust. Examples of such evidence include a record of the meeting where a code review was conducted, the set of test cases to which an application was subjected, or a formal proof that establishes the validity of a critical property. Unfortunately, the diversity, volume, and variability of evidence that is needed in practice, even in the development of some fairly small systems, makes it hard to manage, maintain, and exploit this evidence as a project evolves and as meaningful levels of assurance are required. Without support, practical difficulties like these could easily discourage or prevent system builders from capturing and leveraging evidence to produce systems in which they, and their users, can develop a well-placed trust. In the Programatica project at OGI \cite{high-assurance}, we are exploring the role that tools can play in facilitating and supporting effective use of evidence during the design, development and maintenance of complex software systems. From a programmer's perspective, Programatica provides a development environment for an extended version of the functional programming language Haskell \cite{Haskell98revised} that provides a notation (and an associated logic, called {\em P-logic} \cite{plogic}) for expressing properties of Haskell code. From a verification perspective, we expect that a broad spectrum of techniques will be useful in establishing such properties, including code review, testing, and formal methods. To support {\em evidence management}, Programatica provides: mechanisms for capturing different forms of evidence in {\em certificates}; methods exploiting fine-grained dependency analysis to automate the tasks of tracking, maintaining, and reestablishing evidence as a system evolves; and tools to help users understand, manage, and guide further development and validation efforts. One way to understand Programatica is as a framework for {\em Extreme Formal Methods}: we expect property assertions to be developed and established in parallel with the code that they document, just as test cases are developed in extreme programming \cite{Beck:extreme}. This paper describes the current version of the Programatica tools and illustrates how they address some of the above goals in practice.
... When the translation falls outside that set, any correctness proofs constructed in Alfa entail only partial correctness, and we leave it to the user to judge the value of such proofs. In the future, we might use a more sophisticated termination checker and/or change the translation to use domain predicates [2] to make partiality explicit and to make the user responsible for providing termination proofs. While the type system of plain Haskell 98 can be mapped in a straight-forward way to the predicative type system of Structured Type Theory, we foresee problems extending the translation to cover existential quantification in data types and perhaps also higher rank polymorphism. ...
Article
Full-text available
The Haskell tools from the Programatica project were extended with syntax for property assertions. Various techniques were used to provide evidence for the validity of assertions. The tools are expected to assist the programmer with evidence management, using certificates to record evidence, and to provide whatever translation of Haskell code needed to enable the use of theorem provers and other tools that can serve as sources of evidence. The functionality provided by the tools that might be of interest to Haskell programmers, and those aimed at supporting the goals of the Programatica Project were also discussed.
... We believe that the combination of such decision procedures with random test data generation and support for interactive proving has a great potential to be explored. Another direction is to extend and automate the method, covering more features of functional programming not present in type theory: possibly non-terminating general recursion, lazy evaluation manipulating infinite objects, IO operations, etc. Bove [2] provides a uniform method for representing general recursive partial programs in type theory. Hancock and Setzer [18] model interactive systems in type theory with a structure related to the Haskell's IO-monad. ...
Article
We propose a program verification method that combines random testing, model checking and interactive theorem proving. Testing and model checking are used for debugging programs and specifications before a costly interactive proof attempt. During proof development, testing and model checking quickly eliminate false conjectures and generate counterexamples which help to correct them. With an interactive theorem prover we also ensure the correctness of the reduction of a top level problem to subproblems that can be tested or proved. We demonstrate the method using our random testing tool and binary decision diagrams-based (BDDs) tautology checker, which are added to the Agda/Alfa interactive proof assistant for dependent type theory. In particular we apply our techniques to the verification of Haskell programs. The first example verifies the BDD checker itself by testing its components. The second uses the tautology checker to verify bitonic sort together with a proof that the reduction of the problem to the checked form is correct.
... In Coq, the method was implemented in [33,4], see also [12]. The method of using accessibility predicates was improved by Bove in her thesis [15] and series of papers [14,17,16,18]. The core of the improvement proposed by Bove was to separate computational and logical parts of the definitions of general recursive algorithms. ...
Article
Full-text available
In Constructive Type Theory, recursive and corecursive definitions are subject to syntactic restrictions which guarantee termination for recursive functions and productivity for corecursive functions. However, many terminating and productive functions do not pass the syntactic tests. Bove proposed in her thesis an elegant reformulation of the method of accessibility predicates that widens the range of terminative recursive functions formalisable in Constructive Type Theory. In this paper, we pursue the same goal for productive corecursive functions. Notably, our method of formalisation of coinductive definitions of productive functions in Coq requires not only the use of ad-hoc predicates, but also a systematic algorithm that separates the inductive and coinductive parts of functions.
... In a series of previous articles, we expound two different ways of achieving that goal. In our first approach [3, 4, 2, 5], we define an inductive (domain) predicate that characterises the inputs on which a function terminates. The constructors of this predicate can be easily and automatically determined from the recursive equations defining the function. ...
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.
... However, Giesl managed to extend existing induction provers with his calculus with little effort. Bove and Capretta [10,12] investigate how general recursion can be treated in constructive type theory, which by default only admits structural recursion. Their approach is also based on an inductively defined domain predicate which is similar to our dom f . ...
Article
Based on inductive definitions, we develop a tool that automates the definition of partial recursive functions in higher-order logic (HOL) and provides appropriate proof rules for reasoning about them. Termination is modeled by an inductive domain predicate which follows the structure of the recursion. Since a partial induction rule is available immediately, partial correctness properties can be proved before termination is established. It turns out that this modularity also facilitates termination arguments for total functions, in particular for nested recursions. Our tool is implemented as a definitional package extending Isabelle/HOL. Various extensions provide convenience to the user: pattern matching, default values, tail recursion, mutual recursion and currying.
... There, besides presenting the formal definition of the function, we also show how to prove some of its properties. For further reading on the method, including its limitations, the reader is referred to [5] [6] [4] where the method is presented and exemplified for a constructive type theory in the spirit of Martin-Löf's type theory. For the applicability of the method to the Calculus of Inductive Constructions (CIC), see Chapter 15 of Bertot's and Castéran's book [3]. ...
Article
Full-text available
Bove and Capretta have presented a method to deal with partial and general recursive functions in constructive type theory which relies on an inductive characterisation of the domains of the functions. The method separates the logical and the computational aspects of an algorithm, and facilitates the formal verification of the functions being defined. For nested recursive functions, the method uses Dybjer' schema for simultaneous inductive-recursive definitions. However, not all constructive type theories support this kind of definitions.Here we present a new approach for dealing with partial and general recursive functions that preserves the advantages of the method by Bove and Capretta, but which does not rely on inductive-recursive definitions. In this approach, we start by inductively defining the graph of the function, from which we first define the domain and afterwards the type-theoretic version of the function. We show two ways of proving the formal specification of the functions defined with this new approach: by induction on the graph, or by using an induction principle in the style of the induction principle associated to the domain predicates of the Bove-Capretta method.
... In this case, a well-formed circular definition comes equipped with a formal assessment of its convergency, according to the theoretical properties of the intended model. A well-known and very general method for building models supporting recursive definitions is well-founded recursion (and variations thereof) [12,1,7,2] . A formal definition of a function by well-founded recursion must contain also the definition of the order over which the recursion goes, and the proof Work supported by italian MIUR project COFIN 2001013518 CoMeta. ...
Article
Full-text available
In this paper we present a theorem for defining fixed-points in categories of sheaves. This result gives a unifying and general account of most techniques used in computer science in order to ensure convergency of circular definitions, such as (but not limited to) well-founded recursion and contractivity in complete ultra metric spaces. This general fixed-point theorem encompasses also a similar set theoretic result presented in previous work, based on the notion of ordered family of equivalences, and implemented in the Coq proof assistant.
... In this case, a well-formed circular definition comes equipped with a formal assessment of its convergency, according to the theoretical properties of the intended model. A well-known and very general method for building models supporting recursive definitions is well-founded recursion (and variations thereof) [12,1,7,2] . A formal definition of a function by well-founded recursion must contain also the definition of the order over which the recursion goes, and the proof Work supported by italian MIUR project COFIN 2001013518 CoMeta. ...
Article
Full-text available
In type theory based logical frameworks, recursive and corecursive definitions are subject to syntactic restrictions that ensure their termination and productivity. These restrictions however greately decrease the expressive power of the language. In this work we propose a general approach for systematically defining fixed points for a broad class of well given recursive definition. This approach unifies the ones based on well-founded order to the ones based on complete metrics and contractive functions, thus allowing for mixed recursive/corecursive definitions.
... It was extended in Bove and Capretta (2001) to treat nested recursion, and in Bove (2002b) to treat mutually recursive algorithms, nested or not. 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). ...
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.
Conference Paper
In this paper, I show that general recursive definitions can be represented in the free monad which supports the ‘effect’ of making a recursive call, without saying how these calls should be executed. Diverse semantics can be given within a total framework by suitable monad morphisms. The Bove-Capretta construction of the domain of a general recursive function can be presented datatype-generically as an instance of this technique. The paper is literate Agda, but its key ideas are more broadly transferable.
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
Full-text available
In this paper we present a theorem for defining fixed-points in categories of sheaves. This result gives a unifying and general account of most techniques used in computer science in order to ensure convergency of circular definitions, such as (but not limited to) well-founded recursion and contractivity in complete ultra metric spaces. This general fixed-point theorem encompasses also a similar set theoretic result presented in previous work, based on the notion of ordered family of equivalences, and implemented in the Coq proof assistant.
Conference Paper
Research on formal verification of imperative programs using some form of representing them in a type theory has been done for years. Generally, the different approaches include a verification conditions generator, which from an annotated program including variants and invariants for while–loops and using a Hoare logic–like specification, produces some propositions to be proved in a logical framework, expressing the program correctness and termination. In this paper we present a direct use of Coq [3] to model imperative programs. This method, and the fact that it is not possible to have not–ending programs in Coq, should allow a more deep understanding of imperative programs semantics [15], and people without big knowledge on type theory could use this theorem prover to verify imperative programs properties. This approach is based on using a fixed–point equality theorem [2] that represents the appropriate reduction rule to be used in our model. In our approach no Hoare logic rules are used for verification of program specifications. This verification is achieved, in a pure constructive setting, directly with the type theory model.
Conference Paper
Full-text available
Systems of affine recurrence equations (SAREs) over polyhedral domains are widely used to model computation-intensive algorithms and to derive parallel code or hardware implementations. The development of complex SAREs for real-sized applications calls for the elaboration of formal verification techniques. As the systems we consider are generic, i.e., depend on parameters whose value are not statically known, we considered using theorem provers, and have implemented a translation from SAREs into the Coq system. We take advantage of the regularity of our model to automatically generate an inductive type adapted to each particular system. This allows us to automatically prove that the functional translation of equations respects the wanted fixpoint properties, and to systematically derive mutual induction schemes.
Conference Paper
We consider the problem of efficient representation of dependently typed data. In particular, we consider a language TT based on Dybjer’s notion of inductive families [10] and reanalyse their general form with a view to optimising the storage associated with their use. We introduce an execution language, ExTT, which allows the commenting out of computationally irrelevant subterms and show how to use properties of elimination rules to elide constructor arguments and tags in ExTT. We further show how some types can be collapsed entirely at run-time. Several examples are given, including a representation of the simply typed λ-calculus for which our analysis yields an 80% reduction in run-time storage requirements.
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.
Conference Paper
Full-text available
We extend the proof assistant Agda/Alfa for dependent type theory with a modi ed version of Claessen and Hughes' tool QuickCheck for random testing of functional programs. In this way we combine testing and proving in one system. Testing is used for debugging programs and speci cations before a proof is attempted. Furthermore, we demonstrate by example how testing can be used repeatedly during proof for testing suitable subgoals. Our tool uses testdata generators which are de ned inside Agda/Alfa. We can therefore use the type system to prove properties about them, in particular surjectivity stating that all possible test cases can indeed be generated.
Article
Full-text available
It is now 10 years ago that two of us took the train to Stockholm to meet Per Martin-Löf and discuss his ideas on the connection between type theory and computing science. This book describes different type theories (theories of types, polymorphic and monomorphic sets, and subsets) from a computing science perspective. It is intended for researchers and graduate students with an interest in the foundations of computing science, and it is mathematically self-contained. We started writing this book about six years ago. One reason for this long time is that our increasing experience in using type theory has made several changes of the theory necessary. We are still in this process, but have nevertheless decided to publish the book now. We are, of course, greatly indebted to Per Martin-L¨of; not only for creating the subject of this book, but also for all the discussions we have had with him. Beside Martin-Löf, we have discussed type theory with many people and we in particular want to thank Samson Abramsky, Peter Aczel, Stuart Anderson, Roland Backhouse, Bror Bjerner, Robert Constable, Thierry Coquand, Peter Dybjer, Roy Dyckhoff, Gerard Huet, Larry Paulson, Christine Paulin-Mohring, Anne Salvesen, Björn von Sydow, and Dan Synek. Thanks to Dan Synek also for his co-authorship of the report which the chapter on trees is based on. Finally, we would like to thank STU, the National Swedish Board For Technical Development, for financial support.
Article
Full-text available
This paper introduces \lambda^\widehat, a simply typed lambda calculus supporting inductive types and recursive function definitions with termination ensured by types. The system is shown to enjoy subject reduction, strong normalisation of typable terms and to be stronger than a related system λG\lambda_{\mathcal{G}} in which termination is ensured by a syntactic guard condition. The system can, at will, be extended to support coinductive types and corecursive function definitions also.
Conference Paper
Full-text available
We extend Bove's technique for formalising simple general recursive algorithms 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.
Conference Paper
Full-text available
Alf is an interactive proof editor. It is based on the idea that to prove a mathematical theorem is to build a proof object for the theorem. The proof object is directly manipulated on the screen, different manipulations correspond to different steps in the proof. The language we use is Martin-Löf's monomorphic type theory. This is a small functional programming language with dependent types. The language is open in the sense that it is easy to introduce new inductively defined sets. A proof is represented as a mathematical object and a proposition is identified with the set of its proof objects. The basic part of the proof editor can be seen as a proof engine with two basic commands, one which builds an object by replacing a placeholder in an object by a new object, and another one which deletes a part of an object by replacing a sub-object by a placeholder. We show that the validity of the incomplete object is preserved by admissible insertions and deletions.
Article
Full-text available
Abstract We discuss a scheme for dening,and reasoning about partial recursive functions within a classical two-valued logic in which all terms denote. We show how a total extension of the partial function introduced by a recursive declaration may be axiomatised within a classical logic, and illustrate by an example the kind of reasoning that our scheme supports. By presenting a naive set-theoretic semantics, we show that the system we propose is logic- ally consistent. We discuss some of the practical advantages and limitations of our approach in the context of mechanical theorem-proving.
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
Full-text available
The first example of a simultaneous inductive-recursive definition in intuitionistic type theory is Martin-Löfs universe à la Tarski. A set U 0 of codes for small sets is generated inductively at the same time as a function T 0 , which maps a code to the corresponding small set, is defined by recursion on the way the elements of U 0 are generated. In this paper we argue that there is an underlying general notion of simultaneous inductive-recursive definition which is implicit in Martin-Löf's intuitionistic type theory. We extend previously given schematic formulations of inductive definitions in type theory to encompass a general notion of simultaneous induction-recursion. This enables us to give a unified treatment of several interesting constructions including various universe constructions by Palmgren, Griffor, Rathjen, and Setzer and a constructive version of Aczel's Frege structures. Consistency of a restricted version of the extension is shown by constructing a realisability model in the style of Allen.
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.
Article
Full-text available
This paper gives an introduction to type theory, focusing on its recent use as a logical framework for proofs and programs. The first two sections give a background to type theory intended for the reader who is new to the subject. The following presents Martin-Lof's monomorphic type theory and an implementation, ALF, of this theory. Finally, a few small tutorial examples in ALF are given.
Article
Full-text available
Boyer and Moore have discussed a function that puts conditional expressions into normal form [1]. It is difficult to prove that this function terminates on all inputs. Three termination proofs are compared: (1) using a measure function, (2) in domain theory using LCF, (3) showing that its recursion relation, defined by the pattern of recursive calls, is well-founded. The last two proofs are essentially the same though conducted in markedly different logical frameworks. An obviously total variant of the normalize function is presented as the ‘computational meaning’ of those two proofs. A related function makes nested recursive calls. The three termination proofs become more complex: termination and correctness must be proved simultaneously. The recursion relation approach seems flexible enough to handle subtle termination proofs where previously domain theory seemed essential.
Article
We extend Bove's technique for formalising simple general recursive algorithms in constructive type theory to nested recursive algorithms. The method consists in defining an inductive special-purpose accessibility predicate, that characterises 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 wit...
Chapter
Inductive definitions of sets are often informally presented by giving some rules for generating elements of the set and then adding that an object is to be in the set only if it has been generated according to the rules. An equivalent formulation is to characterize the set as the smallest set closed under the rules. This chapter discusses monotone induction and its role in extensions of recursion theory. The chapter reviews some of the work on non-monotone induction and outlines the separate motivation that has led to its development. The chapter briefly considers inductive definitions in a more general context.
Article
Manna and Waldinger's theory of substitutions and unification has been verified using the Cambridge LCF theorem prover. A proof of the monotonicity of substitutiion is presented in detail. as an example of interaction with LCF. Translating the theory into LCF's domain-theoretic logic is largely straightforward. Well-founded induction on a complex ordering is translated into nested structural inductions. Correctness of unification is expressed using predicates for such properties as idempotence and most-generality. The verification is presented as a series of lemmas. The LCF proofs are compared with the original ones, and with other approaches. It appears difficult to find a logic that is both simple and flexible, especially for conducting difficult proofs of termination.
Article
Recursive definitions are considered which consist of Algol-like conditional expressions. By specifying a computation rule for evaluating such recursive definition, it determines a partial function. However, for different computation rules, the same recursive definition may determine different partial functions. Two types of computation rules are distinguished: sequential and parallel. The purpose of the paper is to formalize properties (such as termination, correctness and equivalence) of these partial functions by means of the satisfiability or validity of certain formulas in partial function logic.
Article
A formal specification of unification is presented and a unification algorithm is synthesized from it. The synthesis is done by logical deduction within the logic programming calculus developed by Hansson and Tärnlund. First-order logic with identity is used as the specification language and extended Horn clause logic as the target language.
Conference Paper
Functions specified by nested recursions are difficult to define and reason about. We present several ameliorative techniques that use deduction in a classical higher-order logic. First, we discuss how an apparent circular dependency between the proof of nested termination conditions and the definition of the specified function can be avoided. Second, we propose a method that allows the specified function to be defined in the absence of a termination relation. Finally, we show how our techniques extend to nested program schemes, where a termination relation cannot be found until schematic parameters have been filled in. In each of these techniques, suitable induction theorems are automatically derived.
Conference Paper
We use a formally proven wellfounded recursion theorem as the basis upon which to build a function definition facility for Higher Order Logic. This approach offers flexibility in the choice of wellfounded relations used, the deferral of termination arguments, and automatic isolation of termination conditions. Building on this platform, we provide the ability to define recursive functions via pattern matching. The system is parameterized and has been instantiated to quite different theorem provers.
Article
The notion of pattern matching in correlation with functional programming is discussed. The key feature of pattern matching in simply-typed languages is that the structure of an arbitrary value in a datatype is explained. Pattern matching analyzes constructor patterns on the left-hand sides of functional equations, and is defined by a subsystem of the operational semantics with hard-wired rules for computing substitution from the pattern variables to values. Elementary pattern matching may be recast in abstract form, with a semantics given by translation.
Article
In Martin-Löf's type theory, general recursion is not available. The only iterating constructs are primitive recursion over natural numbers and other inductive sets. The paper describes a way to allow a general recursion operator in type theory (extended with propositions). A proof rule for the new operator is presented. The addition of the new operator will not destroy the property that all well-typed programs terminate. An advantage of the new program construct is that it is possible to separate the termination proof of the program from the proof of other properties.
Article
This paper deals with automated termination analysis for functional programs. Previously developed methods for automated termination proofs of functional programs often fail for algorithms with nested recursion and they cannot handle algorithms with mutual recursion. We show that termination proofs for nested and mutually recursive algorithms can be performed without having to prove the correctness of the algorithms simultaneously. Using this result, nested and mutually recursive algorithms do no longer constitute a special problem and the existing methods for automated termination analysis can be extended to nested and mutual recursion in a straightforward way. We give some examples of algorithms whose termination can now be proved automatically (including well-known challenge problems such as McCarthy’s f_91 function).
Article
The deductive approach is a formal program-construction method in which the derivation of a program from a given specification is regarded as a theoremproving ask. To construct a program whose output satisfies the conditions of the specification, we prove a theorem stating the existence of such an output. The proof is restricted to be sufficiently constructive so that a program computing the desired output can be extracted directly from the proof. The program we obtain is applicative and may consist of several mutually recursive procedures. The proof constitutes a demonstration of the correctness of this program. To exhibit the full power of the deductive approach, we apply it to a nontrivial example — the synthesis of a unification algorithm. Unification is the process of finding a common instance of two expressions. Algorithms to perform unification have been central to many theorem-proving systems and some programming-language processors. The task of deriving a unification algorithm automatically is beyond the power of existing program-synthesis systems. In this paper, we use the deductive approach to derive an algorithm from a simple, high-level specification of the unification task. We will identify some of the capabilities required of a theorem proving system to perform this derivation automatically.
Article
Advertising campaigns and highly popular government programs have for many years trumpeted the need to get people connected to the Internet. That meant solving the technological and sociological issues involved in providing network access to the population and turning them into regular users. The message echoes today in a slightly muted form. Except in developing parts of the world, getting people connected is no longer a major challenge. The challenge today is to create and support experiences that users continue to value. The recent drop in the overheated valuations of networking-oriented businesses serves as a useful reminder that people don't really care about being connected to the Internet per se. They use the Internet to connect to other people or things. In the case of, connecting to people, a valuable question to ask might be, How can connected applications identify communities, support their activities, and evolve to meet their needs? With respect to things, let's consider the increasingly popular situation in which those things are multimedia content. In particular, let's think about how multimedia content might be the glue that connects, defines, and supports communities. Irrespective of views on intellectual property issues or business models, even a cursory reading of recent events makes it undeniable that the Web is becoming a remarkably effective-if not yet efficient-multimedia content distribution platform. While this may not have been a design goal earlier, it's now a significant driving force in the evolution of network technology, user services, and access devices. Given media content, people, and the Internet, there are three sorts of connectedness pairings to consider: people-to-people; people-to-media; and media-to-media
Article
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.
Article
Gimenez' type system for structural recursion in the Calculus of Constructions is adapted to typed functional programming. As core language, the #-calculus with inductive types, subtyping and bounded quantification is introduced. Decorated type variables, which represent approximations of inductive types, enable the type system to track the size of arguments to recursive functions and the size of the result of function calls. Novel are an algorithm for type checking and proofs of type preservation and strong normalization.
Article
Martin-Löf's type theory is a constructive type theory originally conceived as a formal language in which to carry out constructive mathematics. However, it can also be viewed as a programming language where specifications are represented as types and programs as objects of the types. In this work, the use of type theory as a programming language is investigated. As an example, a formalisation of a unification algorithm for first-order terms is considered. Unification can be seen as the process of finding a substitution that makes all the pairs of terms in an input list equal, if such a substitution exists. Unification algorithms are crucial in many applications, such as type checkers for different programming languages. Unification algorithms are total and recursive, but the arguments on which the recursive calls are performed satisfy no syntactic condition that guarantees termination. This fact is of great importance when working with Martin-Löf's type theory since there is no direc...
Article
We derive a combinator library for non-deterministic parsers with a monadic interface. The choice operator is implemented as a breadth- rst search rather than the more common depth- rst search, and can be seen as a parallel composition between two parsing processes. The resulting library is simple and ecient for "almost deterministic" grammars, which are typical for programming languages and other computing science applications.
Article
General recursive algorithms are such that the recursive calls are performed on arguments satisfying no condition that guarantees termination. Hence, there is no direct way of formalising them in type theory. The standard way of handling general recursion in type theory uses a well-founded recursion principle. Unfortunately, this way of formalising general recursive algorithms often produces unnecessarily long and complicated codes. On the other hand, functional programming languages like Haskell impose no restrictions on recursive programs, and then writing general recursive algorithms is straightforward. In addition, functional programs are usually short and self-explanatory. However, the existing frameworks for reasoning about the correctness of Haskell-like programs are weaker than the framework provided by type theory. The goal of this work is to present a method that combines the advantages of both programming styles when writing simple general recursive algorithms....
Conference Paper
this paper is mostly described by Coquand, Pfenning, and Paulin-Mohring in [14, 4, 11]. General use of well-founded recursion in Martin-L#f's intuitionistic type theory was studied by Paulson in [12], who shows that reduction rules can be obtained for each of several means to construct well-founded relations from previously known well-founded relations. By comparison with Paulson's work, our technique is to obtain reduction rules that are specic to each recursive function. The introduction of well-founded recursion using an accessibility principle as used in this paper was described by Nordstr#m in [9].
Type theory and programming Dubois and V. Viguié Donzeau-Gouge. A step towards the mechanization of partial functions: Domains as inductive predicates
  • T Coquand
  • B Nordströ
  • J M Smith
  • B Sydow
T. Coquand, B. Nordströ, J. M. Smith, and B. von Sydow. Type theory and programming. EATCS, 52, February 1994. [DDG98] C. Dubois and V. Viguié Donzeau-Gouge. A step towards the mechanization of partial functions: Domains as inductive predicates. In M. Kerber, editor, CADE-15, The 15th International Conference on Automated Deduction, pages 53–62, July 1998. WORKSHOP Mechanization of Partial Functions.
The view from the left Under consid-eration for publication in Journal of Functional Programming
  • C Mcbride
  • J Mckinna
C. McBride and J. McKinna. The view from the left, 2002. Under consid-eration for publication in Journal of Functional Programming.
Mutual general recursion in type theory Available on the WWW http://cs.chalmers.se/∼bove/Papers/mutual rec.ps.gz
  • A Bove
A. Bove. Mutual general recursion in type theory, May 2002. Available on the WWW http://cs.chalmers.se/∼bove/Papers/mutual rec.ps.gz. [CH88]
Modelling general recursion in type theory Available on the WWW http://cs.chalmers.se/∼bove/Papers/general presentation.ps.gz Type-theoretic functional semantics Type-based termination of recursive definitions. Under consideration for publication in Math
  • A Bove
  • V Caprettabcb
  • Y Bertot
  • V Capretta
  • K Das
  • G Barthe
  • M J Frade
  • E Gimé
  • L Pinto
  • T Uustalu
A. Bove and V. Capretta. Modelling general recursion in type theory, September 2002. Available on the WWW http://cs.chalmers.se/∼bove/Papers/general presentation.ps.gz. [BCB02] Y. Bertot, V. Capretta, and K. Das Barman. Type-theoretic functional semantics. In Theorem Proving in Higher Order Logics: 15th International Conference, TPHOLs 2002, 2002. [BFG + 00] G. Barthe, M.J. Frade, E. Gimé, L. Pinto, and T. Uustalu. Type-based termination of recursive definitions. Under consideration for publication in Math. Struct. in Comp. Science, December 2000.
A general formulation of simultaneous inductive-recursive defi-nitions in type theory Partial functions in a total setting
  • P Dybjer
  • S Finn
  • M P Fourman
  • J Longley
P. Dybjer. A general formulation of simultaneous inductive-recursive defi-nitions in type theory. Journal of Symbolic Logic, 65(2), June 2000. [FFL97] S. Finn, M.P. Fourman, and J. Longley. Partial functions in a total setting. Journal of Automated Reasoning, 18(1):85–104, 1997.
Fonctions ré géné par ité en thé des types
  • A Balaa
  • Y Bertot
A. Balaa and Y. Bertot. Fonctions ré géné par ité en thé des types. Journé Francophones des Langages Applicatifs -JFLA02, INRIA, January 2002. [BC01]
A step towards the mechanization of partial functions: Domains as inductive predicates
  • C Dubois
  • V Viguié Donzeau-Gouge
Purely Functional Language Available from
  • Peyton Jones
  • J Hughes
  • L Augustsson
  • D Barton
  • B Boutel
  • W Burton
  • J Fasel
  • K Hammond
  • R Hinze
  • P Hudak
  • T Johnsson
  • M Jones
  • J Launchbury
  • E Meijer
  • J Peterson
  • A Reid
  • C Runciman
  • P Wadler