Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3331554.3342605acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Deferring the details and deriving programs

Published: 18 August 2019 Publication History

Abstract

A commonly-used technique in dependently-typed programming is to encode invariants about a data structure into its type, thus ensuring that the data structure is correct by construction. Unfortunately, this often necessitates the embedding of explicit proof terms within the data structure, which are not part of the structure conceptually, but merely supplied to ensure that the data invariants are maintained. As the complexity of the specifications in the types increases, these additional terms tend to clutter definitions, reducing readability. We introduce a technique where these proof terms can be supplied later, by constructing the data structure within a proof delay applicative functor. We apply this technique to Trip, our new language for Hoare-logic verification of imperative programs embedded in Agda, where our applicative functor is used as the basis for a verification condition generator, turning the typed holes of Agda into a method for stepwise derivation of a program from its specification in the form of a Hoare triple.

Supplementary Material

MP4 File (3331554.3342605.mp4)
Video Presentation

References

[1]
Guillaume Allais. 2015. Presburger Arithmetic Solver for Agda. https: //github.com/gallais/agda-presburger .
[2]
Adam Chlipala. 2013. The Bedrock Structured Programming System: Combining Generative Metaprogramming and Hoare Logic in an Extensible Program Verifier. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP ’13). ACM, 391–402.
[3]
David Christiansen and Edwin Brady. 2016. Elaborator Reflection: Extending Idris in Idris. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016). ACM, 284–297.
[4]
Pierre-Evariste Dagand. 2017. The essence of ornaments. Journal of Functional Programming 27 (2017).
[5]
Pierre-Evariste Dagand and Conor McBride. 2012. Transporting Functions Across Ornaments. In Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming (ICFP ’12). ACM, 103–114.
[6]
M. Dahlweid, M. Moskal, T. Santen, S. Tobies, and W. Schulte. 2009. VCC: Contract-based modular verification of concurrent C. In Proceedings of the 31st International Conference on Software Engineering (ICSE ’09). 429–430.
[7]
Justin Dawson, Mark Grebe, and Andy Gill. 2017. Composable Network Stacks and Remote Monads. In Proceedings of the 10th ACM SIGPLAN International Symposium on Haskell (Haskell 2017). ACM, 86–97.
[8]
W.P de Roever. 1979. Recursive program schemes: semantics and proof theory. Mathematical Centre tracts, no. 70. Journal of Symbolic Logic 44, 4 (1979), 658–659.
[9]
Dominique Devriese and Frank Piessens. 2011. On the Bright Side of Type Classes: Instance Arguments in Agda. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). ACM, 143–155.
[10]
Edsger W. Dijkstra. 1976. A Discipline of Programming. Prentice Hall PTR, Upper Saddle River, NJ, USA.
[11]
Gabriel Ebner, Sebastian Ullrich, Jared Roesch, Jeremy Avigad, and Leonardo de Moura. 2017. A Metaprogramming Framework for Formal Verification. Proceedings of the ACM on Programming Languages 1, ICFP, Article 34 (Aug. 2017), 29 pages.
[12]
Jean-Christophe Filliâtre and Andrei Paskevich. 2013. Why3 — Where Programs Meet Provers. In Proceedings of the 22nd European Symposium on Programming (Lecture Notes in Computer Science), Matthias Felleisen and Philippa Gardner (Eds.), Vol. 7792. Springer, 125–128.
[13]
Michael J. Fischer and Richard E. Ladner. 1977. Propositional Modal Logic of Programs. In Proceedings of the Ninth Annual ACM Symposium on Theory of Computing (STOC ’77). ACM, 286–294.
[14]
Robert W. Floyd. 1967. Assigning Meanings to Programs. In Proceedings of a Symposium on Applied Mathematics (Mathematical Aspects of Computer Science), J. T. Schwartz (Ed.), Vol. 19. American Mathematical Society, Providence, 19–31.
[15]
David Greenaway, June Andronick, and Gerwin Klein. 2012. Bridging the Gap: Automatic Verified Abstraction of C. In International Conference on Interactive Theorem Proving, Lennart Beringer and Amy Felty (Ed.). Springer, Princeton, New Jersey, USA, 99–115.
[16]
David Greenaway, Japheth Lim, June Andronick, and Gerwin Klein. 2014. Don’t Sweat the Small Stuff: Formal Verification of C Code Without the Pain. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’14). ACM, 429–439.
[17]
David Harel and Vaughan R. Pratt. 1978. Nondeterminism in Logics of Programs. In Proceedings of the 5th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’78). ACM, New York, NY, USA, 203–213.
[18]
C. A. R. Hoare. 1969. An Axiomatic Basis for Computer Programming. Commun. ACM 12, 10 (Oct. 1969), 576–580.
[19]
INRIA. 2009. The Coq Proof Assistant Reference Manual.
[20]
Wojciech Jedynak. 2015. Ring Solver for Agda. https://github.com/ wjzz/Agda-reflection-for-semiring-solver .
[21]
Oleg Kiselyov, Ralf Lämmel, and Keean Schupke. 2004. Strongly Typed Heterogeneous Collections. In Proceedings of the 2004 ACM SIGPLAN Workshop on Haskell (Haskell ’04). ACM, 96–107.
[22]
Gerwin Klein, Kevin Elphinstone, Gernot Heiser, June Andronick, David Cock, Philip Derrin, Dhammika Elkaduwe, Kai Engelhardt, Rafal Kolanski, Michael Norrish, Thomas Sewell, Harvey Tuch, and Simon Winwood. 2009. seL4: Formal Verification of an OS Kernel. In Proceedings of the ACM SIGOPS 22Nd Symposium on Operating Systems Principles (SOSP ’09). ACM, 207–220.
[23]
Hsiang-Shang Ko and Jeremy Gibbons. 2016. Programming with ornaments. Journal of Functional Programming 27 (2016).
[24]
Pepijn Kokke and Wouter Swierstra. 2015. Auto in Agda. In Mathematics of Program Construction, Ralf Hinze and Janis Voigtländer (Eds.). Springer International Publishing, Cham, 276–301.
[25]
K. Rustan M. Leino. 2010. Dafny: An Automatic Program Verifier for Functional Correctness. In Logic for Programming, Artificial Intelligence, and Reasoning, Edmund M. Clarke and Andrei Voronkov (Eds.). Springer Berlin Heidelberg, 348–370.
[26]
Fredrik Lindblad and Marcin Benke. 2006. A Tool for Automated Theorem Proving in Agda. In Proceedings of the 2004 International Conference on Types for Proofs and Programs (TYPES’04). SpringerVerlag, 154–169.
[27]
Sam Lindley and Conor McBride. 2013. Hasochism: The Pleasure and Pain of Dependently Typed Haskell Programming. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell (Haskell ’13). ACM, 81–92.
[28]
Simon Marlow, Louis Brandy, Jonathan Coens, and Jon Purdy. 2014. There is No Fork: An Abstraction for Efficient, Concurrent, and Concise Data Access. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). ACM, 325–337.
[29]
Simon Marlow, Simon Peyton Jones, Edward Kmett, and Andrey Mokhov. 2016. Desugaring Haskell’s Do-notation into Applicative Operations. In Proceedings of the 9th International Symposium on Haskell (Haskell 2016). ACM, 92–104.
[30]
Conor McBride. 2010. Ornamental Algebras, Algebraic Ornaments. (2010). http://personal.cis.strath.ac.uk/~conor/pub/OAAO/Ornament. pdf Manuscript available online.
[31]
Conor McBride. 2014. How to Keep Your Neighbours in Order. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). ACM, 297–309.
[32]
Conor McBride and Ross Paterson. 2008. Applicative Programming with Effects. Journal of Functional Programming 18, 1 (Jan. 2008), 1–13.
[33]
Carroll Morgan. 1994. Programming from Specifications (2nd Ed.). Prentice Hall International Ltd.
[34]
Tobias Nipkow, Lawrence Paulson, and Markus Wenzel. 2002. Isabelle/HOL — A Proof Assistant for Higher-Order Logic. Vol. 2283.
[35]
Liam O’Connor. 2016. Applications of Applicative Proof Search. In Proceedings of the 1st International Workshop on Type-Driven Development (TyDe 2016). ACM, 43–55.
[36]
Susan Owicki and David Gries. 1976. An axiomatic proof technique for parallel programs. Acta Informatica 6, 4 (01 Dec 1976), 319–340.
[37]
Sam Owre, John Rushby, and Natarajan Shankar. 1992. PVS: A prototype verification system. In Proceedings of the 11th International Conference on Automated Deduction (CADE ’11), Deepak Kapur (Ed.). Springer Berlin Heidelberg, 748–752.
[38]
David J. Pearce and Lindsay Groves. 2013. Whiley: A Platform for Research in Software Verification. In Software Language Engineering, Martin Erwig, Richard F. Paige, and Eric Van Wyk (Eds.). Springer International Publishing, Cham, 238–248.
[39]
Vaughan R. Pratt. 1976. Semantical consideration on Floyd-Hoare logic. In 17th Annual Symposium on Foundations of Computer Science (SFCS ’76). 109–121.
[40]
John Rushby, Sam Owre, and Natarajan Shankar. 1998. Subtypes for specifications: predicate subtyping in PVS. IEEE Transactions on Software Engineering 24, 9 (Sep. 1998), 709–720.
[41]
Norbert Schirmer. 2005. A Verification Environment for Sequential Imperative Programs in Isabelle/HOL. In Logic for Programming, Artificial Intelligence, and Reasoning, Franz Baader and Andrei Voronkov (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 398–414.
[42]
Matthieu Sozeau. 2007. Subset Coercions in Coq. In Proceedings of the 2006 International Conference on Types for Proofs and Programs (TYPES’06). Springer-Verlag, 237–252.
[43]
Wouter Swierstra. 2009. A Hoare Logic for the State Monad. In Proceedings of the 22nd International Conference on Theorem Proving in Higher Order Logics (TPHOLs ’09). Springer-Verlag, 440–451.
[44]
Harvey Tuch, Gerwin Klein, and Michael Norrish. 2007. Types, Bytes, and Separation Logic. In Proceedings of the 34th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’07). ACM, 97–108.
[45]
Thomas Williams and Didier Rémy. 2017. A Principled Approach to Ornamentation in ML. Proceedings of the ACM on Programming Languages 2, POPL, Article 21 (Dec. 2017), 30 pages.
[46]
Simon Winwood, Gerwin Klein, Thomas Sewell, June Andronick, David Cock, and Michael Norrish. 2009. Mind the Gap: A Verification Framework for Low-Level C. In International Conference on Theorem Proving in Higher Order Logics, S. Berghofer, T. Nipkow, C. Urban, M. Wenzel (Ed.). Springer, Munich, Germany, 500–515.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
TyDe 2019: Proceedings of the 4th ACM SIGPLAN International Workshop on Type-Driven Development
August 2019
76 pages
ISBN:9781450368155
DOI:10.1145/3331554
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 18 August 2019

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. agda
  2. applicative functor
  3. hoare logic
  4. imperative programming
  5. types
  6. verification conditions

Qualifiers

  • Research-article

Conference

ICFP '19
Sponsor:

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 202
    Total Downloads
  • Downloads (Last 12 months)9
  • Downloads (Last 6 weeks)0
Reflects downloads up to 10 Nov 2024

Other Metrics

Citations

Cited By

View all

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