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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
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)
Floyd, R.W.: Assigning meanings to programs. Mathematical Aspects of Computer Science 19 (1967)
Hoare, C.A.R.: An axiomatic basis for computer programming. Communications of the ACM 12(10), 576–580 (1969)
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)
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)
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)
McKinna, J.: Deliverables: a categorical approach to program development in type theory. Ph.D thesis, School of Informatics at the University of Edinburgh (1992)
Nanevski, A., Morrisett, G.: Dependent type theory of stateful higher-order functions. Technical Report TR-24-05, Harvard University (2005)
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)
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)
Peyton Jones, S. (ed.): Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press, Cambridge (2003)
Sozeau, M.: Subset coercions in Coq. In: Altenkirch, T., McBride, C. (eds.) TYPES 2006. LNCS, vol. 4502, pp. 237–252. Springer, Heidelberg (2007)
Sozeau, M.: Un environnement pour la programmation avec types dépendants. Ph.D thesis, Université de Paris XI (2008)
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)
The Coq development team. The Coq proof assistant reference manual. LogiCal Project, Version 8.2 (2008)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)