Skip to main content

Invariant Based Programming

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 4024))

Abstract

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.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  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 

  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)

    Chapter  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 

  7. Dijkstra, E.W.: A constructive approach to the problem of program correctness. BIT 8, 174–186 (1968)

    Article  MATH  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 

  9. Dijkstra, E.W.: A Discipline of Programming. Prentice-Hall, Englewood Cliffs (1976)

    MATH  Google Scholar 

  10. Fowler, M.: UML Distilled. Addison-Wesley, Reading (1999)

    Google Scholar 

  11. Harel, D.: State charts: a visual formalism for complex systems. Science of Computer Programming 8, 231–274 (1987)

    Article  MATH  MathSciNet  Google Scholar 

  12. Hehner, E.: Do considered od: a contribution to the programming calculus. Acta Informatica 11, 287–304 (1979)

    Article  MATH  Google Scholar 

  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)

    Chapter  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 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Back, RJ. (2006). Invariant Based Programming. In: Donatelli, S., Thiagarajan, P.S. (eds) Petri Nets and Other Models of Concurrency - ICATPN 2006. ICATPN 2006. Lecture Notes in Computer Science, vol 4024. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11767589_1

Download citation

  • DOI: https://doi.org/10.1007/11767589_1

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-34699-9

  • Online ISBN: 978-3-540-34700-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics