ABSTRACT
We would like to use the Coq proof assistant to mechanically verify properties of Haskell programs. To that end, we present a tool, named <tt>hs-to-coq</tt>, that translates total Haskell programs into Coq programs via a shallow embedding. We apply our tool in three case studies – a lawful <tt>Monad</tt> instance, “Hutton’s razor”, and an existing data structure library – and prove their correctness. These examples show that this approach is viable: both that <tt>hs-to-coq</tt> applies to existing Haskell code, and that the output it produces is amenable to verification.
References
- Andreas Abel, Marcin Benke, Ana Bove, John Hughes, and Ulf Norell. 2005. Verifying Haskell Programs Using Constructive Type Theory. In Haskell Workshop. ACM, 62-73. Google Scholar
Digital Library
- Gilles Barthe, Julien Forest, David Pichardie, and Vlad Rusu. 2006. Defining and Reasoning About Recursive Functions: A Practical Tool for the Coq Proof Assistant. In FLOPS (LNCS), Vol. 3945. Springer, 114-129. Google Scholar
Digital Library
- Joachim Breitner. 2017. successors: An applicative functor to manage successors. https://hackage.haskell.org/package/successors-0.1. (1 February 2017).Google Scholar
- Joachim Breitner, Brian Huffman, Neil Mitchell, and Christian Sternagel. 2013. Certified HLints with Isabelle/HOLCF-Prelude. In Haskell and Rewriting Techniques (HART). arXiv:1306.1340.Google Scholar
- Arthur Charguéraud. 2010. Program verification through characteristic formulae. In ICFP. ACM, 321-332. Google Scholar
Digital Library
- Haogang Chen, Daniel Ziegler, Tej Chajed, Adam Chlipala, M. Frans Kaashoek, and Nickolai Zeldovich. 2015. Using Crash Hoare Logic for Certifying the FSCQ File System. In SOSP. ACM, 18-37. Google Scholar
Digital Library
- Haskell Core Libraries Comittee. 2017. base: Basic libraries. https://hackage.haskell.org/package/base-4.9.1.0. (14 January 2017).Google Scholar
- Nils Anders Danielsson, John Hughes, Patrik Jansson, and Jeremy Gibbons. 2006. Fast and loose reasoning is morally correct. In POPL. ACM, 206-217. Google Scholar
Digital Library
- Leonardo Mendonça de Moura and Nikolaj Bjørner. 2008. Z3: An Efficient SMT Solver. In TACAS (LNCS), Vol. 4963. Springer, 337-340.Google Scholar
Digital Library
- Philip Derrin, Kevin Elphinstone, Gerwin Klein, David Cock, and Manuel M. T. Chakravarty. 2006. Running the Manual: An Approach to High-assurance Microkernel Development. In Haskell Symposium. ACM, 60-71. Google Scholar
Digital Library
- Peter Dybjer, Qiao Haiyan, and Makoto Takeyama. 2004. Verifying Haskell programs by combining testing, model checking and interactive theorem proving. Information & Software Technology 46, 15 (2004), 1011-1025.Google Scholar
Cross Ref
- Georges Gonthier, Assia Mahboubi, and Enrico Tassi. 2016. A Small Scale Reflection Extension for the Coq system. Research Report RR-6455. Inria Saclay Ile de France. https://hal.inria.fr/inria-00258384.Google Scholar
- Florian Haftmann. 2010. From higher-order logic to Haskell: there and back again. In '10. ACM, 155-158. Google Scholar
Digital Library
- Thomas Hallgren, James Hook, Mark P. Jones, and Richard B. Kieburtz. 2004. An overview of the programatica toolset. In HCSS.Google Scholar
- Brian Huffman. 2012. HOLCF '11: A Definitional Domain Theory for Verifying Functional Programs. Ph.D. Dissertation. Portland State University. Google Scholar
Digital Library
- Graham Hutton. 2016. Programming in Haskell (2nd ed.). Cambridge University Press. 241-246 pages.Google Scholar
- Adam Megacz Joseph. 2014. Generalized Arrows. (May 2014). http://www2.eecs.berkeley.edu/Pubs/TechRpts/2014/EECS-2014-130.html also see http://www.megacz.com/berkeley/coq-in-ghc/.Google Scholar
- Pierre Letouzey. 2002. A New Extraction for Coq. In TYPES (LNCS), Vol. 2646. Springer, 200-219. Google Scholar
Digital Library
- Cyprien Mangin and Matthieu Sozeau. 2017. Equations Reloaded. (2017). http://www.irif.fr/~sozeau/research/publications/drafts/Equations_Reloaded.pdf (submitted).Google Scholar
- Simon Marlow (Ed.). 2010. Haskell 2010 Language Report.Google Scholar
- Simon Marlow and Simon Peyton Jones. 2012. The Glasgow Haskell Compiler. In The Architecture of Open Source Applications, Volume 2. Lulu. http://www.aosabook.org/en/ghc.html.Google Scholar
- The Coq development team. 2016. The Coq proof assistant reference manual. LogiCal Project. http://coq.inria.fr Version 8.6.1.Google Scholar
- Olaf Müller, Tobias Nipkow, David von Oheimb, and Oskar Slotosch. 1999. HOLCF = HOL + LCF. Journal of Functional Programming 9 (1999), 191-223. Google Scholar
Digital Library
- Chris Okasaki. 1999. Purely functional data structures. Cambridge University Press. Google Scholar
Digital Library
- Will Partain. 1996. GHC commit 6c381e873e. http://git.haskell.org/ghc.git/commit/6c381e873e. (19 March 1996).Google Scholar
- Lawrence C. Paulson. 1987. Logic and Computation: Interactive Proof with Cambridge LCF. Cambridge University Press. Google Scholar
Digital Library
- Matthew Pickering, Gergo Érdi, Simon Peyton Jones, and Richard A. Eisenberg. 2016. Pattern synonyms. In Haskell. ACM, 80-91. Google Scholar
Digital Library
- Alexandre Riazanov and Andrei Voronkov. 1999. Vampire. In CADE-16 (LNCS), Vol. 1632. Springer, 292-296. Google Scholar
Digital Library
- Matthieu Sozeau and Nicolas Oury. 2008. First-Class Type Classes. In TPHOLs (LNCS), Vol. 5170. Springer, 278-293. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement Types for Haskell. In ICFP. ACM, 269-282. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon Peyton Jones, Koen Claessen, and Dan Rosén. 2013. HALO: Haskell to Logic Through Denotational Semantics. In POPL. ACM, 431-442. Google Scholar
Digital Library
- Philip Wadler and Stephen Blott. 1989. How to Make ad-hoc Polymorphism Less ad-hoc. In POPL. ACM, 60-76. Google Scholar
Digital Library
- John Wiegley. 2017. coq-haskell: A library for formalizing Haskell types and functions in Coq. https://github.com/jwiegley/coq-haskell. (2017).Google Scholar
Index Terms
Total Haskell is reasonable Coq





Comments