skip to main content
article

Theorem proving for all: equational reasoning in liquid Haskell (functional pearl)

Published:17 September 2018Publication History
Skip Abstract Section

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).

References

  1. Patrick Bahr and Graham Hutton. 2015. Calculating correct compilers. Journal of Functional Programming 25 (2015).Google ScholarGoogle Scholar
  2. Clark Barrett, Aaron Stump, and Cesare Tinelli. 2010. The SMT-LIB Standard: Version 2.0.Google ScholarGoogle Scholar
  3. Yves Bertot and Pierre Castéran. 2004. Interactive Theorem Proving and Program Development - Coq’Art: The Calculus of Inductive Constructions. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Richard S. Bird. 1987. An Introduction to the Theory of Lists. In NATO ASI. Springer, 5–42. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Richard S. Bird. 2010. Pearls of Functional Algorithm Design. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of Functional Programming 23, 5 (2013), 552–593.Google ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle Scholar
  9. Richard A. Eisenberg. 2016. Dependent Types in Haskell: Theory and Practice. Ph.D. Dissertation. UPenn. arXiv: 1610.07978Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. Timothy S. Freeman and Frank Pfenning. 1991. Refinement Types for ML. In PLDI. ACM, 268–277. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Florian Haftmann. 2010. From higher-order logic to Haskell: there and back again. In PEPM ’10. ACM, 155–158. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Graham Hutton. 2016. Programming in Haskell. Cambridge University Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. K. Rustan M. Leino. 2010. Dafny: An Automatic Program Verifier for Functional Correctness. In LPAR (LNCS), Vol. 6355. Springer, 348–370. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle Scholar
  16. K. Rustan M. Leino and Nadia Polikarpova. 2013. Verified Calculations. In VSTTE (LNCS), Vol. 8164. Springer, 170–190. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. James Mckinna and Joel Wright. 2006. Functional Pearl: A type-correct, stack-safe, provably correct expression compiler in Epigram. (2006).Google ScholarGoogle Scholar
  18. Tobias Nipkow. 2002. Structured Proofs in Isar/HOL. In Types for Proofs and Programs (TYPES) (LNCS), Vol. 2646. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Tobias Nipkow, Lawrence C. Paulson, and Markus Wenzel. 2002. Isabelle/HOL - A Proof Assistant for Higher-Order Logic. LNCS, Vol. 2283. Springer. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Ulf Norell. 2007. Towards a practical programming language based on dependent type theory. Ph.D. Dissertation. Chalmers.Google ScholarGoogle Scholar
  21. 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 ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. University of California, San Diego.Google ScholarGoogle Scholar
  26. 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
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Theorem proving for all: equational reasoning in liquid Haskell (functional pearl)

    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!