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.
Supplemental Material
- Alejandro Aguirre, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Pierre-Yves Strub. 2017. A Relational Logic for Higher-Order Programs. In ICFP. ACM.Google Scholar
- David Aspinall, Lennart Beringer, Martin Hofmann, Hans-Wolfgang Loidl, and Alberto Momigliano. 2007. A Program Logic for Resources. In Theoretical Computer Science. Elsevier.Google Scholar
- Robert Atkey. 2010. Amortised Resource Analysis with Separation Logic. In ESOP. Springer.Google Scholar
- Yves Bertot and Pierre Castéran. 2013. Interactive Theorem Proving and Program Development: Coq’Art: The Calculus of Inductive Constructions. Springer.Google Scholar
Digital Library
- Rod M Burstall and John Darlington. 1977. A Transformation System for Developing Recursive Programs. In JACM. ACM.Google Scholar
- Ezgi Çiçek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Jan Hoffmann. 2017. Relational Cost Analysis. In POPL. ACM.Google Scholar
- Ezgi Çiçek. 2018. Relational Cost Analysis. Ph.D. Dissertation. Saarland University, Saarbrücken, Germany.Google Scholar
- Ezgi Çiçek, Weihao Qu, Gilles Barthe, Marco Gaboardi, and Deepak Garg. 2019. Bidirectional Type Checking for Relational Properties. In PLDI. ACM.Google Scholar
- Karl Crary and Stephnie Weirich. 2000. Resource Bound Certification. In POPL. ACM.Google Scholar
- Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In POPL. ACM.Google Scholar
- Martin A.T. Handley and Niki Vazou. 2019. GitHub Repository for RTick library. https://github.com/mathandley/RTick .Google Scholar
- Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2011. Multivariate Amortized Resource Analysis. In POPL. ACM.Google Scholar
- Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012. Resource Aware ML. In CAV. Springer.Google Scholar
- Jan Hoffmann and Zhong Shao. 2015. Automatic Static Cost Analysis for Parallel Programs. In ESOP. Springer.Google Scholar
- Martin Hofmann and Steffen Jost. 2003. Static Prediction of Heap Space Usage for First-Order Functional Programs. In POPL. ACM.Google Scholar
- John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In POPL. ACM.Google Scholar
- Guoliang Jin, Linhai Song, Xiaoming Shi, Joel Scherpelz, and Shan Lu. 2012. Understanding and Detecting Real-World Performance Bugs. In PLDI. ACM.Google Scholar
- 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 Scholar
- 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 Scholar
- Ravichandhran Madhavan, Sumith Kulal, and Viktor Kuncak. 2017. Contract-Based Resource Verification for Higher-Order Functions with Memoization. In POPL. ACM.Google Scholar
- 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 Scholar
- Andrew Moran and David Sands. 1999. Improvement in a Lazy Context: An Operational Theory for Call-By-Need. In POPL. ACM.Google Scholar
- Ulf Norell. 2008. Dependently Typed Programming in Agda. In AFP. Springer.Google Scholar
Digital Library
- Chris Okasaki. 1999. Purely Functional Data Structures. Cambridge University Press.Google Scholar
Digital Library
- Ivan Radiček, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018. Monadic Refinements for Relational Cost Analysis. In POPL. ACM.Google Scholar
- David Sands. 1995. Total Correctness by Local Improvement in Program Transformation. In POPL. ACM.Google Scholar
- Pedro B Vasconcelos. 2008. Space Cost Analysis Using Sized Types. Ph.D. Dissertation. University of St. Andrews.Google Scholar
- Pedro B Vasconcelos and Kevin Hammond. 2003. Inferring Cost Equations for Recursive, Polymorphic and Higher-Order Functional Programs. In IFL. Springer.Google Scholar
- Niki Vazou. 2016. Liquid Haskell: Haskell as a Theorem Prover. Ph.D. Dissertation. UC San Diego.Google Scholar
- 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 Scholar
- Niki Vazou, Patrick M. Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In ESOP. Springer-Verlag.Google Scholar
- Niki Vazou, Eric L Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement Types for Haskell. In ICFP. ACM.Google Scholar
- 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 Scholar
- Peng Wang, Di Wang, and Adam Chlipala. 2017. TiML: A Functional Language for Practical Complexity Analysis with Invariants. OOPSLA.Google Scholar
- Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In POPL. ACM.Google Scholar
Index Terms
Liquidate your assets: reasoning about resource usage in liquid Haskell
Recommendations
Verifying replicated data types with typeclass refinements in Liquid Haskell
This paper presents an extension to Liquid Haskell that facilitates stating and semi-automatically proving properties of typeclasses. Liquid Haskell augments Haskell with refinement types—our work allows such types to be attached to typeclass method ...
Gradual liquid type inference
Refinement types allow for lightweight program verification by enriching types with logical predicates. Liquid typing provides a decidable refinement inference mechanism that is convenient but subject to two major issues: (1) inference is global and ...
Self-certification: bootstrapping certified typecheckers in F* with Coq
POPL '12Well-established dependently-typed languages like Agda and Coq provide reliable ways to build and check formal proofs. Several other dependently-typed languages such as Aura, ATS, Cayenne, Epigram, F*, F7, Fine, Guru, PCML5, and Ur also explore reliable ...






Comments