A system for developing programs by transformation

Much of the difficulty of programming can be atcribute: ' to the clash between the goal of efficiency and other desirable goals, s! Lch as clarity, reliability and m3difiability. 'I"his thesis proposes program transfornat4. on as a suitable methodology for program development to circumvent this difficulty. Following this methodology, a program is developed by first writing a simple str. aightforws. rd solution to the problem, unhampered by efficiency considerations. Efficiency is then introduced in a separate step by transforming the simple solution. In order that this be a practical methodology, transformation of large programs must be possible to perform reliably and easi. l y. 1"(. 'is thesis presents an implemented machine-b::, sed transformation system which attempts to realise these needs. The system is based on a concise and powerful transformation method due to Burstail and Darlington. The emphasis of the system is on making it easy for the user to control the system through a transformation. Guidance is expressed in a command language, so that commands may be saved and re-run, modified, or viewed as documentation together with the initial program. The level at which guidance is given is higher that the low-level underlying manipulations. Techniques for organising the transformation of large programs at even higher levels are presented. Some non trivial programs and their transformation as achieved using the system illustrate these features. ý CHAPTER I INTRODii(; TIOIl The use of computers is continur,. liy increasing, and a great deal of research is being done into tn. hardware and sof twar` aspects of computing. Progress on the hardware side has led :o cheaper and more efficient machines, so the cost (in both time and money) of providing and maintaining software is becoming increasingly significant. Since the late 1960's the existence of the so called software crisis has been recognised that is the difficulty of specifying, developing and maintaining large pieces of software. Consequently there is a great deal of interest in devising methods to ease the task of programming. My own research has concentrated on one of these potential methods program transformation. This is a design methodology that suggests we produce a program in a two-stage process; firstly, write a simple program without regard for efficiency of execution (so freeing us to aim for clarity and correctness); the required efficiency is achieved in the second stage, in which we' transform the initial program. In making this separation we hope to benefit by ending up with an efficient program (as we would if we used some other design method), yet one which is much more reliable and bet-ter documented through being derived from a simple initial program. INTRODUCTION Pag. C, Other reseý_. _-chers have already in-, ented ways of tr nsfo? -! ̂ i:, g programs. Rather than look for yet more such ways, or t. ý _xtend them to some new domain, my decision has been to take what appeared to be a promising approach, invented by Burstail and Darlington, and attempt to develop it further in the direction of practical applicability Ly trying it on larger and more complex examples. If transformation is to become a practical mcthodelogv, it must be both easy and reliable to perform. This implies the need for a machine-based transformation system to aid us in transforming programs. Such a. system would provide reliability, and give assistance by removing the drudgery of carrying out many small operations by hand. Darlington had already developed a semi-automatic system based on the transformation method he invented with Burstall. Although his system performed impressively on small examples, it did not seem to be practical for use on larger programs. A major part of my work has been to produce my own transformation system which is intended to be a suitable tool for use on larger programs. The system adopts the Burstall-Darlington transformation method as its underlying means of transforming programs, however the transformation steps which the system -implements are at a higher level than these underlying operations. Each system step can be justified in terms of many small steps, but the user is saved the need to think at the rather low level of the small steps. An important design decision behind my system has been to accept, in fact encou age, user guidance. As an investigation into the practicality of transformation, I consider it better to see how much can beachieved with the aid of a machine-based system ý 1"; 'RODUCTIOII ý; ;ý 1-3 rather than to see far a totally automatic a_pp((ci: pushed. To run my system, the user provides a series of c ýrýands c;. n