Skip to main content

Forward with Hoare

  • Chapter
  • First Online:
Reflections on the Work of C.A.R. Hoare

Abstract

Hoare’s celebrated paper entitled “An Axiomatic Basis for Computer Programming” appeared in 1969, so the Hoare formula P{S}Q is now 40 years old! That paper introduced Hoare Logic, which is still the basis for program verification today, but is now mechanised inside sophisticated verification systems. We aim here to give an accessible introduction to methods for proving Hoare formulae based both on the forward computation of postconditions and on the backward computation of preconditions. Although precondition methods are better known, computing postconditions provides a verification framework that encompasses methods ranging from symbolic execution to full deductive proof of correctness.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 129.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 169.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 169.99
Price excludes VAT (USA)
  • Durable hardcover 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

Institutional subscriptions

Notes

  1. 1.

    The word ‘statement’ is overused: Hoare statements P{S}Q (or {P}S{Q}) are either true or false, but program statements are constructs that can be executed to change the values of variables. To avoid this confusion program statements are sometimes called commands.

  2. 2.

    The fascinating story of the flow of ideas between the early pioneers of programming logic is delightfully told in Jones’ historical paper [16].

  3. 3.

    Dijkstra defined ‘weakest precondition’ to require termination of S – what we are calling ‘weakest precondition’ he calls ‘weakest liberal precondition’. Dijkstra also uses different notation: in his first book he uses wlp( S,Q) and wp( S,Q). In the later book with Scholten he uses wlp. S.Q and wp. S.Q. Thus our wp SQ is Dijkstra’s wlp( S,Q) (or wlp. S.Q). However, our use of ‘strongest postcondition’ corresponds to Dijkstra’s, though our notation differs.

  4. 4.

    Actually this is an oversimplification: mathematical constants might occur in the formula, e.g.+,−, ×from the theory of arithmetic, so the theorem prover may need to go beyond pure logic and solve problems in mathematical theories.

  5. 5.

    State-of-the-art bounded model checkers [1, 3] generate the strongest postcondition using similar rules to those given in Fig. 5.1. However, they first transform programs into SSA (Static Single Assignment) form [5] and avoid the explicit use of existential quantifiers generated by assignments. The approach in this paper seems equivalent to the use of SSA, but we have not worked out a clean account of this. A feature of our method is that it applies directly to programs without requiring any preprocessing.

References

  1. Mantovani, J., Armando, A., Platania, L.: Bounded model checking of software using smt solvers instead of sat solvers. Int. J. Software Tools Technol. Transfer 11(1), 69–83 February. (2009).

    Google Scholar 

  2. Apt, K.R.: Ten years of Hoare’s logic: A survey – part I. ACM Trans. Program. Lang. Syst. 3(4), 431–483 (1981).

    Article  MATH  Google Scholar 

  3. ClarkeE., L.F., Kroening,D., Lerda F.: A tool for checking ansi-c programs. In: TACAS 2004, vol. 2988 of LNCS, pp. 168–176. Springer-verlag (2004).

    Google Scholar 

  4. Cook, S.A.: Soundness and completeness of an axiom system for program verification. SIAM J. Comput. 7(1), 70–90 (1978).

    Article  MATH  MathSciNet  Google Scholar 

  5. Cytron, R., Ferrante, J., Rosen, B.K., Wegman, M.N., Zadeck, F.K.: Efficently computing static single assignment form and control dependence graph. Trans. Program. Lang. Systems,13(4), 451–490 (1991).

    Article  Google Scholar 

  6. Dijkstra, E.W.: A Discipline of Programming. Prentice Hall (October 1976).

    Google Scholar 

  7. Dijkstra, E.W., Scholten, C.S.: Predicate Calculus and Program Semantics. Texts and Monographs in Computer Science. Springer, New York, Inc., New York, NY, USA (1990).

    Book  MATH  Google Scholar 

  8. Floyd, R.W.: Assigning meanings to programs. In: Procsedings of the. Sympos. Applied. Mathematics., Vol. XIX, pp. 19–32. Amer. Math. Soc., Providence, R.I., (1967).

    Google Scholar 

  9. Gannod, G.C., Cheng, B.H.C.: Strongest postcondition semantics as the formal basis for reverse engineering. In: WCRE ’95: Proceedings of the Second Working Conference on Reverse Engineering, p. 188, IEEE Computer Society. Washington, DC, USA (1995).

    Google Scholar 

  10. Gries, D.: The Science of Programming. Springer (1981).

    Google Scholar 

  11. Henzinger, T.A., Jhala, R., Majumdar, R., McMillan, K.L.: Abstractions from proofs. In: Jones, N.D., Leroy, Xa. (eds.), POPL, pp. 232–244. ACM (2004).

    Google Scholar 

  12. Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. the ACM 12(10), 576–580 October (1969).

    Article  MathSciNet  Google Scholar 

  13. Hoare, C.A.R., Lauer, P.E.: Consistent and complementary formal theories of the semantics of programming languages. Acta Inf. 3, 135–153 (1974).

    MATH  MathSciNet  Google Scholar 

  14. Igarashi, S., London, R.L., Luckham, D.C.: Automatic program verificationI: A logical basis and its implementation. Acta Inf. 4, 145–182 (1975).

    Article  MathSciNet  Google Scholar 

  15. Igarashi, S., London, R.L., Luckham, D.C.: Automatic program verification i: a logical basis and its implementation. Technical report, Stanford University, Stanford, CA, USA (1973).

    Google Scholar 

  16. Jones, C.B.: The early search for tractable ways of reasoning about programs. IEEE Ann. Hist. Comput. 25(2), 26–49, (2003).

    Article  MathSciNet  Google Scholar 

  17. King, J.C.: A program verifier. In: IFIP Congress (1), pp. 234–249 (1971).

    Google Scholar 

  18. King, J.C.: Symbolic execution and program testing. Commun. ACM 19(7), 385–394 (July 1976).

    Article  MATH  Google Scholar 

  19. Cornelius King, J.: A program verifier. PhD thesis, Carnegie Mellon University, Pittsburgh, PA, USA (1970).

    Google Scholar 

  20. Luckham, D.C.: A brief account: Implementation and applications of a pascal program verifier (position statement). In: ACM ’78: Proceedings of the 1978 Annual conference, pp. 786–792 ACM, New York, NY, USA (1978).

    Google Scholar 

  21. O’Hearn, P.W., Reynolds, J.C., Yang, H.: Local reasoning about programs that alter data structures. In: Proceedings of 15th Annual Conference of the European Association for Computer Science Logic, vol. 2142 of Lecture Notes in Computer Science, pp. 1–19. Springer (September 2001).

    Google Scholar 

  22. Pasareanu, Co.S., Visser, W.: Verification of java programs using symbolic execution and invariant generation. In: Graf, S. Mounier, L. (eds.), SPIN, vol. 2989 of Lecture Notes in Computer Science, pp. 164–181. Springer (2004).

    Google Scholar 

  23. von Henke, F.W, Luckham, D.C.: A methodology for verifying programs. In: Proceedings of the International Conference on Reliable Software, pp. 156–164 ACM, New York, NY, USA (1975).

    Google Scholar 

  24. Winskel, G.: The Formal Semantics of Programming Languages: an Introduction. MIT, Cambridge, MA, USA (1993).

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Mike Gordon .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2010 Springer London

About this chapter

Cite this chapter

Gordon, M., Collavizza, H. (2010). Forward with Hoare. In: Roscoe, A., Jones, C., Wood, K. (eds) Reflections on the Work of C.A.R. Hoare. Springer, London. https://doi.org/10.1007/978-1-84882-912-1_5

Download citation

  • DOI: https://doi.org/10.1007/978-1-84882-912-1_5

  • Published:

  • Publisher Name: Springer, London

  • Print ISBN: 978-1-84882-911-4

  • Online ISBN: 978-1-84882-912-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics