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.


Termination Function Program Code Transition Diagram Initial Situation Correctness Proof 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 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. 2.
    Back, R.-J.: Program construction by situation analysis. Research Report 6, Computing Centre, University of Helsinki, Helsinki, Finland (1978)Google Scholar
  3. 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. 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
  5. 5.
    Barnett, M., Leino, K.R.M., Schulte, W.: The spec-sharp programming system: An overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  6. 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
  7. 7.
    Dijkstra, E.W.: A constructive approach to the problem of program correctness. BIT 8, 174–186 (1968)MATHCrossRefGoogle Scholar
  8. 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
  9. 9.
    Dijkstra, E.W.: A Discipline of Programming. Prentice-Hall, Englewood Cliffs (1976)MATHGoogle Scholar
  10. 10.
    Fowler, M.: UML Distilled. Addison-Wesley, Reading (1999)Google Scholar
  11. 11.
    Harel, D.: State charts: a visual formalism for complex systems. Science of Computer Programming 8, 231–274 (1987)MATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Hehner, E.: Do considered od: a contribution to the programming calculus. Acta Informatica 11, 287–304 (1979)MATHCrossRefGoogle Scholar
  13. 13.
    Leino, K.R.M., Nelson, G.: An extended static checker for modula-3. In: Koskimies, K. (ed.) CC 1998. LNCS, vol. 1383, pp. 302–305. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  14. 14.
    Nelson, G.: Techniques for Program Verification. PhD thesis, Stanford University (1980)Google Scholar
  15. 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. 16.
    Reynolds, J.C.: Programming with transition diagrams. In: Gries, D. (ed.) Programming Methodology. Springer, Berlin (1978)Google Scholar
  17. 17.
    van Emden, M.H.: Programming with verification conditions. IEEE Transactions on Software Engineering SE-5 (1979)Google Scholar
  18. 18.
    Van Rossum, G., Drake Jr., F.L.: The Python Tutorial - An Introduction to Python. Network Theory Ltd. (2003)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Ralph-Johan Back
    • 1
  1. 1.Abo Akademi UniversityTurkuFinland

Personalised recommendations