Abstract
This article presents liquid resource types, a technique for automatically verifying the resource consumption of functional programs. Existing resource analysis techniques trade automation for flexibility – automated techniques are restricted to relatively constrained families of resource bounds, while more expressive proof techniques admitting value-dependent bounds rely on handwritten proofs. Liquid resource types combine the best of these approaches, using logical refinements to automatically prove precise bounds on a program’s resource consumption. The type system augments refinement types with potential annotations to conduct an amortized resource analysis. Importantly, users can annotate data structure declarations to indicate how potential is allocated within the type, allowing the system to express bounds with polynomials and exponentials, as well as more precise expressions depending on program values. We prove the soundness of the type system, provide a library of flexible and reusable data structures for conducting resource analysis, and use our prototype implementation to automatically verify resource bounds that previously required a manual proof.
Supplemental Material
- E. Albert, P. Arenas, S. Genaim, and G. Puebla. 2011. Closed-Form Upper Bounds in Static Cost Analysis. J. Automated Reasoning 46 (February 2011 ). Issue 2.Google Scholar
- E. Albert, J. C. Fernández, and G. Román-Díez. 2015. Non-cumulative Resource Analysis. In Tools and Algs. for the Construct. and Anal. of Syst. (TACAS'15).Google Scholar
- Rajeev Alur, Rastislav Bodík, Garvit Juniwal, Milo M. K. Martin, Mukund Raghothaman, Sanjit A. Seshia, Rishabh Singh, Armando Solar-Lezama, Emina Torlak, and Abhishek Udupa. 2013. Syntax-guided synthesis. In Formal Methods in Computer-Aided Design, FMCAD 2013, Portland, OR, USA, October 20-23, 2013. 1-8. http://ieeexplore.ieee.org/document/ 6679385/Google Scholar
- Lex Augusteijn. 1999. Sorting Morphisms. In Advanced Functional Programming, S. Doaitse Swierstra, José N. Oliveira, and Pedro R. Henriques (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 1-27.Google Scholar
- M. Avanzini and G. Moser. 2013. A Combination Framework for Complexity. In Int. Conf. on Rewriting Techniques and Applications (RTA'13).Google Scholar
- M. Brockschmidt, F. Emmes, S. Falke, C. Fuhs, and J. Giesl. 2014. Alternating Runtime and Size Complexity Analysis of Integer Programs. In Tools and Algs. for the Construct. and Anal. of Syst. (TACAS'14).Google Scholar
- Aloïs Brunel, Marco Gaboardi, Damiano Mazza, and Steve Zdancewic. 2014. A Core Quantitative Coefect Calculus. In Proceedings of the 23rd European Symposium on Programming Languages and Systems-Volume 8410. Springer-Verlag, Berlin, Heidelberg, 351-370. https://doi.org/10.1007/978-3-642-54833-8_19 Google Scholar
Digital Library
- E. Çiçek, G. Barthe, M. Gaboardi, D. Garg, and J. Hofmann. 2017. Relational Cost Analysis. In Princ. of Prog. Lang. (POPL'17).Google Scholar
- Ezgi Çiçek, Weihao Qu, Gilles Barthe, Marco Gaboardi, and Deepak Garg. 2019. Bidirectional type checking for relational properties. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2019, Phoenix, AZ, USA, June 22-26, 2019, Kathryn S. McKinley and Kathleen Fisher (Eds.). ACM, 533-547. https: //doi.org/10.1145/3314221.3314603 Google Scholar
Digital Library
- Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In 35th ACM Symp. on Principles Prog. Langs. (POPL'08). 133-144.Google Scholar
- N. Danner, D. R. Licata, and R. Ramyaa. 2015. Denotational Cost Semantics for Functional Languages with Inductive Types. In Int. Conf. on Functional Programming (ICFP'15).Google Scholar
- Ewen Denney. 1999. A theory of program refinement. Ph.D. Dissertation. University of Edinburgh, UK. http://hdl.handle. net/ 1842 /381Google Scholar
- T. Freeman and F. Pfenning. 1991. Refinement Types for ML. In Prog. Lang. Design and Impl. (PLDI'91).Google Scholar
- Dan R. Ghica and Alex I. Smith. 2014. Bounded Linear Types in a Resource Semiring. In Proceedings of the 23rd European Symposium on Programming Languages and Systems-Volume 8410. Springer-Verlag, Berlin, Heidelberg, 331-350. https: //doi.org/10.1007/978-3-642-54833-8_18 Google Scholar
Digital Library
- Jean-Yves Girard, Andre Scedrov, and Philip J. Scott. 1992. Bounded Linear Logic: A Modular Approach to Polynomial-Time Computability. Theor. Comput. Sci. 97, 1 ( 1992 ), 1-66.Google Scholar
- Sumit Gulwani, Sagar Jain, and Eric Koskinen. 2009a. Control-Flow Refinement and Progress Invariants for Bound Analysis. In Conf. on Prog. Lang. Design and Impl. (PLDI'09). 375-385.Google Scholar
- S. Gulwani, K. K. Mehra, and T. M. Chilimbi. 2009b. SPEED: Precise and Eficient Static Estimation of Program Computational Complexity. In Princ. of Prog. Lang. (POPL'09).Google Scholar
- Martin A. T. Handley, Niki Vazou, and Graham Hutton. 2020. Liquidate your assets: reasoning about resource usage in liquid Haskell. PACMPL 4, POPL ( 2020 ), 24 : 1-24 : 27. https://doi.org/10.1145/3371092 Google Scholar
Digital Library
- R. Harper. 2016. Practical Foundations for Programming Languages. Cambridge University Press.Google Scholar
Digital Library
- Jan Hofmann, Klaus Aehlig, and Martin Hofmann. 2011a. Multivariate Amortized Resource Analysis. In 38th Symp. on Principles of Prog. Langs. (POPL'11). 357-370.Google Scholar
- J. Hofmann, K. Aehlig, and M. Hofmann. 2011b. Multivariate Amortized Resource Analysis. In Princ. of Prog. Lang. (POPL'11).Google Scholar
- J. Hofmann, A. Das, and S.-C. Weng. 2017. Towards Automatic Resource Bound Analysis for OCaml. In Princ. of Prog. Lang. (POPL'17).Google Scholar
- J. Hofmann and M. Hofmann. 2010a. Amortized Resource Analysis with Polynomial Potential. In European Symp. on Programming (ESOP'10).Google Scholar
- Jan Hofmann and Martin Hofmann. 2010b. Amortized Resource Analysis with Polynomial Potential-A Static Inference of Polynomial Bounds for Functional Programs. In In Proceedings of the 19th European Symposium on Programming (ESOP'10) (Lecture Notes in Computer Science), Vol. 6012. Springer, 287-306.Google Scholar
- M. Hofmann and S. Jost. 2003. Static Prediction of Heap Space Usage for First-Order Functional Programs. In Princ. of Prog. Lang. (POPL'03).Google Scholar
- M. Hofmann and G. Moser. 2015. Multivariate Amortised Resource Analysis for Term Rewrite Systems. In Int. Conf. on Typed Lambda Calculi and Applications (TLCA'15).Google Scholar
- S. Jost, K. Hammond, H.-W. Loidl, and M. Hofmann. 2010. Static Determination of Quantitative Resource Usage for Higher-Order Programs. In Princ. of Prog. Lang. (POPL'10).Google Scholar
- Z. Kincaid, J. Breck, A. F. Boroujeni, and T. Reps. 2017. Compositional Recurrence Analysis Revisited. In Prog. Lang. Design and Impl. (PLDI'17).Google Scholar
- Z. Kincaid, J. Cyphert, J. Breck, and T. Reps. 2019. Non-linear Reasoning for Invariant Synthesis. In Princ. of Prog. Lang. (POPL'19).Google Scholar
- Tristan Knoth, Di Wang, Nadia Polikarpova, and Jan Hofmann. 2019. Resource-Guided Program Synthesis. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2019 ). Association for Computing Machinery, New York, NY, USA, 253-268. https://doi.org/10.1145/3314221.3314602 Google Scholar
Digital Library
- Tristan Knoth, Di Wang, Adam Reynolds, Jan Hofmann, and Nadia Polikarpova. 2020. Liquid Resource Types (Extended Version). ( 2020 ). arXiv:cs.PL/ 2006.16233Google Scholar
- U. D. Lago and M. Gaboardi. 2011. Linear Dependent Types and Relative Completeness. In Logic in Computer Science (LICS'11).Google Scholar
- L. Noschinski, F. Emmes, and J. Giesl. 2013. Analyzing Innermost Runtime Complexity of Term Rewriting by Dependency Pairs. J. Automated Reasoning 51 ( June 2013 ). Issue 1.Google Scholar
- Dominic Orchard, Vilem-Benjamin Liepelt, and Harley Eades III. 2019. Quantitative Program Reasoning with Graded Modal Types. Proc. ACM Program. Lang. 3, ICFP, Article 110 ( July 2019 ), 30 pages. https://doi.org/10.1145/3341714 Google Scholar
Digital Library
- Nadia Polikarpova, Ivan Kuraj, and Armando Solar-Lezama. 2016. Program synthesis from polymorphic refinement types. In Programming Language Design and Implementation (PLDI). 522-538.Google Scholar
Digital Library
- Ivan Radicek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018a. Monadic refinements for relational cost analysis. PACMPL 2, POPL ( 2018 ), 36 : 1-36 : 32. https://doi.org/10.1145/3158124 Google Scholar
Digital Library
- Ivan Radicek, Gilles Barthe, Marco Gaboardi, Deepak Garg, and Florian Zuleger. 2018b. Monadic refinements for relational cost analysis. PACMPL 2, POPL ( 2018 ), 36 : 1-36 : 32. https://doi.org/10.1145/3158124 Google Scholar
Digital Library
- Andrew Reynolds, Viktor Kuncak, Cesare Tinelli, Clark W. Barrett, and Morgan Deters. 2019. Refutation-based synthesis in SMT. Formal Methods Syst. Des. 55, 2 ( 2019 ), 73-102.Google Scholar
- Patrick Maxim Rondon, Alexander Bakst, Ming Kawaguchi, and Ranjit Jhala. 2012. CSolve: Verifying C with Liquid Types. In Computer Aided Verification-24th International Conference, CAV 2012, Berkeley, CA, USA, July 7-13, 2012 Proceedings. 744-750. https://doi.org/10.1007/978-3-642-31424-7_59 Google Scholar
Digital Library
- Patrick Maxim Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In PLDI.Google Scholar
- A. Sabry and M. Felleisen. 1992. Reasoning about Programs in Continuation-Passing Style. In LISP and Functional Programming (LFP'92).Google Scholar
- Moritz Sinn, Florian Zuleger, and Helmut Veith. 2014. A Simple and Scalable Approach to Bound Analysis and Amortized Complexity Analysis. In Computer Aided Verification-26th Int. Conf. (CAV'14). 743-759.Google Scholar
Digital Library
- Armando Solar-Lezama, Liviu Tancau, Rastislav Bodík, Sanjit A. Seshia, and Vijay A. Saraswat. 2006. Combinatorial sketching for finite programs. In ASPLOS.Google Scholar
- Nikhil Swamy, Cătălin Hriundefinedcu, Chantal Keller, Aseem Rastogi, Antoine Delignat-Lavaud, Simon Forest, Karthikeyan Bhargavan, Cédric Fournet, Pierre-Yves Strub, Markulf Kohlweiss, Jean-Karim Zinzindohoue, and Santiago ZanellaBéguelin. 2016. Dependent Types and Multi-Monadic Efects in F*. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL '16). Association for Computing Machinery, New York, NY, USA, 256-270. https://doi.org/10.1145/2837614.2837655 Google Scholar
Digital Library
- R. E. Tarjan. 1985. Amortized Computational Complexity. SIAM J. Algebraic Discrete Methods 6 ( August 1985 ). Issue 2.Google Scholar
- Niki Vazou, Patrick Maxim Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In ESOP.Google Scholar
- D. Walker. 2002. Substructural Type Systems. In Advanced Topics in Types and Programming Languages. MIT Press.Google Scholar
- P. Wang, D. Wang, and A. Chlipala. 2017. TiML: A Functional Language for Practical Complexity Analysis with Invariants. In Object-Oriented Prog., Syst., Lang., and Applications (OOPSLA'17).Google Scholar
- Ben Wegbreit. 1975. Mechanical Program Analysis. Commun. ACM 18, 9 ( 1975 ), 528-539.Google Scholar
- F. Zuleger, M. Sinn, S. Gulwani, and H. Veith. 2011. Bound Analysis of Imperative Programs with the Size-change Abstraction. In Static Analysis Symp. (SAS'11).Google Scholar
Digital Library
Index Terms
Liquid resource types
Recommendations
Resource-guided program synthesis
PLDI 2019: Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and ImplementationThis article presents resource-guided synthesis, a technique for synthesizing recursive programs that satisfy both a functional specification and a symbolic resource bound. The technique is type-directed and rests upon a novel type system that combines ...
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 ...
Liquid types
PLDI '08We present Logically Qualified Data Types, abbreviated to Liquid Types, a system that combines Hindley-Milner type inference with Predicate Abstraction to automatically infer dependent types precise enough to prove a variety of safety properties. Liquid ...






Comments