Skip to main content

A Hoare Logic for the State Monad

Proof Pearl

  • Conference paper

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

Abstract

This pearl examines how to verify functional programs written using the state monad. It uses Coq’s Program framework to provide strong specifications for the standard operations that the state monad supports, such as return and bind. By exploiting the monadic structure of such programs during the verification process, it becomes easier to prove that they satisfy their specification.

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. Cock, D., Klein, G., Sewell, T.: Secure microkernels, state monads and scalable refinement. In: Munoz, C., Ait, O. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 167–182. Springer, Heidelberg (2008)

    Chapter  Google Scholar 

  2. Floyd, R.W.: Assigning meanings to programs. Mathematical Aspects of Computer Science 19 (1967)

    Google Scholar 

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

    Article  MATH  Google Scholar 

  4. Hutton, G., Fulger, D.: Reasoning about effects: seeing the wood through the trees. In: Proceedings of the Ninth Symposium on Trends in Functional Programming (2008)

    Google Scholar 

  5. Leroy, X.: Formal certification of a compiler back-end, or: programming a compiler with a proof assistant. In: POPL 2006: 33rd Symposium on Principles of Programming Languages, pp. 42–54. ACM Press, New York (2006)

    Google Scholar 

  6. Martin-Löf, P.: Constructive mathematics and computer programming. In: Proceedings of a discussion meeting of the Royal Society of London on Mathematical logic and programming languages, pp. 167–184. Prentice-Hall, Inc., Englewood Cliffs (1985)

    Google Scholar 

  7. McKinna, J.: Deliverables: a categorical approach to program development in type theory. Ph.D thesis, School of Informatics at the University of Edinburgh (1992)

    Google Scholar 

  8. Nanevski, A., Morrisett, G.: Dependent type theory of stateful higher-order functions. Technical Report TR-24-05, Harvard University (2005)

    Google Scholar 

  9. Nanevski, A., Morrisett, G., Birkedal, L.: Polymorphism and separation in Hoare Type Theory. In: ICFP 2006: Proceedings of the Eleventh ACM SIGPLAN Internation Conference on Functional Programming (2006)

    Google Scholar 

  10. Nanevski, A., Morrisett, G., Shinnar, A., Govereau, P., Birkedal, L.: Ynot: Reasoning with the awkward squad. In: ICFP 2008: Proceedings of the Twelfth ACM SIGPLAN International Conference on Functional Programming (2008)

    Google Scholar 

  11. Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)

    MATH  Google Scholar 

  12. Sozeau, M.: Subset coercions in Coq. In: Altenkirch, T., McBride, C. (eds.) TYPES 2006. LNCS, vol. 4502, pp. 237–252. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  13. Sozeau, M.: Un environnement pour la programmation avec types dépendants. Ph.D thesis, Université de Paris XI (2008)

    Google Scholar 

  14. Sprenger, C., Basin, D.: A monad-based modeling and verification toolbox with application to security protocols. In: Schneider, K., Brandt, J. (eds.) TPHOLs 2007. LNCS, vol. 4732, pp. 302–318. Springer, Heidelberg (2007)

    Chapter  Google Scholar 

  15. The Coq development team. The Coq proof assistant reference manual. LogiCal Project, Version 8.2 (2008)

    Google Scholar 

  16. Wadler, P.: The essence of functional programming. In: POPL 1992: Conference Record of the Nineteenth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 1–14 (1992)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2009 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Swierstra, W. (2009). A Hoare Logic for the State Monad. In: Berghofer, S., Nipkow, T., Urban, C., Wenzel, M. (eds) Theorem Proving in Higher Order Logics. TPHOLs 2009. Lecture Notes in Computer Science, vol 5674. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-03359-9_30

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-03359-9_30

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-03358-2

  • Online ISBN: 978-3-642-03359-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics