Skip to main content

Abstract

Hoare logic is the fundamental formalism introduced by C.A.R. Hoare in 1969 for reasoning about the correctness of imperative programs, building on first-order logic. In this chapter we study a program logic which is a variant of Hoare logic for programs containing user-provided annotations.

The logic deals with the notion of correctness vis a vis a specification that consists of a precondition and a postcondition. The correctness of a program with respect to a given specification is asserted by constructing a derivation in the inference system of Hoare logic. While doing so, one must identify an invariant for every loop in the program.

This chapter also discusses the important problem of adaptation of specifications, since it has major implications on the design of practical verification systems based on Hoare logic.

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 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 39.95
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

Institutional subscriptions

Notes

  1. 1.

    In fact this is aparsing issue, related to the construction of an abstract syntax tree corresponding to a given program text. In our language the purpose of the above convention is to allow brackets to be omitted.

  2. 2.

    This is distinguished from the setVarD in that it excludes the functions that map elements ofVar τ to values inD τ with\(\tau\not=\tau'\).

References

  1. 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 

  2. Backhouse, R.: Program Construction—Calculating Implementations from Specifications. Wiley, New York (2003)

    Google Scholar 

  3. Cousot, P.: Methods and logics for proving programs. In: Handbook of Theoretical Computer Science, Volume B: Formal Models and Semantics (B), pp. 841–994. Elsevier/MIT Press, Cambridge (1990)

    Google Scholar 

  4. Hennessy, M.: The Semantics of Programming Languages. Wiley, New York (1990)

    MATH  Google Scholar 

  5. Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM12, 576–580 (1969)

    Article  MATH  Google Scholar 

  6. Hoare, C.A.R.: Procedures and parameters: an axiomatic approach. In: Proceedings of Symposium on Semantics of Algorithmic Languages. Lecture Notes in Mathematics, vol. 188. Springer, Berlin (1971)

    Google Scholar 

  7. Hoare, C.A.R.: Viewpoint retrospective: An axiomatic basis for computer programming. Commun. ACM52(10), 30–32 (2009)

    Article  Google Scholar 

  8. 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 

  9. Kleymann, T.: Hoare logic and auxiliary variables. Form. Asp. Comput.11(5), 541–566 (1999)

    Article  MATH  Google Scholar 

  10. Loeckx, J., Sieber, K.: The Foundations of Program Verification, 2nd edn. Wiley, New York (1987)

    MATH  Google Scholar 

  11. Nielson, H.R., Nielson, F.: Semantics with Applications: An Appetizer. Undergraduate Topics in Computer Science. Springer, Berlin (2007)

    Book  MATH  Google Scholar 

  12. Reynolds, J.C.: Theories of Programming Languages. Cambridge University Press, Cambridge (1998)

    Book  MATH  Google Scholar 

  13. Tennent, R.D.: Specifying Software—A Hands-on Introduction. Cambridge University Press, Cambridge (2002)

    Book  MATH  Google Scholar 

  14. Winskel, G.: The Formal Semantics of Programming Languages: An Introduction. Foundations of Computing. MIT Press, Cambridge (1993)

    MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to José Bacelar Almeida .

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag London Limited

About this chapter

Cite this chapter

Almeida, J.B., Frade, M.J., Pinto, J.S., Melo de Sousa, S. (2011). Hoare Logic. In: Rigorous Software Development. Undergraduate Topics in Computer Science. Springer, London. https://doi.org/10.1007/978-0-85729-018-2_5

Download citation

  • DOI: https://doi.org/10.1007/978-0-85729-018-2_5

  • Publisher Name: Springer, London

  • Print ISBN: 978-0-85729-017-5

  • Online ISBN: 978-0-85729-018-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics