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.
Supplemental Material
Available for Download
Evaluated artifact for the paper Dijkstra Monads for All
- J. Adámek, S. Milius, N. Bowler, and P. B. Levy. Coproducts of monads on set . LICS. 2012.Google Scholar
- D. Ahman. Handling fibred algebraic effects . PACMPL, 2(POPL):7:1–7:29, 2018. Google Scholar
Digital Library
- D. Ahman and T. Uustalu. Update monads: Cointerpreting directed containers . TYPES, 2013.Google Scholar
- 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 Scholar
Digital Library
- N. Benton, J. Hughes, and E. Moggi. Monads and effects . APPSEM . 2000. Google Scholar
Digital Library
- 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 Scholar
- 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 Scholar
- T. Coquand and C. Paulin. Inductively defined types . COLOG, 1988. Google Scholar
Digital Library
- G. A. Delbianco and A. Nanevski. Hoare-style reasoning with (algebraic) continuations . ICFP . 2013. Google Scholar
Digital Library
- E. W. Dijkstra. Guarded commands, nondeterminacy and formal derivation of programs . CACM , 18(8):453–457, 1975. Google Scholar
Digital Library
- J. Egger, R. E. Møgelberg, and A. Simpson. The enriched effect calculus: syntax and semantics . LogCom, 24(3):615–654, 2014.Google Scholar
- R. W. Floyd. Nondeterministic algorithms . J. ACM, 14(4):636–644, 1967. Google Scholar
Digital Library
- M. Giry. A categorical approach to probability theory . Categorical Aspects of Topology and Analysis. 1982.Google Scholar
- I. Hasuo. Generic weakest precondition semantics from monads enriched with order . Theor. Comput. Sci., 604:2–29, 2015. Google Scholar
Digital Library
- C. A. R. Hoare. An axiomatic basis for computer programming . Commun. ACM, 12(10):576–580, 1969. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- B. Jacobs. Comprehension categories and the semantics of type dependency . Theor. Comput. Sci., 107(2):169–207, 1993. Google Scholar
Digital Library
- B. Jacobs. Dijkstra monads in monadic computation . CMCS, 2014. Google Scholar
Digital Library
- B. Jacobs. Dijkstra and Hoare monads in monadic computation . Theor. Comput. Sci., 604:30–45, 2015. Google Scholar
Digital Library
- M. Jaskelioff and E. Moggi. Monad transformers as monoid transformers . Theor. Comput. Sci., 411(51-52):4441–4466, 2010. Google Scholar
Digital Library
- A. Kaposi and A. Kovács. Signatures and induction principles for higher inductive-inductive types . arXiv:1902.00297, 2019.Google Scholar
- S. Katsumata. Relating computational effects by ⊤⊤-lifting . Inf. Comput., 222:228–246, 2013. Google Scholar
Digital Library
- S. Katsumata. Parametric effect monads and semantics of effect systems . POPL. 2014. Google Scholar
Digital Library
- K. R. M. Leino. Efficient weakest preconditions . Inf. Process. Lett., 93(6):281–288, 2005. Google Scholar
Digital Library
- K. R. M. Leino and J. L. A. van de Snepscheut. Semantics of exceptions . PROCOMET . 1994. Google Scholar
Digital Library
- S. Liang, P. Hudak, and M. P. Jones. Monad transformers and modular interpreters . POPL. 1995. Google Scholar
Digital Library
- S. Lindley and I. Stark. Reducibility and ⊤⊤-lifting for computation types . TLCA. 2005. Google Scholar
Digital Library
- C. Lüth and N. Ghani. Composing monads using coproducts . ICFP . 2002.Google Scholar
- 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 Scholar
Digital Library
- C. Matache and S. Staton. A sound and complete logic for algebraic effects . FoSSaCS. 2019.Google Scholar
- C. McBride. Turing-completeness totally free . MPC . 2015.Google Scholar
- E. Moggi. Computational lambda-calculus and monads . LICS. 1989. Google Scholar
Digital Library
- E. Moggi. A semantics for evaluation logic . Fundam. Inform., 22(1/2):117–152, 1995. Google Scholar
Digital Library
- C. Morgan. Programming from Specifications (2nd Ed.). Prentice Hall, Hertfordshire, UK, 1994. Google Scholar
Digital Library
- 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 Scholar
- A. Nanevski, G. Morrisett, A. Shinnar, P. Govereau, and L. Birkedal. Ynot: dependent types for imperative programs . ICFP . 2008a. Google Scholar
Digital Library
- A. Nanevski, J. G. Morrisett, and L. Birkedal. Hoare type theory, polymorphism and separation . JFP , 18(5-6):865–911, 2008b. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- S. S. Owicki and D. Gries. Verifying properties of parallel programs: An axiomatic approach . CACM , 19(5):279–285, 1976. Google Scholar
Digital Library
- A. M. Pitts. Evaluation logic . In IV Higher Order Workshop, Banff 1990. Springer, 1991.Google Scholar
- G. D. Plotkin and J. Power. Notions of computation determine monads . FOSSACS, 2002. Google Scholar
Digital Library
- G. D. Plotkin and J. Power. Algebraic operations and generic effects . Applied Categorical Structures, 11(1):69–94, 2003.Google Scholar
Cross Ref
- G. D. Plotkin and M. Pretnar. A logic for algebraic effects . In LICS. 2008. Google Scholar
Digital Library
- G. D. Plotkin and M. Pretnar. Handling algebraic effects . Logical Methods in Computer Science, 9(4), 2013.Google Scholar
- J. Protzenko and B. Parno. EverCrypt cryptographic provider offers developers greater security assurances . Microsoft Research Blog, 2019.Google Scholar
- C. Rauch, S. Goncharov, and L. Schröder. Generic hoare logic for order-enriched effects with exceptions . WADT , 2016.Google Scholar
- E. Sekerinski. Exceptions for dependability . In Dependability and Computer Engineering: Concepts for Software-Intensive Systems, pages 11–35. IGI Global, 2012.Google Scholar
- A. Simpson and N. F. W. Voorneveld. Behavioural equivalence via modalities for algebraic effects . ESOP . 2018.Google Scholar
- N. Swamy, J. Weinberger, C. Schlesinger, J. Chen, and B. Livshits. Verifying higher-order programs with the Dijkstra monad . PLDI , 2013. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- W. Swierstra and T. Baanen. A predicate transformer semantics for effects , 2019. Google Scholar
Digital Library
- N. Voorneveld. Quantitative logics for equivalence of effectful programs . MFPS. 2019. To appear.Google Scholar
Index Terms
Dijkstra monads for all
Recommendations
The next 700 relational program logics
We propose the first framework for defining relational program logics for arbitrary monadic effects. The framework is embedded within a relational dependent type theory and is highly expressive. At the semantic level, we provide an algebraic ...
Coproducts of Monads on Set
LICS '12: Proceedings of the 2012 27th Annual IEEE/ACM Symposium on Logic in Computer ScienceCoproducts of monads on $\Set$ have arisen in both the study of computational effects and universal algebra. We describe coproducts of consistent monads on $\Set$ by an initial algebra formula, and prove also the converse: if the coproduct exists, so do ...
Idioms are Oblivious, Arrows are Meticulous, Monads are Promiscuous
We revisit the connection between three notions of computation: Moggi s monads, Hughes s arrows and McBride and Paterson s idioms (also called applicative functors). We show that idioms are equivalent to arrows that satisfy the type isomorphism A B 1 (A ...






Comments