Invariant Based Programming
Program verification is usually done by adding specifications and invariants to the program and then proving that the verification conditions are all true. This makes program verification an alternative to or a complement to testing. We study here an another approach to program construction, which we refer to as invariant based programming, where we start by formulating the specifications and the internal loop invariants for the program, before we write the program code itself. The correctness of the code is then easy to check at the same time as one is constructing it. In this approach, program verification becomes a complement to coding rather than to testing. The purpose is to produce programs and software that are correct by construction. We present a new kind of diagrams, nested invariant diagrams, where program specifications and invariants (rather than the control) provide the main organizing structure. Nesting of invariants provide an extension hierarchy that allows us to express the invariants in a very compact manner. We study the feasibility of formulating specifications and loop invariants before the code itself has been written. We propose that a systematic use of figures, in combination with a rough idea of the intended behavior of the algorithm, makes it rather straightforward to formulate the invariants needed for the program, to construct the code around these invariants and to check that the resulting program is indeed correct.
KeywordsTermination Function Program Code Transition Diagram Initial Situation Correctness Proof
Unable to display preview. Download preview PDF.
- 1.Back, R., Myreen, M.: Tool support for invariant based programming. In: Proceedings of the 12th Asia-Pacific Software Engineering Conference, Taipei, Taiwan (December 2005)Google Scholar
- 2.Back, R.-J.: Program construction by situation analysis. Research Report 6, Computing Centre, University of Helsinki, Helsinki, Finland (1978)Google Scholar
- 3.Back, R.-J.: Exception handling with multi-exit statements. In: Hoffmann, H.J. (ed.) 6th Fachtagung Programmiersprachen und Programmentwicklungen, Darmstadt. Informatik Fachberichte, vol. 25, pp. 71–82. Springer, Heidelberg (1980)Google Scholar
- 4.Back, R.-J.: Invariant based programs and their correctness. In: Biermann, W., Guiho, G., Kodratoff, Y. (eds.) Automatic Program Construction Techniques, pp. 223–242. MacMillan Publishing Company, Basingstoke (1983)Google Scholar
- 6.Burdy, L., Cheon, Y., Cok, D.R., Ernst, M.D., Kiniry, J.R., Leavens, G.T., Leino, K.R.M., Poll, E.: An overview of jml tools and applications. Software Tools for Technology Transfer 7(3) (June 2005)Google Scholar
- 8.Dijkstra, E.W.: Notes on structured programming. In: Dahl, O.-J., Hoare, C.A.R., Dijkstra, E.W. (eds.) Structured Programming. Academic Press, New York (1972)Google Scholar
- 10.Fowler, M.: UML Distilled. Addison-Wesley, Reading (1999)Google Scholar
- 14.Nelson, G.: Techniques for Program Verification. PhD thesis, Stanford University (1980)Google Scholar
- 15.Owre, S., Shankar, N., Rushby, J.: Pvs: A prototype verification system. In: Kapur, D. (ed.) CADE 1992. LNCS, vol. 607. Springer, Heidelberg (1992)Google Scholar
- 16.Reynolds, J.C.: Programming with transition diagrams. In: Gries, D. (ed.) Programming Methodology. Springer, Berlin (1978)Google Scholar
- 17.van Emden, M.H.: Programming with verification conditions. IEEE Transactions on Software Engineering SE-5 (1979)Google Scholar
- 18.Van Rossum, G., Drake Jr., F.L.: The Python Tutorial - An Introduction to Python. Network Theory Ltd. (2003)Google Scholar