Is “sometime” sometimes better than “always”?: Intermittent assertions in proving program correctness

This paper explores a technique for proving the correctness and termination of programs simultaneously. This approach, which we call the intermittent-assertion method, involves documenting the program with assertions that must be true at some time when control is passing through the corresponding point, but that need not be true every time. The method, introduced by Knuth and further developed by Burstall, promises to provide a valuable complement to the more conventional methods. We first introduce and illustrate the technique with a number of examples. We then show that a correctness proof using the invariant assertion method can always be expressed using intermittent assertions instead, but argue that the reverse is not always the case. The method can also be used just to prove termination, and any proof of termination using the conventional well-founded sets approach can be rephrased as a proof using intermittent assertions. Finally, we show how the method can be applied to prove the validity of program transformations and the correctness of continuously operating programs. This research was supported in part by the Advanced Research Projects Agency of the Department of Defense under Contract DAHC15-73-C-0435, by the National Science Foundation under Grant GJ-36146, by the Office of Naval Research under Contract N00014-75-C-0816, and by a grant from the United States-Israel Binational Science Foundation (BSF), Jerusalem, Israel.

[1]  Vaughan R. Pratt,et al.  SEMANTICAL CONSIDERATIONS ON FLOYD-HOARE LOGIC , 1976, FOCS 1976.

[2]  Donald E. Knuth The art of computer programming: fundamental algorithms , 1969 .

[3]  James H. Morris,et al.  Subgoal induction , 1977, CACM.

[4]  Donald E. Knuth,et al.  Structured Programming with go to Statements , 1974, CSUR.

[5]  Donald E. Knuth,et al.  The Art of Computer Programming, Volume I: Fundamental Algorithms, 2nd Edition , 1997 .

[6]  Robert W. Floyd,et al.  Assigning meaning to programs , 1967 .

[7]  Zohar Manna,et al.  Mathematical Theory of Partial Correctness , 1971, J. Comput. Syst. Sci..

[8]  J. Schwarz,et al.  Event Based Reasoning - A System for Proving Correct Termination of Programs , 1976, International Colloquium on Automata, Languages and Programming.

[9]  Zohar Manna,et al.  Introduction to mathematical theory of computation , 1972 .

[10]  John Darlington,et al.  A Transformation System for Developing Recursive Programs , 1977, J. ACM.

[11]  Ralph L. London,et al.  A view of program verification , 1975, Reliable Software.

[12]  Rod M. Burstall,et al.  Program Proving as Hand Simulation with a Little Induction , 1974, IFIP Congress.

[13]  John Darlington,et al.  Some transformations for developing recursive programs , 1975, Reliable Software.

[14]  Susan L. Gerhart,et al.  Correctness-preserving program transformations , 1975, POPL '75.

[15]  William W. Wadge,et al.  Intermittent Assertion Proofs in Lucid , 1977, IFIP Congress.

[16]  A. Wang An axiomatic basis for proving total correctness of goto-programs , 1976 .

[17]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .