Mechanization of program construction in Martin-Loef’s theory of types
The constructive approach to the problem of program correctness dates to the late 1960’s. During the early 1970’s interest developed in the application of constructive logics to the derivation of provably correct programs. Martin-Loef’s Theory of Types was devised as a formalisation of constructive mathematics. His theory also integrates the processes of program construction and verification within a single deductive system. This thesis is concerned with the application of Martin-Loef’s theory to the task of program construction. In particular, the mechanisation of this task is investigated. We begin with a comparative study of current implementations of constructive type theory. The aim of the study is to assess the suitability of the implementations in the role of programming assistant. A proposal for a more effective programming assistant is presented. A principal difficulty in constructing correct programs is the problem of scale. Computer assistance plays an essential role in alleviating this problem. Experience in performing formal proof provides a better understanding of this problem and is, therefore, an important aid to the development of computer assistance. For this reason the formal derivation of a generalised table look-up function was undertaken. This exercise in program construction revealed that a disproportionate amount of the overall proof effort was taken up with proving negations. A proof of a negation has no computational content; it contributes only to the correctness of the synthesized program. With the aim of freeing the programmer from those proof obligations a decision method for negation was developed.
This decision method exploits, and thereby demonstrates, the uniform structure of Martin-Loef’s theory. This uniformity is further utilized in a scheme for automatically deriving primitive recursive functions. The scheme enables the formal introduction of definitions during the course of a proof which satisfy the constraints of primitive recursion.