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

Ready, set, verify! applying hs-to-coq to real-world Haskell code (experience report)

Published:30 July 2018Publication History
Skip Abstract Section

Abstract

Good tools can bring mechanical verification to programs written in mainstream functional languages. We use <pre>hs-to-coq</pre> to translate significant portions of Haskell’s <pre>containers</pre> library into Coq, and verify it against specifications that we derive from a variety of sources including type class laws, the library’s test suite, and interfaces from Coq’s standard library. Our work shows that it is feasible to verify mature, widely-used, highly optimized, and unmodified Haskell code. We also learn more about the theory of weight-balanced trees, extend <pre>hs-to-coq</pre> to handle partiality, and – since we found no bugs – attest to the superb quality of well-tested functional code.

Skip Supplemental Material Section

Supplemental Material

a89-breitner.webm

References

  1. Stephen Adams. 1992. Implementing sets efficiently in a functional language,. Research Report CSTR 92-10. University of Southampton.Google ScholarGoogle Scholar
  2. Andrew W. Appel, Lennart Beringer, Adam Chlipala, Benjamin C. Pierce, Zhong Shao, Stephanie Weirich, and Steve Zdancewic. 2017. Position paper: the science of deep specification. Philosophical Transactions of the Royal Society of London A: Mathematical, Physical and Engineering Sciences 375, 2104 (2017).Google ScholarGoogle Scholar
  3. Ana Bove, Peter Dybjer, and Ulf Norell. 2009. A Brief Overview of Agda - A Functional Language with Dependent Types. In Theorem Proving in Higher Order Logics, 22nd International Conference, TPHOLs 2009, Munich, Germany, August 17-20, 2009. Proceedings (Lecture Notes in Computer Science), Stefan Berghofer, Tobias Nipkow, Christian Urban, and Makarius Wenzel (Eds.), Vol. 5674. Springer, 73–78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Edwin Brady. 2017. Type-driven Development With Idris. Manning.Google ScholarGoogle Scholar
  5. Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley, and Stephanie Weirich. 2018. Ready, Set, Verify! Applying hs-to-coq to real-world Haskell code. CoRR abs/1803.06960 (2018). arXiv: 1803.06960 http: //arxiv.org/abs/1803.06960 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Arthur Charguéraud. 2010. The Optimal Fixed Point Combinator. In Proceedings of the First International Conference on Interactive Theorem Proving (ITP’10). Springer-Verlag, Berlin, Heidelberg, 195–210. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Koen Claessen and John Hughes. 2000. QuickCheck: a lightweight tool for random testing of Haskell programs. In ICFP. ACM, 268–279. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Nils Anders Danielsson, John Hughes, Patrik Jansson, and Jeremy Gibbons. 2006. Fast and loose reasoning is morally correct. In POPL. ACM, 206–217. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Yoichi Hirai and Kazuhiko Yamamoto. 2011. Balancing weight-balanced trees. Journal of Functional Programming 21, 3 (2011), 287–307. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Alexander Krauss. 2006. Partial Recursive Functions in Higher-Order Logic. In IJCAR (LNCS), Vol. 4130. Springer, 589–603. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Daniel Kröning, Philipp Rümmer, and Georg Weissenbacher. 2009. A proposal for a theory of finite sets, lists, and maps for the SMT-LIB standard. In Informal proceedings, 7th International Workshop on Satisfiability Modulo Theories at CADE, Vol. 22.Google ScholarGoogle Scholar
  12. The Coq development team. 2016. The Coq proof assistant reference manual. LogiCal Project. http://coq.inria.fr Version 8.6.1.Google ScholarGoogle Scholar
  13. Donald R. Morrison. 1968. PATRICIA&amp;Mdash;Practical Algorithm To Retrieve Information Coded in Alphanumeric. J. ACM 15, 4 (Oct. 1968), 514–534. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jürg Nievergelt and Edward M. Reingold. 1972. Binary Search Trees of Bounded Balance. In STOC. ACM, 137–142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Tobias Nipkow and Stefan Dirix. 2018. Weight-Balanced Trees. Archive of Formal Proofs (March 2018). http://isa-afp.org/ entries/Weight_Balanced_Trees.html , Formal proof development.Google ScholarGoogle Scholar
  16. Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. 2002. Isabelle/HOL - A Proof Assistant for Higher-Order Logic. Lecture Notes in Computer Science, Vol. 2283. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Chris Okasaki. 1999. Purely functional data structures. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Chris Okasaki and Andrew Gill. 1998. Fast Mergeable Integer Maps. In In Workshop on ML. 77–86.Google ScholarGoogle Scholar
  19. Simon Peyton Jones, Andrew Tolmach, and Tony Hoare. 2001. Playing by the rules: rewriting as a practical optimisation technique in GHC. In Haskell Workshop.Google ScholarGoogle Scholar
  20. Antal Spector-Zabusky, Joachim Breitner, Christine Rizkallah, and Stephanie Weirich. 2018. Total Haskell is reasonable Coq. In CPP. ACM, 14–27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Milan Straka. 2010. The Performance of the Haskell Containers Package. In Proceedings of the Third ACM Haskell Symposium on Haskell (Haskell ’10). ACM, New York, NY, USA, 13–24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Niki Vazou, Leonidas Lampropoulos, and Jeff Polakow. 2017. A Tale of Two Provers: Verifying Monoidal String Matching in Liquid Haskell and Coq. In Haskell Symposium. ACM, 63–74. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Niki Vazou, Patrick M. Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In Proceedings of the 22Nd European Conference on Programming Languages and Systems (ESOP’13). Springer-Verlag, Berlin, Heidelberg, 209–228. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement Types for Haskell. In ICFP. ACM, 269–282. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Niki Vazou, Anish Tondwalkar, Vikraman Choudhury, Ryan G. Scott, Ryan R. Newton, Philip Wadler, and Ranjit Jhala. 2018. Refinement reflection: complete verification with SMT. PACMPL 2, POPL (2018), 53:1–53:31. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Ready, set, verify! applying hs-to-coq to real-world Haskell code (experience report)

    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!