skip to main content
research-article

Dijkstra monads for free

Published:01 January 2017Publication History
Skip Abstract Section

Abstract

Dijkstra monads enable a dependent type theory to be enhanced with support for specifying and verifying effectful code via weakest preconditions. Together with their closely related counterparts, Hoare monads, they provide the basis on which verification tools like F*, Hoare Type Theory (HTT), and Ynot are built. We show that Dijkstra monads can be derived "for free" by applying a continuation-passing style (CPS) translation to the standard monadic definitions of the underlying computational effects. Automatically deriving Dijkstra monads in this way provides a correct-by-construction and efficient way of reasoning about user-defined effects in dependent type theories. We demonstrate these ideas in EMF*, a new dependently typed calculus, validating it via both formal proof and a prototype implementation within F*. Besides equipping F* with a more uniform and extensible effect system, EMF* enables a novel mixture of intrinsic and extrinsic proofs within F*.

References

  1. D. Ahman and T. Uustalu. Update monads: Cointerpreting directed containers. TYPES, 2013.Google ScholarGoogle Scholar
  2. D. Ahman, N. Ghani, and G. D. Plotkin. Dependent types and fibred computational effects. FOSSACS, 2016.Google ScholarGoogle ScholarCross RefCross Ref
  3. R. Atkey. Parameterised notions of computation. Journal of Functional Programming, 19:335–376, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. P. Audebaud and E. Zucca. Deriving proof rules from continuation semantics. Formal Asp. Comput., 11(4):426–447, 1999.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. G. Barthe and T. Uustalu. CPS translating inductive and coinductive types. PEPM. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. G. Barthe, C. Fournet, B. Grégoire, P.-Y. Strub, N. Swamy, and S. Zanella-Béguelin. Probabilistic relational verification for cryptographic implementations. POPL. 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. N. Benton. Simple relational correctness proofs for static analyses and program transformations. POPL. 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. N. Benton and A. Kennedy. Exceptional syntax. J. Funct. Program., 11(4): 395–410, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. N. Benton, J. Hughes, and E. Moggi. Monads and effects. APPSEM. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. E. Brady. Programming and reasoning with algebraic effects and dependent types. ICFP, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. E. Brady. Resource-dependent algebraic effects. TFP, 2014.Google ScholarGoogle Scholar
  12. C. Casinghino, V. Sjöberg, and S. Weirich. Combining proofs and programs in a dependently typed language. POPL, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. A. Charguéraud. Characteristic formulae for the verification of imperative programs. ICFP. 2011.Google ScholarGoogle Scholar
  14. A. Chlipala, G. Malecha, G. Morrisett, A. Shinnar, and R. Wisnesky. Effective interactive proofs for higher-order imperative programs. ICFP, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. T. Coquand and G. Huet. The calculus of constructions. Information and Computation, 76(2):95 – 120, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. L. M. de Moura and N. Bjørner. Z3: an efficient SMT solver. TACAS. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. E. W. Dijkstra. Guarded commands, nondeterminacy and formal derivation of programs. Commun. ACM, 18(8):453–457, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. E. W. Dijkstra. A Discipline of Programming. Prentice Hall PTR, Upper Saddle River, NJ, USA, 1st edition, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. A. Filinski. Representing monads. POPL. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. A. Filinski. Representing layered monads. POPL. 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A. Filinski. Monads in action. POPL. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J.-C. Filliˆatre and A. Paskevich. Why3 — where programs meet provers. ESOP. 2013.Google ScholarGoogle Scholar
  23. C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. PLDI, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. B. Jacobs. Dijkstra and Hoare monads in monadic computation. Theor. Comput. Sci., 604:30–45, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. K. Jensen. Connection between Dijkstra’s predicate-transformers and denotational continuation-semantics. DAIMI Report Series 7.86, 1978.Google ScholarGoogle Scholar
  26. K. Keimel. Healthiness conditions for predicate transformers. Electr. Notes Theor. Comput. Sci., 319:255–270, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. K. Keimel and G. Plotkin. Mixed powerdomains for probability and nondeterminism. submitted to LMCS, 2016.Google ScholarGoogle Scholar
  28. K. R. M. Leino. Dafny: An automatic program verifier for functional correctness. LPAR. 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. E. Moggi. Computational lambda-calculus and monads. LICS. 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. A. Nanevski, J. G. Morrisett, and L. Birkedal. Hoare type theory, polymorphism and separation. JFP, 18(5-6):865–911, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. Nogin. Quotient types: A modular approach. TPHOLs. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. C. Paulin-Mohring. Introduction to the Calculus of Inductive Constructions. In B. W. Paleo and D. Delahaye, editors, All about Proofs, Proofs for All, volume 55 of Studies in Logic (Mathematical logic and foundations). College Publications, 2015.Google ScholarGoogle Scholar
  33. G. D. Plotkin and M. Pretnar. Handlers of algebraic effects. ESOP. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. A. Sabelfeld and A. C. Myers. Language-based information-flow security. IEEE J.Sel. A. Commun., 21(1):5–19, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. D. Stefan, A. Russo, J. C. Mitchell, and D. Mazières. Flexible dynamic information flow control in haskell. SIGPLAN Not., 46(12):95–106, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. N. Swamy, N. Guts, D. Leijen, and M. Hicks. Lightweight monadic programming in ML. ICFP, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. N. Swamy, J. Weinberger, C. Schlesinger, J. Chen, and B. Livshits. Verifying higher-order programs with the Dijkstra monad. PLDI, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. N. Swamy, C. Hrit¸cu, C. Keller, A. Rastogi, A. Delignat-Lavaud, S. Forest, K. Bhargavan, C. Fournet, P.-Y. Strub, M. Kohlweiss, J.-K. Zinzindohoué, and S. Zanella-Béguelin. Dependent types and multi-monadic effects in F*. POPL. 2016. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. P. Wadler. Comprehending monads. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming. 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. P. Wadler. The essence of functional programming. POPL. 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. P. Wadler. Monads and composable continuations. Lisp Symb. Comput., 7 (1):39–56, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Dijkstra monads for free

          Recommendations

          Comments

          Login options

          Check if you have access through your login credentials or your institution to get full access on this article.

          Sign in

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 52, Issue 1
            POPL '17
            January 2017
            901 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/3093333
            Issue’s Table of Contents
            • cover image ACM Conferences
              POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages
              January 2017
              901 pages
              ISBN:9781450346603
              DOI:10.1145/3009837

            Copyright © 2017 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 1 January 2017

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!