skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Functional

Dijkstra monads for all

Published:26 July 2019Publication History
Skip Abstract Section

Abstract

This paper proposes a general semantic framework for verifying programs with arbitrary monadic side-effects using Dijkstra monads, which we define as monad-like structures indexed by a specification monad. We prove that any monad morphism between a computational monad and a specification monad gives rise to a Dijkstra monad, which provides great flexibility for obtaining Dijkstra monads tailored to the verification task at hand. We moreover show that a large variety of specification monads can be obtained by applying monad transformers to various base specification monads, including predicate transformers and Hoare-style pre- and postconditions. For defining correct monad transformers, we propose a language inspired by Moggi's monadic metalanguage that is parameterized by a dependent type theory. We also develop a notion of algebraic operations for Dijkstra monads, and start to investigate two ways of also accommodating effect handlers. We implement our framework in both Coq and F*, and illustrate that it supports a wide variety of verification styles for effects such as exceptions, nondeterminism, state, input-output, and general recursion.

Skip Supplemental Material Section

Supplemental Material

a104-maillard.webm

References

  1. J. Adámek, S. Milius, N. Bowler, and P. B. Levy. Coproducts of monads on set . LICS. 2012.Google ScholarGoogle Scholar
  2. D. Ahman. Handling fibred algebraic effects . PACMPL, 2(POPL):7:1–7:29, 2018. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. D. Ahman and T. Uustalu. Update monads: Cointerpreting directed containers . TYPES, 2013.Google ScholarGoogle Scholar
  4. D. Ahman, C. Hriţcu, K. Maillard, G. Martínez, G. Plotkin, J. Protzenko, A. Rastogi, and N. Swamy. Dijkstra monads for free . POPL. 2017. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. N. Benton, J. Hughes, and E. Moggi. Monads and effects . APPSEM . 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. N. Bowler, S. Goncharov, P. B. Levy, and L. Schröder. Exploring the boundaries of monad tensorability on set . Logical Methods in Computer Science, 9(3), 2013.Google ScholarGoogle Scholar
  7. P. Clairambault and P. Dybjer. The biequivalence of locally cartesian closed categories and Martin-Löf type theories . Mathematical Structures in Computer Science, 24(6), 2014.Google ScholarGoogle Scholar
  8. T. Coquand and C. Paulin. Inductively defined types . COLOG, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. G. A. Delbianco and A. Nanevski. Hoare-style reasoning with (algebraic) continuations . ICFP . 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. E. W. Dijkstra. Guarded commands, nondeterminacy and formal derivation of programs . CACM , 18(8):453–457, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Egger, R. E. Møgelberg, and A. Simpson. The enriched effect calculus: syntax and semantics . LogCom, 24(3):615–654, 2014.Google ScholarGoogle Scholar
  12. R. W. Floyd. Nondeterministic algorithms . J. ACM, 14(4):636–644, 1967. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. M. Giry. A categorical approach to probability theory . Categorical Aspects of Topology and Analysis. 1982.Google ScholarGoogle Scholar
  14. I. Hasuo. Generic weakest precondition semantics from monads enriched with order . Theor. Comput. Sci., 604:2–29, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. C. A. R. Hoare. An axiomatic basis for computer programming . Commun. ACM, 12(10):576–580, 1969. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Hyland, P. B. Levy, G. D. Plotkin, and J. Power. Combining algebraic effects with continuations . Theor. Comput. Sci., 375 (1-3):20–40, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. B. Jacobs. Comprehension categories and the semantics of type dependency . Theor. Comput. Sci., 107(2):169–207, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. B. Jacobs. Dijkstra monads in monadic computation . CMCS, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. B. Jacobs. Dijkstra and Hoare monads in monadic computation . Theor. Comput. Sci., 604:30–45, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Jaskelioff and E. Moggi. Monad transformers as monoid transformers . Theor. Comput. Sci., 411(51-52):4441–4466, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. A. Kaposi and A. Kovács. Signatures and induction principles for higher inductive-inductive types . arXiv:1902.00297, 2019.Google ScholarGoogle Scholar
  22. S. Katsumata. Relating computational effects by ⊤⊤-lifting . Inf. Comput., 222:228–246, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Katsumata. Parametric effect monads and semantics of effect systems . POPL. 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. K. R. M. Leino. Efficient weakest preconditions . Inf. Process. Lett., 93(6):281–288, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. K. R. M. Leino and J. L. A. van de Snepscheut. Semantics of exceptions . PROCOMET . 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. S. Liang, P. Hudak, and M. P. Jones. Monad transformers and modular interpreters . POPL. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. Lindley and I. Stark. Reducibility and ⊤⊤-lifting for computation types . TLCA. 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. C. Lüth and N. Ghani. Composing monads using coproducts . ICFP . 2002.Google ScholarGoogle Scholar
  29. G. Malecha, G. Morrisett, and R. Wisnesky. Trace-based verification of imperative programs with I/O . J. Symb. Comput., 46 (2):95–118, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. C. Matache and S. Staton. A sound and complete logic for algebraic effects . FoSSaCS. 2019.Google ScholarGoogle Scholar
  31. C. McBride. Turing-completeness totally free . MPC . 2015.Google ScholarGoogle Scholar
  32. E. Moggi. Computational lambda-calculus and monads . LICS. 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. E. Moggi. A semantics for evaluation logic . Fundam. Inform., 22(1/2):117–152, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. C. Morgan. Programming from Specifications (2nd Ed.). Prentice Hall, Hertfordshire, UK, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. G. Munch-Maccagnoni. Syntax and Models of a non-Associative Composition of Programs and Proofs. (Syntaxe et modèles d’une composition non-associative des programmes et des preuves) . PhD thesis, Paris Diderot University, France, 2013.Google ScholarGoogle Scholar
  36. A. Nanevski, G. Morrisett, A. Shinnar, P. Govereau, and L. Birkedal. Ynot: dependent types for imperative programs . ICFP . 2008a. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. A. Nanevski, J. G. Morrisett, and L. Birkedal. Hoare type theory, polymorphism and separation . JFP , 18(5-6):865–911, 2008b. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. A. Nanevski, A. Banerjee, and D. Garg. Dependent type theory for verification of information flow and access control policies . ACM TOPLAS, 35(2):6, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. S. S. Owicki and D. Gries. Verifying properties of parallel programs: An axiomatic approach . CACM , 19(5):279–285, 1976. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. A. M. Pitts. Evaluation logic . In IV Higher Order Workshop, Banff 1990. Springer, 1991.Google ScholarGoogle Scholar
  41. G. D. Plotkin and J. Power. Notions of computation determine monads . FOSSACS, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. G. D. Plotkin and J. Power. Algebraic operations and generic effects . Applied Categorical Structures, 11(1):69–94, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  43. G. D. Plotkin and M. Pretnar. A logic for algebraic effects . In LICS. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. G. D. Plotkin and M. Pretnar. Handling algebraic effects . Logical Methods in Computer Science, 9(4), 2013.Google ScholarGoogle Scholar
  45. J. Protzenko and B. Parno. EverCrypt cryptographic provider offers developers greater security assurances . Microsoft Research Blog, 2019.Google ScholarGoogle Scholar
  46. C. Rauch, S. Goncharov, and L. Schröder. Generic hoare logic for order-enriched effects with exceptions . WADT , 2016.Google ScholarGoogle Scholar
  47. E. Sekerinski. Exceptions for dependability . In Dependability and Computer Engineering: Concepts for Software-Intensive Systems, pages 11–35. IGI Global, 2012.Google ScholarGoogle Scholar
  48. A. Simpson and N. F. W. Voorneveld. Behavioural equivalence via modalities for algebraic effects . ESOP . 2018.Google ScholarGoogle Scholar
  49. 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
  50. N. Swamy, C. Hriţ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
  51. W. Swierstra and T. Baanen. A predicate transformer semantics for effects , 2019. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. N. Voorneveld. Quantitative logics for equivalence of effectful programs . MFPS. 2019. To appear.Google ScholarGoogle Scholar

Index Terms

  1. Dijkstra monads for all

            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

            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!