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

Liquidate your assets: reasoning about resource usage in liquid Haskell

Published:20 December 2019Publication History
Skip Abstract Section

Abstract

Liquid Haskell is an extension to the type system of Haskell that supports formal reasoning about program correctness by encoding logical properties as refinement types. In this article, we show how Liquid Haskell can also be used to reason about program efficiency in the same setting. We use the system's existing verification machinery to ensure that the results of our cost analysis are valid, together with custom invariants for particular program contexts to ensure that the results of our analysis are precise. To illustrate our approach, we analyse the efficiency of a wide range of popular data structures and algorithms, and in doing so, explore various notions of resource usage. Our experience is that reasoning about efficiency in Liquid Haskell is often just as simple as reasoning about correctness, and that the two can naturally be combined.

Skip Supplemental Material Section

Supplemental Material

a24-handley.webm

References

  1. Alejandro Aguirre, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Pierre-Yves Strub. 2017. A Relational Logic for Higher-Order Programs. In ICFP. ACM.Google ScholarGoogle Scholar
  2. David Aspinall, Lennart Beringer, Martin Hofmann, Hans-Wolfgang Loidl, and Alberto Momigliano. 2007. A Program Logic for Resources. In Theoretical Computer Science. Elsevier.Google ScholarGoogle Scholar
  3. Robert Atkey. 2010. Amortised Resource Analysis with Separation Logic. In ESOP. Springer.Google ScholarGoogle Scholar
  4. Yves Bertot and Pierre Castéran. 2013. Interactive Theorem Proving and Program Development: Coq’Art: The Calculus of Inductive Constructions. Springer.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Rod M Burstall and John Darlington. 1977. A Transformation System for Developing Recursive Programs. In JACM. ACM.Google ScholarGoogle Scholar
  6. Ezgi Çiçek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2017. Relational Cost Analysis. In POPL. ACM.Google ScholarGoogle Scholar
  7. Ezgi Çiçek. 2018. Relational Cost Analysis. Ph.D. Dissertation. Saarland University, Saarbrücken, Germany.Google ScholarGoogle Scholar
  8. Ezgi Çiçek, Weihao Qu, Gilles Barthe, Marco Gaboardi, and Deepak Garg. 2019. Bidirectional Type Checking for Relational Properties. In PLDI. ACM.Google ScholarGoogle Scholar
  9. Karl Crary and Stephnie Weirich. 2000. Resource Bound Certification. In POPL. ACM.Google ScholarGoogle Scholar
  10. Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In POPL. ACM.Google ScholarGoogle Scholar
  11. Martin A.T. Handley and Niki Vazou. 2019. GitHub Repository for RTick library. https://github.com/mathandley/RTick .Google ScholarGoogle Scholar
  12. Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2011. Multivariate Amortized Resource Analysis. In POPL. ACM.Google ScholarGoogle Scholar
  13. Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012. Resource Aware ML. In CAV. Springer.Google ScholarGoogle Scholar
  14. Jan Hoffmann and Zhong Shao. 2015. Automatic Static Cost Analysis for Parallel Programs. In ESOP. Springer.Google ScholarGoogle Scholar
  15. Martin Hofmann and Steffen Jost. 2003. Static Prediction of Heap Space Usage for First-Order Functional Programs. In POPL. ACM.Google ScholarGoogle Scholar
  16. John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In POPL. ACM.Google ScholarGoogle Scholar
  17. Guoliang Jin, Linhai Song, Xiaoming Shi, Joel Scherpelz, and Shan Lu. 2012. Understanding and Detecting Real-World Performance Bugs. In PLDI. ACM.Google ScholarGoogle Scholar
  18. Steffen Jost, Kevin Hammond, Hans-Wolfgang Loidl, and Martin Hofmann. 2010. Static Determination of Quantitative Resource Usage for Higher-Order Programs. In POPL. ACM.Google ScholarGoogle Scholar
  19. Steffen Jost, Pedro Vasconcelos, Mário Florido, and Kevin Hammond. 2017. Type-Based Cost Analysis for Lazy Functional Languages. In Journal of Automated Reasoning. Springer.Google ScholarGoogle Scholar
  20. Ravichandhran Madhavan, Sumith Kulal, and Viktor Kuncak. 2017. Contract-Based Resource Verification for Higher-Order Functions with Memoization. In POPL. ACM.Google ScholarGoogle Scholar
  21. Jay McCarthy, Burke Fetscher, Max S. New, Daniel Feltey, and Robert Findler. 2017. A Coq Library for Internal Verification of Running-Times. Science of Computer Programming.Google ScholarGoogle Scholar
  22. Andrew Moran and David Sands. 1999. Improvement in a Lazy Context: An Operational Theory for Call-By-Need. In POPL. ACM.Google ScholarGoogle Scholar
  23. Ulf Norell. 2008. Dependently Typed Programming in Agda. In AFP. Springer.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Chris Okasaki. 1999. Purely Functional Data Structures. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Ivan Radiček, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018. Monadic Refinements for Relational Cost Analysis. In POPL. ACM.Google ScholarGoogle Scholar
  26. David Sands. 1995. Total Correctness by Local Improvement in Program Transformation. In POPL. ACM.Google ScholarGoogle Scholar
  27. Pedro B Vasconcelos. 2008. Space Cost Analysis Using Sized Types. Ph.D. Dissertation. University of St. Andrews.Google ScholarGoogle Scholar
  28. Pedro B Vasconcelos and Kevin Hammond. 2003. Inferring Cost Equations for Recursive, Polymorphic and Higher-Order Functional Programs. In IFL. Springer.Google ScholarGoogle Scholar
  29. Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. UC San Diego.Google ScholarGoogle Scholar
  30. Niki Vazou, Joachim Breitner, Rose Kunkel, David Van Horn, and Graham Hutton. 2018. Theorem Proving For All: Equational Reasoning in Liquid Haskell. In Haskell Symposium.Google ScholarGoogle Scholar
  31. Niki Vazou, Patrick M. Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In ESOP. Springer-Verlag.Google ScholarGoogle Scholar
  32. Niki Vazou, Eric L Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement Types for Haskell. In ICFP. ACM.Google ScholarGoogle Scholar
  33. Niki Vazou, Anish Tondwalkar, Vikraman Choudhury, Ryan G Scott, Ryan R Newton, Philip Wadler, and Ranjit Jhala. 2017. Refinement Reflection: Complete Verification with SMT. POPL.Google ScholarGoogle Scholar
  34. Peng Wang, Di Wang, and Adam Chlipala. 2017. TiML: A Functional Language for Practical Complexity Analysis with Invariants. OOPSLA.Google ScholarGoogle Scholar
  35. Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In POPL. ACM.Google ScholarGoogle Scholar

Index Terms

  1. Liquidate your assets: reasoning about resource usage in liquid Haskell

      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!