Mathematical Foundations for Structured Programming

Mathematical Foundations for Structured Programming

University of Tennessee, Knoxville TRACE: Tennessee Research and Creative Exchange The Harlan D. Mills Collection Science Alliance 2-1972 Mathematical Foundations for Structured Programming Harlan D. Mills Follow this and additional works at: https://trace.tennessee.edu/utk_harlan Part of the Mathematics Commons, and the Software Engineering Commons Recommended Citation Mills, Harlan D., "Mathematical Foundations for Structured Programming" (1972). The Harlan D. Mills Collection. https://trace.tennessee.edu/utk_harlan/56 This Book is brought to you for free and open access by the Science Alliance at TRACE: Tennessee Research and Creative Exchange. It has been accepted for inclusion in The Harlan D. Mills Collection by an authorized administrator of TRACE: Tennessee Research and Creative Exchange. For more information, please contact [email protected]. University of Tennessee, Knoxville Trace: Tennessee Research and Creative Exchange The aH rlan D. Mills Collection Science Alliance 2-1972 Mathematical Foundations for Structured Programming Harlan D. Mills Follow this and additional works at: http://trace.tennessee.edu/utk_harlan Part of the Mathematics Commons, and the Software Engineering Commons Recommended Citation Mills, Harlan D., "Mathematical Foundations for Structured Programming" (1972). The Harlan D. Mills Collection. http://trace.tennessee.edu/utk_harlan/56 This Book is brought to you for free and open access by the Science Alliance at Trace: Tennessee Research and Creative Exchange. It has been accepted for inclusion in The aH rlan D. Mills Collection by an authorized administrator of Trace: Tennessee Research and Creative Exchange. For more information, please contact [email protected]. athematical Foundations for Structured Programming B Harlan D. Mills FSC 72-6012 MATHEMATICAL FOUNDATIONS II FOR STRUCTURED PROGRAMMING by HarlanD ~~ February 1972 SEP Federal Systems Division INTERNATIONAL BUSINESS MACHINES CORPORATION Gaithersburg, Maryland 20760 :Copyright 1972 International Bus iness Machines Corporation FOREWORD The first name in structured programming is Edsger W. Dijkstra (Holland), who has originated a set of ideas and a series of examples for clear thinking in the construction of programs. These ideas are powerful tools in mentally connecting the static text of a program with the dynamic process it invokes in execution. This new correspondence between program and process permits a new level of precision in programming. Indeed, it is contended here that the precision now possible in programming will change its industrial characteristics from a frustrating, trial and error activity to a systematic, quality controlled activity. However, in order to introduce and enforce such precision programming as an industrial activity, the ideas of structured programming must be formulated as technical standards, not simply as good ideas to be used when convenient, but as basic principles which are always valid. A good example of a technical standard occurs in logic circuit design. There, it is known, from basic theorems in boolean algebra, that an~ logic circuit, no matter how complex its requirement, can be constructed using only AND, OR, and NOT gates. Our interest is similar, to provide a mathematical assurance, for manage­ 1 ment purposes, t:'hat: a ..ac1ni':C& ..L 'il"L<mdM..4.. ~!t !LO_u_qQ_ a_!!~l_ ~ractical. This mathematical assurance is due, in large part, to Corrado Bohm and Giuseppe Jacopini (Italy), who showed how to prove that relatively simple (structured) program control logics were capable of expressing any pro­ gram requirements. Initial practical experience with structured programming indicates there is more than a technical side to the matter. There is a psychological effect, as well, when programmers learn of their new power to write programs correctly. This new power motivates, in turn, a new level of concentration, which helps avoid errors of carelessness. This new psychology of precision has a mathematical counterpart in the theory of program correctness, which we formulate in a new way. The mathematical appYoach we take in formulating stYuctured programming and the correctness problem emphasizes these combinatorial aspects, in order to demonstrate for programmers that corre~t programming involves only combinatorial selection, and not problems requiring perfect pre­ cision, on a continuous scale. Because of this, we are confident that programmers will soon work at a level of productivity and precision which will appear incredible compared to early experience with the programming problem. ii-- CONTENTS Page Complexity and Precision in Programming The Psychology of Precision 2 The Problem of Complexity 3 The Idea of Structured Programming 4 The Correctness of Structured Programs 6 Ft.mctions 8 Functions and Rules 8 Ft.mction Composition and Completion 10 Special Functions 11 Programs 12 Control Graphs 13 Programs in Flowchart Form 14 Program Execution 16 Proper Programs 17 Program Equivalence 18 Program Expansions 19 Control Graph Labels 20 Program Formulas 22 Program Descriptions 25 Structured Programs 27 The Number of Control Lines in a Proper Program 30 Lemma 30 Proof 30 Structure Theorem 31 Proof 31 Summary 38 Top Down Corollary 39 S-Structured Programs 40 Program Representations 40 Program Trees 41 iii Page Program Correctness 43 Correctness Theorem 43 Proof 44 Correctness Notes 49 Top Down Program Expansions so Expansion Theorem (Verbal Version) 51 Expansion Theorem (Set Theoretic Version) 52 Proof 53 Indeterminate Programs 57 References 59 iv COMPLEXITY AND PRECISION IN PROGRAMMING The digital computer has introduced a need for highly complex, precisely formulated, logical systems on a scale never before attempted. Systems may be large and highly complex, but if human beings, or even analog devices, are components in them, then various error tolerances are possible, which such components can adjust and compensate for. However, a digital computer, in hardware and software, not only makes the idea of perfect precision possible -- it requires perfect precision for satis­ factory operation. This complete intolerance to the slightest logical error gives programming a new character, little known previously, in its requirements for precision on a large scale. The combination of this new requirement for precision, and the commercial demand for computer programming on a broad scale, has created many false values and distorted relationships in the past decade. They arise from intense pressure to achieve complex and precision results in a practical way without adequate technical foundations. As a result, a great deal of programming uses people and computers highly inefficiently, as the only means presently known to accomplish a practical end. It is universally accepted today that programming is an error-prone activity. Any major programming system is presumed to have errors in it. Only the very naive would believe otherwise. The process of debugging programs and systems is a mysterious art. Indeed, more programmer time goes into debugging than into program designing and coding in most large systems. But there is practically no systematic literature on this large undertaking. Yet, even though errors in program logic have always been a source of frustration, even for the most careful and meticulous, this may not be necessarily so in the future. Programming is very young as a human activity -· some twenty years old. It has practically no technical foundations yet. Imagine engineering when it was twenty years old. Whether that was in 1620 or 1770, it was not in very good technical shape at that stage either! As technical foundations are developed for programming, its character will undergo radical changes. We contend here that such a radical change is possible now •• that in structured programming the techniques and tools are at hand to permit an entirely new level of precision in programming. This new level of precision will be characterized by programs of large size (from tens of thousands to millions of instructions) which have 1 mean time between detected errors of a year or so. But to accomplish that level of precision a new attitude toward programming expectations will be required in programmers, as well. THE PSYCHOLOGY OF PRECISION A child can learn to play the game of tic tac toe perfectly -· but a man can never learn to saw a board exactly in half. Playing tic tac toe is a combinatorial problem, selecting, at every alternative, one of a finite number of possibilities. Sawing a board exactly in half is a physical problem, for which no discrete level of accuracy is sufficient. The child who has learned to play tic tac toe need never make a mistake, except through a loss of concentration. In any game he believes important (say played for a candy bar) he is capable of perfect play. Computer programming is a combinatorial activity, like tic tac toe, not like sawing a board in half. It does not require perfect resolution in measurement and control -- it only requires correct choices out of finite sets of possibilities at every step. The difference between tic tac toe and computer programming is complexity. The purpose of structured program­ ming is to control complexity through theory and discipline. And with complexity under better control, it now appears that men can write sub­ stantial computer programs correctly. In fact, just as a child moves from groping and frustration to confidence and competence in tic tac toe, so men can now find solid ground for program development. A child, in learning to play

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    69 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us