# From function level semantics to program transformation and optimization

• John Backus
Advanced Seminar On The Role Of Semantics In Software Development The Role Of Semantics In Language Design
Part of the Lecture Notes in Computer Science book series (LNCS, volume 185)

## Abstract

The software crisis results from our disorderly concepts of "program". These make programming an art, rather than an engineering discipline. Such a discipline would at least require that we have stocks of useful off-the-shelf programs and collections of standard theorems that can be applied repeatedly. We have neither.

Mathematical systems are often distinguished by a set of operations that (a) map a set of entities into itself, (b) have simply understood results, and (c) obey a set of strong algebraic laws. Neither conventional programs nor "object level" functional programs are entities belonging to such a system. The standard operations on conventional programs violate (b) and (c); object level functional programs normally employ lambda abstraction as their program building operation and it violates (a) and (c). Other problems of these program concepts are reviewed.

Function level programs are the entities of just such a mathematical system: programs are built by program-forming operations having good algebraic properties. Hence they are the subject of a large number of general theorems, theorems that are applicable in practice. We give examples. Function level programs also have the possibility of providing solutions to many of the other problems reviewed.

The paper reviews the function level FP system of programs, sketches a function level semantics for it, and from the equations of that semantics develops some moderately general results concerning linear, recursively defined functions, one concerning recursion removal. It then discusses other general, directly applicable results in the literature and shows that they are essentially function level results and are best presented and recognized in that form.

The final section is about optimization; it shows how some FP programs can be transformed into others that run as fast as Fortran programs. It introduces "Fortran constructs" into FP, pure functions that have an obvious corresponding Fortran-like program. It exhibits a number of function level identities for these constructs and shows how these can be used to convert inefficient FP programs into efficient Fortran-like ones.

## References

1. Backus, J. (1978) Can programming be liberated from the von Neumann style? A functional style and its algebra of programs. CACM 21:8 (August)Google Scholar
2. Backus, J. (1981a) Is computer science based on the wrong fundamental concept of "program"? An extended concept. in Algorithmic Languages, de Bakker & van Vliet, eds., North-Holland, Amsterdam (1981)Google Scholar
3. Backus, J. (1981b) The algebra of functional programs: function level reasoning, linear equations, and extended definitions. Lecture Notes in Computer Science #107, Springer-Verlag (April)Google Scholar
4. Backus, J. (1981c) Function level programs as mathematical objects. Proc. Conf. on Functional Programming Languages and Computer Architecture. ACM (October)Google Scholar
5. Bird, R. S. (1984) The promotion and accumulation strategies in transformational programming. Trans. Prog. Langs. & Systs. 6,4 ACM (October)Google Scholar
6. Burstall, R. M., and Darlington, J. (1977) A transformation system for developing recursive programs. JACM 24,1 (January)Google Scholar
7. Cohen, N. H. (1979) Characterization and elimination of redundancy in recursive programs. Proc. 6th Symp. on Principles of Prog. Langs. ACMGoogle Scholar
8. Dijkstra, E. W. (1976) A Discipline of Programming. Prentice-HallGoogle Scholar
9. Guttag, J., Horning, J., and Williams, J. (1981) FP with data abstraction and strong typing. Proc. Conf. on Functional Programming Languages and Computer Architecture. ACM (October)Google Scholar
10. Halpern, J. Y., Williams, J. H., Wimmers, E. L., and Winkler, T. C. (1985) Denotational semantics and rewrite rules for FP. Proc. 12th Symp. on Princ. Prog. Langs., ACM (January)Google Scholar
11. Kieburtz, R. B., and Shultis, J. (1981) Transformations of FP program schemes. Proc. Conf. on Functional Programming Languages and Computer Architecture. ACM (October)Google Scholar
12. Hoare, C. A. R. (1969) An axiomatic basis for computer programming. CACM 12,10 (October)Google Scholar
13. Hughes, R. J. M. (1982) Super combinators: a new implementation method for applicative languages. Proc. Symp. on LISP and Functional Programming ACM (August)Google Scholar
14. Manna, Z. (1974) Mathematical Theory of Computation. McGraw-HillGoogle Scholar
15. Mills, H. D. (1975) The new math of computer programming. CACM 18,1 (January)Google Scholar
16. Stoye, W. R., Clarke, T. J. W. and Norman, A. C. (1984) Some practical methods for rapid combinator reduction. Proc. Symp. on LISP and Functional Programming ACM (August)Google Scholar
17. Turner, D. A. (1979) A new implementation technique for applicative languages, Software Practice & Experience, vol 9, pp31–49Google Scholar
18. Turner, D. A. (1981) The semantic elegance of applicative languages. Proc. Conf. on Functional Programming Languages and Computer Architecture. ACM (October)Google Scholar
19. Wadler, P. (1981) Applicative style programming, program transformation, and list operators. Proc. Conf. on Functional Programming Languages and Computer Architecture. ACM (October)Google Scholar
20. Wadler, P. (1984) Listlessness is better than laziness: lazy evaluation and garbage collection at compile time. Proc. Symp. on LISP and Functional Programming ACM (August)Google Scholar
21. Williams, J. H. (1982) On the development of the algebra of functional programs. Trans. Prog. Langs. & Systs. 4,4 ACM (October)Google Scholar