Abstract
Equational reasoning is one of the key features of pure functional languages such as Haskell. To date, however, such reasoning always took place externally to Haskell, either manually on paper, or mechanised in a theorem prover. This article shows how equational reasoning can be performed directly and seamlessly within Haskell itself, and be checked using Liquid Haskell. In particular, language learners --- to whom external theorem provers are out of reach --- can benefit from having their proofs mechanically checked. Concretely, we show how the equational proofs and derivations from Graham's textbook can be recast as proofs in Haskell (spoiler: they look essentially the same).
- Patrick Bahr and Graham Hutton. 2015. Calculating correct compilers. Journal of Functional Programming 25 (2015).Google Scholar
- Clark Barrett, Aaron Stump, and Cesare Tinelli. 2010. The SMT-LIB Standard: Version 2.0.Google Scholar
- Yves Bertot and Pierre Castéran. 2004. Interactive Theorem Proving and Program Development - Coq’Art: The Calculus of Inductive Constructions. Springer. Google Scholar
Digital Library
- Richard S. Bird. 1987. An Introduction to the Theory of Lists. In NATO ASI. Springer, 5–42. Google Scholar
Digital Library
- Richard S. Bird. 2010. Pearls of Functional Algorithm Design. Cambridge University Press. Google Scholar
Digital Library
- Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 (2013), 552–593.Google Scholar
Cross Ref
- Joachim Breitner. 2018. A promise checked is a promise kept: Inspection Testing. ArXiv e-prints (March 2018). arXiv: 1803.07130 submitted to Haskell’18. Google Scholar
Digital Library
- Leonardo Mendonça de Moura, Soonho Kong, Jeremy Avigad, Floris van Doorn, and Jakob von Raumer. 2015. The Lean Theorem Prover (System Description). In CADE-25 (LNCS), Vol. 9195. Springer, 378–388.Google Scholar
- Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. Ph.D. Dissertation. UPenn. arXiv: 1610.07978Google Scholar
- Andrew Farmer, Neil Sculthorpe, and Andy Gill. 2015. Reasoning with the HERMIT: tool support for equational reasoning on GHC core programs. In Haskell Symposium. ACM, 23–34. Google Scholar
Digital Library
- Timothy S. Freeman and Frank Pfenning. 1991. Refinement Types for ML. In PLDI. ACM, 268–277. Google Scholar
Digital Library
- Florian Haftmann. 2010. From higher-order logic to Haskell: there and back again. In PEPM ’10. ACM, 155–158. Google Scholar
Digital Library
- Graham Hutton. 2016. Programming in Haskell. Cambridge University Press. Google Scholar
Digital Library
- K. Rustan M. Leino. 2010. Dafny: An Automatic Program Verifier for Functional Correctness. In LPAR (LNCS), Vol. 6355. Springer, 348–370. Google Scholar
Digital Library
- K. Rustan M. Leino and Clément Pit-Claudel. 2016. Trigger Selection Strategies to Stabilize Program Verifiers. In CAV (LNCS), Vol. 9779. Springer, 361–381.Google Scholar
- K. Rustan M. Leino and Nadia Polikarpova. 2013. Verified Calculations. In VSTTE (LNCS), Vol. 8164. Springer, 170–190. Google Scholar
Digital Library
- James Mckinna and Joel Wright. 2006. Functional Pearl: A type-correct, stack-safe, provably correct expression compiler in Epigram. (2006).Google Scholar
- Tobias Nipkow. 2002. Structured Proofs in Isar/HOL. In Types for Proofs and Programs (TYPES) (LNCS), Vol. 2646. Springer. Google Scholar
Digital Library
- Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. 2002. Isabelle/HOL - A Proof Assistant for Higher-Order Logic. LNCS, Vol. 2283. Springer. Google Scholar
Digital Library
- Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Chalmers.Google Scholar
- Benjamin C. Pierce, Arthur Azevedo de Amorim, Chris Casinghino, Marco Gaboardi, Michael Greenberg, Cˇatˇalin Hriţcu, Vilhelm Sjöberg, and Brent Yorgey. 2018. Software Foundations Volume 1: Logical Foundations. Electronic textbook. Version 5.5. http://www.cis.upenn.edu/~bcpierce/sf .Google Scholar
- William Sonnex, Sophia Drossopoulou, and Susan Eisenbach. 2012. Zeno: An Automated Prover for Properties of Recursive Data Structures. In TACAS (LNCS), Vol. 7214. Springer, 407–421. Google Scholar
Digital Library
- Antal Spector-Zabusky, Joachim Breitner, Christine Rizkallah, and Stephanie Weirich. 2018. Total Haskell is reasonable Coq. In CPP. ACM, 14–27. Google Scholar
Digital Library
- Nikhil Swamy, Catalin Hritcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean Karim Zinzindohoue, and Santiago Zanella Béguelin. 2016. Dependent types and multi-monadic effects in F*. In POPL. ACM, 256–270. Google Scholar
Digital Library
- Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. University of California, San Diego.Google Scholar
- 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 L. Peyton Jones. 2014. Refinement types for Haskell. In ICFP. ACM, 269–282. Google Scholar
Digital Library
- 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, 53:1–53:31. Google Scholar
Digital Library
- Dimitrios Vytiniotis, Simon L. 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
Index Terms
Theorem proving for all: equational reasoning in liquid Haskell (functional pearl)
Recommendations
Theorem proving for all: equational reasoning in liquid Haskell (functional pearl)
Haskell 2018: Proceedings of the 11th ACM SIGPLAN International Symposium on HaskellEquational reasoning is one of the key features of pure functional languages such as Haskell. To date, however, such reasoning always took place externally to Haskell, either manually on paper, or mechanised in a theorem prover. This article shows how ...
A tale of two provers: verifying monoidal string matching in liquid Haskell and Coq
Haskell '17We demonstrate for the first time that Liquid Haskell, a refinement type checker for Haskell programs, can be used for arbitrary theorem proving by verifying a parallel, monoidal string matching algorithm implemented in Haskell. We use refinement types ...
Theorem proving using equational matings and rigid E-unification
In this paper, it is shown that the method of matings due to Andrews and Bibel can be extended to (first-order) languages with equality. A decidable version of E-unification called rigid E-unification is introduced, and it is shown that the method of ...







Comments