Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Dijkstra monads for free

Published: 01 January 2017 Publication History

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

Cited By

View all
  • (2024)Type Inference LogicsProceedings of the ACM on Programming Languages10.1145/36897868:OOPSLA2(2125-2155)Online publication date: 8-Oct-2024
  • (2023)Omnisemantics: Smooth Handling of NondeterminismACM Transactions on Programming Languages and Systems10.1145/357983445:1(1-43)Online publication date: 24-Jan-2023
  • (2022)Formal reasoning about layered monadic interpretersProceedings of the ACM on Programming Languages10.1145/35476306:ICFP(254-282)Online publication date: 31-Aug-2022
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

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
Publication rights licensed to ACM. ACM acknowledges that this contribution was authored or co-authored by an employee, contractor or affiliate of a national government. As such, the Government retains a nonexclusive, royalty-free right to publish or reproduce this article, or to allow others to do so, for Government purposes only.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 January 2017
Published in SIGPLAN Volume 52, Issue 1

Check for updates

Author Tags

  1. dependent types
  2. effectful programming
  3. proof assistants
  4. verification

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)36
  • Downloads (Last 6 weeks)1
Reflects downloads up to 15 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Type Inference LogicsProceedings of the ACM on Programming Languages10.1145/36897868:OOPSLA2(2125-2155)Online publication date: 8-Oct-2024
  • (2023)Omnisemantics: Smooth Handling of NondeterminismACM Transactions on Programming Languages and Systems10.1145/357983445:1(1-43)Online publication date: 24-Jan-2023
  • (2022)Formal reasoning about layered monadic interpretersProceedings of the ACM on Programming Languages10.1145/35476306:ICFP(254-282)Online publication date: 31-Aug-2022
  • (2019)Formally Verified Cryptographic Web Applications in WebAssembly2019 IEEE Symposium on Security and Privacy (SP)10.1109/SP.2019.00064(1256-1274)Online publication date: May-2019
  • (2024)Automated Verification of Higher-Order Probabilistic Programs via a Dependent Refinement Type SystemProceedings of the ACM on Programming Languages10.1145/36746628:ICFP(973-1002)Online publication date: 15-Aug-2024
  • (2024)A HAT Trick: Automatically Verifying Representation Invariants using Symbolic Finite AutomataProceedings of the ACM on Programming Languages10.1145/36564338:PLDI(1387-1411)Online publication date: 20-Jun-2024
  • (2024)Securing Verified IO Programs Against Unverified Code in F*Proceedings of the ACM on Programming Languages10.1145/36329168:POPL(2226-2259)Online publication date: 5-Jan-2024
  • (2024)Verifying Programs with Logic and Extended Proof Rules: Deep Embedding vs. Shallow EmbeddingJournal of Automated Reasoning10.1007/s10817-024-09706-568:3Online publication date: 10-Aug-2024
  • (2023)Modularity, Code Specialization, and Zero-Cost Abstractions for Program VerificationProceedings of the ACM on Programming Languages10.1145/36078447:ICFP(385-416)Online publication date: 31-Aug-2023
  • (2023)Formalizing, Verifying and Applying ISA Security Guarantees as Universal ContractsProceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Security10.1145/3576915.3616602(2083-2097)Online publication date: 15-Nov-2023
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media