Texts and Monographs in Computer Science Editor David Gries Advisory Board F. L. Bauer K. S. Fu J. J. Horning R. Reddy D. C. Tsichritzis W. M. Waite
Programming Methodology A Collection of Articles by Members of IFIP WG2.3.Q~ ~. IFIP Edited by David Gries Sprlnger.Verlag New York Heidelberg Berlin
David Gries Cornell University Department of Computer Science Upson Hall Ithaca, New York 14859 USA AMS Subject Qassifications: 68A05, 68AlO, 68A20 (C.R.) Computing Classifications: 4.0, 4.2, 4.35, 5.24 Library of Congress Cataloging in Publication Data Main entry under title: Programming methodology. (Texts and monographs in computer science) Bibliography: p. Includes index. 1. Electronic digital computers-programming Addresses, essays, lectures. I. Gries, David, 1939- QA76.6.P7516 001.6'42 78-16539 ISBN 0-387-90329-1 All rights reserved. No part of this book may be translated or reproduced in any form without written permission from Springer-Verlag. 1978 by Springer-Verlag New York Inc. Softcover reprint of the hardcover 18t edition 1978 ISBN-13: 978-1-4612-6317-3 001: 10.1007/978-1-4612-6315-9 e-isbn-13: 978-1-4612-6315-9
Contents Preface Acknowledgments ix xiii A History of WG2.3 1 M. Woodger Part I: Viewpoints on Programming 7 1. The humble programmer 9 E. W. Dijkstra 2. Software engineering 23 J. N. Buxton 3. Software engineering-some principles and problems 29 W. M. Turski 4. The engineering of software: a startling contradiction 37 5. Programs, cities, students-limits to growth? 42 M. M. Lehman 6. On structured programming 70 D. Gries Part II: The Concern for Program Correctness 75 7. Correctness concerns and, among other things, why they are resented 80 E. W. Dijkstra v
vi CONTENTS 8. An axiomatic basis for computer programming 89 9. Proof of a program: FIND 101 10. An approach to correctness proofs for semicoroutines 116 O.-J. Dahl 11. An axiomatic proof technique for parallel programs 130 S. Owicki and D. Gries 12. Programming with transition diagrams J. C. Reynolds 153 13. Guarded commands, nondeterminacy, and formal derivation of programs 166 E. W Dijkstra 14. A system which automatically improves programs 176 J. Darlington and R. M. Burstall Part III: Harnessing Parallelism 1'99 15. Towards a theory of parallel programming 202 16. Structured multiprogramming 215 P. Brinch Hansen 17. Monitors: an operating system structuring concept 224 18. The programming language Concurrent Pascal 244 P. Brinch Hansen Part IV: Data Types 263 19. Proof of correctness of data representations 269 20. The algebraic specification of abstract data types 282 J. V. Guttag and J. J. Horning 21. User-defined types and procedural data structures as complementary approaches to data abstraction 309 J. C. Reynolds
CONTENTS vii Part V: Software Development 319 22. Program development by stepwise refinement 321 N. Wirth 23. On a "buzzword": hierarchical structure 335 D. L. Parnas 24. On the design and development of program families 343 D. L Parnas 25. System structure for software fault tolerance 362 B. Randell 26. Structured analysis (SA): a language for communicating ideas 388 D. T. Ross References 422
Preface This volume is being published for two reasons. The first is to present a collection of previously published articles on the subject of programming methodology that have helped define the field and give it direction. It is hoped that the scientist in the field will find the volume useful as a reference, while the scientist in neighboring fields will find it useful in seriously acquainting himself with important ideas in programming methodology. The advanced student can also study it-either in a course or by himself -in order to learn significant material that may not appear in texts for some time. The second reason for this volume is to make public the nature and work on programming methodology of IFIP Working Group 2.3, hereafter called WG2.3. (IFIP stands for International Federation for Information Processing.) WG2.3 is one of many IFIP Working Groups that have been established to provide international forums for discussion of ideas in various areas. Generally, these groups publish proceedings of some of their meetings and occasionally they sponsor a larger conference that persons outside a group can attend. WG2.3 has been something of a maverick in this respect. From the beginning the group has shunned paperwork, reports, meetings, and the like. This has meant less publicity for IFIP and WG2.3, but on the other hand it has meant that meetings could be devoted almost wholly to scientific discussions. Moreover, meetings have not centered on formal presentation of completed, published material; instead, the emphasis has been on the presentation and discussion of research underway. Thus, members could receive their colleagues' constructive criticisms at a much earlier stage than usual. Many members feel that this mode of operation has furthered their own research endeavors, and have accordingly acknowledged WG2.3 in their publications. This volume, then, is the first formal "output" from WG2.3. It contains articles by members of the group that are deemed to be significant and ix
x PREFACE exemplary work of programming methodology and of WG2.3. Unfortunately, lack of space prohibits the incorporation of material by all members. Many have written important books, articles, and technical reports that simply could not be included. Each of the next five Parts consists of an Introduction and a series of articles devoted to one aspect or area of programming methodology. Part I contains a number of largely nontechnical articles, many of them based on lectures, which give thoughts, opinions, and viewpoints on various aspects of the field. This Part should give the reader a definite view of where the experts think programming has been and where it is or should be going. Parts II through V then cover four different areas of programming methodology in detail. These certainly do not define the complete field of programming methodology (which is nowhere defined), but they represent significant aspects of the subject. Part II contains articles on the use of correctness proofs in programming and the related topic of defining a programming language so as to facilitate proofs. Part II is the largest of the five Parts, reflecting the importance of the subject and the major role played by members of WG2.3 in its development. The articles in Part III attack the problem of harnessing parallelism so that it can be used effectively-particularly in operating systems. Part IV is devoted to the topic of (programmer-defined) data types and their use in programming. Finally, the articles in Part V deal with different aspects of creating large programs and/or systems of programs, and is entitled Software Development. Following Part V is a list of references, which is split into two sections. The first is a WG2.3 Bibliography-a list of publications relevant to programming methodology by members of WG2.3. Most of this was compiled by Sol J. Greenspan and Jim J. Horning (see [Horning 77b*]); the reader might wish to obtain this report, which contains annotations not included here. All the publications cited by articles in this volume are Ii,sted either in the WG2.3 Bibliography or in the second list of references following this bibliography, and all references within the text are to one of these lists. Examples will illustrate the nature of the text references: [Burstall 72b*] refers to the second (because of b) 1972 article by Burstall (Algebraic description of programs with assertions, verification, and simulation); the "*,, indicates that it is to be found in the WG2.3 Bibliography. The reference [Mills 72] refers to the 1972 article by Mills (Mathematical foundations of structured programming), which appears in the second list of references (no "*,, is present). In compiling this volume, I have had the help of many people. Mike Woodger, the first chairman of WG2.3, was influential in getting this project underway and constructed an initial list of potential articles. Jim Horning, the current chairman, continued to support the project and (along with Greenspan) provided most of the references in the WG2.3 Bibliography. I have had the advice and criticism of WG2.3 members and
PREFACE xi of Jim Donahue, Greg Andrews, and Manfred Paul both on my selection of articles and on my Introductions. Needless to say, however, I take full responsibility for any mistakes, for the selection and arrangement of the articles, and for the omission of many other excellent articles in order to keep the volume to a reasonable size. It should be mentioned that the volume would not have been possible without the dedicated and creative work of the authors of the articles. David Gries
Acknowledgments The editor, the authors, IFIP, and the publishers acknowledge with thanks permission to reprint the copyrighted articles in this book that have been published in various journals, proceedings, and books. With a few exceptions, the articles are reprinted from Acta Informatica, the Communications of the ACM, the Computer Bulletin, IEEE Trans. on Software Engineering, Lecture Notes in Computer Science (Springer-Verlag), books by Academic Press and Prentice-Hall, and the Proc. of the International Conference on Reliable Software. Below we give the individual credits. Brinch Hansen, P. Structured multiprogramming. By permission of the ACM, from CACM IS (July 1972), 574-578. Brinch Hansen, P. The programming language Concurrent Pascal. By permission of the Institute of Electrical and Electronics Engineers, Inc., from IEEE Trans. Software Eng. 1 (June 1975), 199-207. Buxton, J. N. Software engineering. By permission of the author, from Proc. 1974 CERN School of Computing, CERN Rpt. No. 74-23 (Nov 1974), 394-401. Dahl, O.-J. An approach to correctness proofs of semicoroutines. By permission of the author, from Math. Foundations of Computer Science. LNCS 28 (1975), 157-174. Darlington, J. and Burstall, R. M. A system which automatically improves programs. By permission of Springer-Verlag, from Acta Informatica 6 (1976), 41-60. Dijkstra, E. W. The humble programmer. By permission of the ACM, from CACM IS (Oct 1972),859-886. Dijkstra, E. W. Correctness concerns and, among other things, why they are resented. By permission of the author, from Proc. Int. Conf. on Reliable Software, S/GPLAN Notices 10 (June 1975), 546-550. Dijkstra, E. W. Guarded commands, nondeterminacy, and formal derivation of programs. By permission of the ACM, from CACM 18 (Aug 1975),453-457; also appeared in Yeh, R. T. (ed.), Current Trends in Programming Methodology I. Prentice-Hall, 1976,233-242. Gries, D. On structured programming. By permission of the ACM, based on a letter to the editor by the author in CACM 17 (Nov 1974),655-657. Guttag, J. V. and Homing, J. J. The algebraic specification of abstract data types. By permission of Springer-Verlag, from Acta Informatica, to appear. xiii
xiv ACKNOWLEDGMENTS Hoare, C. A. R. An axiomatic basis for computer programming. By permission of the ACM, from CACM 12 (Oct 1969),576-580,583. Hoare, C. A. R. Proof of a progfam: FIND. By permission of the ACM, from CACM 14 (Jan 1971), 39-45. Hoare, C. A. R. Towards a theory of parallel programming. By permission of Academic Press, from Hoare, C. A. R. and Perrott, R. N. (eds.), Operating Systems Techniques. Academic Press, 1972. Hoare, C. A. R. Proof of correctness of data representations. By permission of Springer-Verlag, from Acta Informatica 1 (1972), 271-281. Hoare, C. A. R. Monitors: an operating system structuring concept. By permission of the ACM, from CACM 17 (Oct 1974),549-557. Hoare, C. A. R. The engineering of software: a startling contradiction. By permission of the British Computer Society, based on a note by the author in the Computer Bulletin (Dec 1975). Lehman, M. M. Programs, cities, students-limits to growth? By permission of the author, from Inaugural Lecture College Series, Vol. 9, 1970-1974,211-229. Owicki, S. and Gries, O. An axiomatic proof technique for parallel programs. By permission of Springer-Verlag, from Acta Informatica 6 (1976),319-340. Parnas, D. L. On a "buzzword": hierarchical structure. By permission of the author, from IFIP 1974, 336-339. Parnas, D. L. On the design and development of program families. By permission of the Inst. of Electrical and Electronics Engineers, Inc., from IEEE Trans. Softwart: Eng. 1 (March 1976), 1-9. Randell, B. System structure for software fault tolerance. By permission of the Inst. of Electrical and Electronics Engineers, Inc., from IEEE Trans. Software Eng. 1 (April 1975),220-232; also appeared in Yeh, R. T. (ed.), Current Trends in Programming Methodology I. Prentice-Hall, 1976, 195-219. Reynolds, J. C. Programming with transition diagrams. By permission of the author. Reynolds, J. C. User-defined types and procedural data structures as complementary approaches to data abstraction. By permission of the author, from Schuman, S. A. (ed.), New Directions in Algorithmic Languages 1975, Inst. de Recherche d'informatique et d'automatique, Rocquencourt, 1975, 157-168. Ross, D. T. Structured analysis (SA): a language for communicating ideas. By permission of the Inst. of Electrical and Electronics Engineers, Inc., from IEEE Trans. Software Eng. 3 (Jan 1977), 16-34. Turski, W. M. Software engineering-some principles and problems. By permission of the author, from Mathematical Structures-Computational Mathematics Mathematical Modelling. Publ. House of the Bulgarian Academy of Sciences, Sofia, 1975,485-491. Wirth, N. Program development by stepwise refinement. By permission of the ACM, from CACM 14 (April 1971),221-227.