skip to main content

Liquid resource types

Published:03 August 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Presentation at ICFP '20

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle Scholar
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle Scholar
  5. M. Avanzini and G. Moser. 2013. A Combination Framework for Complexity. In Int. Conf. on Rewriting Techniques and Applications (RTA'13).Google ScholarGoogle Scholar
  6. 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 ScholarGoogle Scholar
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. E. Çiçek, G. Barthe, M. Gaboardi, D. Garg, and J. Hofmann. 2017. Relational Cost Analysis. In Princ. of Prog. Lang. (POPL'17).Google ScholarGoogle Scholar
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle Scholar
  12. Ewen Denney. 1999. A theory of program refinement. Ph.D. Dissertation. University of Edinburgh, UK. http://hdl.handle. net/ 1842 /381Google ScholarGoogle Scholar
  13. T. Freeman and F. Pfenning. 1991. Refinement Types for ML. In Prog. Lang. Design and Impl. (PLDI'91).Google ScholarGoogle Scholar
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle Scholar
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle Scholar
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Harper. 2016. Practical Foundations for Programming Languages. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle Scholar
  21. J. Hofmann, K. Aehlig, and M. Hofmann. 2011b. Multivariate Amortized Resource Analysis. In Princ. of Prog. Lang. (POPL'11).Google ScholarGoogle Scholar
  22. J. Hofmann, A. Das, and S.-C. Weng. 2017. Towards Automatic Resource Bound Analysis for OCaml. In Princ. of Prog. Lang. (POPL'17).Google ScholarGoogle Scholar
  23. J. Hofmann and M. Hofmann. 2010a. Amortized Resource Analysis with Polynomial Potential. In European Symp. on Programming (ESOP'10).Google ScholarGoogle Scholar
  24. 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 ScholarGoogle Scholar
  25. 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 ScholarGoogle Scholar
  26. 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 ScholarGoogle Scholar
  27. 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 ScholarGoogle Scholar
  28. Z. Kincaid, J. Breck, A. F. Boroujeni, and T. Reps. 2017. Compositional Recurrence Analysis Revisited. In Prog. Lang. Design and Impl. (PLDI'17).Google ScholarGoogle Scholar
  29. Z. Kincaid, J. Cyphert, J. Breck, and T. Reps. 2019. Non-linear Reasoning for Invariant Synthesis. In Princ. of Prog. Lang. (POPL'19).Google ScholarGoogle Scholar
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. Tristan Knoth, Di Wang, Adam Reynolds, Jan Hofmann, and Nadia Polikarpova. 2020. Liquid Resource Types (Extended Version). ( 2020 ). arXiv:cs.PL/ 2006.16233Google ScholarGoogle Scholar
  32. U. D. Lago and M. Gaboardi. 2011. Linear Dependent Types and Relative Completeness. In Logic in Computer Science (LICS'11).Google ScholarGoogle Scholar
  33. 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 ScholarGoogle Scholar
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  36. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  37. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  38. 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 ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. Patrick Maxim Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In PLDI.Google ScholarGoogle Scholar
  41. A. Sabry and M. Felleisen. 1992. Reasoning about Programs in Continuation-Passing Style. In LISP and Functional Programming (LFP'92).Google ScholarGoogle Scholar
  42. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  43. Armando Solar-Lezama, Liviu Tancau, Rastislav Bodík, Sanjit A. Seshia, and Vijay A. Saraswat. 2006. Combinatorial sketching for finite programs. In ASPLOS.Google ScholarGoogle Scholar
  44. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  45. R. E. Tarjan. 1985. Amortized Computational Complexity. SIAM J. Algebraic Discrete Methods 6 ( August 1985 ). Issue 2.Google ScholarGoogle Scholar
  46. Niki Vazou, Patrick Maxim Rondon, and Ranjit Jhala. 2013. Abstract Refinement Types. In ESOP.Google ScholarGoogle Scholar
  47. D. Walker. 2002. Substructural Type Systems. In Advanced Topics in Types and Programming Languages. MIT Press.Google ScholarGoogle Scholar
  48. 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 ScholarGoogle Scholar
  49. Ben Wegbreit. 1975. Mechanical Program Analysis. Commun. ACM 18, 9 ( 1975 ), 528-539.Google ScholarGoogle Scholar
  50. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Liquid resource types

      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!