skip to main content
research-article
Open Access

Denotational recurrence extraction for amortized analysis

Published:03 August 2020Publication History
Skip Abstract Section

Abstract

A typical way of analyzing the time complexity of functional programs is to extract a recurrence expressing the running time of the program in terms of the size of its input, and then to solve the recurrence to obtain a big-O bound. For recurrence extraction to be compositional, it is also necessary to extract recurrences for the size of outputs of helper functions. Previous work has developed techniques for using logical relations to state a formal correctness theorem for a general recurrence extraction translation: a program is bounded by a recurrence when the operational cost is bounded by the extracted cost, and the output value is bounded, according to a value bounding relation defined by induction on types, by the extracted size. This previous work supports higher-order functions by viewing recurrences as programs in a lambda-calculus, or as mathematical entities in a denotational semantics thereof. In this paper, we extend these techniques to support amortized analysis, where costs are rearranged from one portion of a program to another to achieve more precise bounds. We give an intermediate language in which programs can be annotated according to the banker's method of amortized analysis; this language has an affine type system to ensure credits are not spent more than once. We give a recurrence extraction translation of this language into a recurrence language, a simply-typed lambda-calculus with a cost type, and state and prove a bounding logical relation expressing the correctness of this translation. The recurrence language has a denotational semantics in preorders, and we use this semantics to solve recurrences, e.g analyzing binary counters and splay trees.

Skip Supplemental Material Section

Supplemental Material

a97-cutler-presentation.mp4

mp4

26.9 MB

References

  1. Elvira Albert, Puri Arenas, Samir Genaim, and Germán Puebla. 2011. Closed-form upper bounds in static cost analysis. Journal of Automated Reasoning 46 (2011), 161–203. Issue 2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Elvira Albert, Puri Arenas, Samir Genaim, German Puebla, and Damiano Zanardini. 2012. Cost analysis of object-oriented bytecode programs. Theoretical Computer Science 413, 1 (2012), 142–159. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Elvira Albert, Samir Genaim, and Abu Naser Masud. 2013. On the Inference of Resource Usage Upper and Lower Bounds. ACM Transactions on Computational Logic 14, 3 (2013), 22:1–22:35. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Diego Esteban Alonso-Blas and Samir Genaim. 2012. On the limits of the classical approach to cost analysis. In Static Analysis (Lecture Notes in Computer Science), Antoine Miné and David Schmidt (Eds.), Vol. 7460. Springer Berlin Heidelberg, 405–421. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert Atkey. 2018. Syntax and semantics of quantitative type theory. In Proceedings of the 33rd Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2018 (Oxford, United Kingdom). ACM Press, 56–65. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Ralph Benzinger. 2004. Automated higher-order complexity analysis. Theoretical Computer Science 318, 1-2 (2004), 79–103. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Joseph W. Cutler, Daniel R. Licata, and Norman Danner. 2020. Denotational recurrence extraction for amortized analysis. arXiv: 2006.15036Google ScholarGoogle Scholar
  8. Nils Anders Danielsson. 2008. Lightweight semiformal time complexity analysis for purely functional data structures. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, George Necula and Philip Wadler (Eds.). ACM Press, 133–144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Norman Danner and Daniel R. Licata. 2020. Denotational semantics as a foundation for cost recurrence extraction for functional languages. arXiv: 2002.07262v1Google ScholarGoogle Scholar
  10. Norman Danner, Daniel R. Licata, and Ramyaa Ramyaa. 2015. Denotational cost semantics for functional languages with inductive types. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015 (Vancouver, BC, Canada), Kathleen Fisher and John Reppy (Eds.). ACM Press, 140–151. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Norman Danner, Jennifer Paykin, and James S. Royer. 2013. A static cost analysis for a higher-order language. In Proceedings of the 7th workshop on Programming languages meets program verification, PLPV 2013, Matthew Might and David Van Horn (Eds.). ACM Press, 25–34. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Norman Danner and James S. Royer. 2007. Adventures in time and space. Logical Methods in Computer Science 3, 9 (2007), 1–53. Google ScholarGoogle ScholarCross RefCross Ref
  13. Antonio Flores-Montoya. 2016. Upper and Lower Amortized Cost Bounds of Programs Expressed as Cost Relations. In FM 2016: Formal Methods (Lecture Notes in Computer Science), John Fitzgerald, Constance Heitmeyer, Stefania Gnesi, and Anna Philippou (Eds.), Vol. 9995. Springer International Publishing, 254–273. Google ScholarGoogle ScholarCross RefCross Ref
  14. Jean-Yves Girard, Andre Scedrov, and Philip J. Scott. 1992. Bounded linear logic: a modular approach to polynomial-time computability. Theoretical Computer Science 97, 1 (1992), 1–66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Jan Hoffmann, Klaus Aehlig, and Martin Hofmann. 2012. Multivariate Amortized Resource Analysis. ACM Transactions on Programming Languages and Systems 34, 3 (2012), 14:1–14:62. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Jan Hoffmann, Ankush Das, and Shu-Chun Weng. 2017. Towards automatic resource bound analysis for OCaml. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Giuseppe Castagna and Andrew D. Gordon (Eds.). ACM Press, 359–373. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Jan Hoffmann and Zhong Shao. 2015. Automatic static cost analysis for parallel programs. In Programming Languages and Systems: 24th European Symposium on Programming, ESOP 2015 (Lecture Notes in Computer Science), Jan Vitek (Ed.), Vol. 9032. Springer-Verlag, 132–157. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Martin Hofmann. 2002. The Strength of Non-Size Increasing Computation. In Proceedings of the 29th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 260–269. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Martin Hofmann. 2003. Linear Types and Non-Size-Increasing Polynomial Time Computation. Information and Computation 183, 1 (2003), 57–85. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Martin Hofmann and Steffen Jost. 2003. Static prediction of heap space usage for first-order functional programs. In Proceedings of the 30th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Alex Aiken and Greg Morrisett (Eds.). ACM Press, 185–197. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Hudson, Bowornmet. 2016. Computer-Checked Recurrence Extraction for Functional Programs. Master’s thesis. Wesleyan University.Google ScholarGoogle Scholar
  22. Steffen Jost, Pedro Vasconcelos, Mário Florido, and Kevin Hammond. 2017. Type-based cost analysis for lazy functional languages. Journal of Automated Reasoning 59, 1 (2017), 87–120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. G. A. Kavvos, Edward Morehouse, Daniel R. Licata, and Norman Danner. 2019. Recurrence Extraction for Functional Programs through Call-by-Push-Value. Proceedings of the ACM on Programming Languages 4, POPL, Article 15 (2019). Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Zachary Kincaid, John Cyphert, Jason Breck, and Thomas Reps. 2017. Non-linear Reasoning for Invariant Synthesis. Proceedings of the ACM on Programming Languages 2, POPL, Article 54 (Dec. 2017), 33 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Tristan Knoth, Di Wang, Nadia Polikarpova, and Jan Hoffmann. 2019. Resource-Guided Program Synthesis. In ACM SIGPLAN Conference on Programming Language Design and Implementation.Google ScholarGoogle Scholar
  26. Daniel Le Métayer. 1988. ACE: an automatic complexity evaluator. ACM Transactions on Programming Languages and Systems 10, 2 (1988), 248–266. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Daniel R. Licata, Michael Shulman, and Mitchell Riley. 2017. A fibrational framework for substructural and modal logics. In 2nd International Conference on Formal Structures for Computation and Deduction, FSCD 2017 (Leibniz International Proceedings in Informatics (LIPIcs)), Dale Miller (Ed.), Vol. 84. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 25:1– 25:22. Google ScholarGoogle ScholarCross RefCross Ref
  28. Conor McBride. 2016. I got plenty o’ Nuttin’. In A List of Successes That Can Change the World: Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday (Lecture Notes in Computer Science), Sam Lindley, Conor McBride, Phil Trinder, and Don Sannella (Eds.), Vol. 9600. Springer-Verlag. Google ScholarGoogle ScholarCross RefCross Ref
  29. John C. Mitchell and Gordon D. Plotkin. 1985. Abstract types have existential types. In Proceedings of the 12th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL 1985. 37–51. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Yue Niu and Jan Hoffmann. 2018. Automatic Space Bound Analysis for Functional Programs with Garbage Collection. In LPAR-22. 22nd International Conference on Logic for Programming, Artificial Intelligence and Reasoning (EPiC Series in Computing), Gilles Barthe, Geoff Sutcliffe, and Margus Veanes (Eds.), Vol. 57. EasyChair, 543–563. Google ScholarGoogle ScholarCross RefCross Ref
  31. Chris Okasaki. 1998. Purely Functional Data Structures. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Dominic Orchard, Vilem-Benjamin Liepelt, and Harley Eades III. 2019. Quantitative program reasoning with graded modal types. Proceedings of the ACM on Programming Languages 3, ICFP (2019), 110:1–110:30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Jason Reed. [n.d.]. Names are (mostly) useless. ([n. d.]). https://www.cis.upenn.edu/~sweirich/wmm/wmm08- programme. html Presented at 3rd Informal ACM SIGPLAN Workshop on Mechanizing Metatheory 2008.Google ScholarGoogle Scholar
  34. Mads Rosendahl. 1989. Automatic complexity analysis. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, FPCA 1989, Joseph E. Stoy (Ed.). ACM Press, 144–156. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. David Sands. 1990. Calculi for Time Analysis of Functional Programs. Ph.D. Dissertation. University of London.Google ScholarGoogle Scholar
  36. Jon Shultis. 1985. On the complexity of higher-order programs. Technical Report CU-CS-288-85. University of Colorado at Boulder.Google ScholarGoogle Scholar
  37. Daniel Dominic Sleator and Robert Endre Tarjan. 1985. Self-adjusting binary search trees. Journal of the ACM 32, 3 (1985).Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Kathryn Van Stone. 2003. A Denotational Approach to Measuring Complexity in Functional Programs. Ph.D. Dissertation. Carnegie Mellon University.Google ScholarGoogle Scholar
  39. Robert Endre Tarjan. 1985. Amortized computational complexity. SIAM J. Algebraic Discrete Methods 6, 2 (1985), 306–318. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Peng Wang, Di Wang, and Adam Chlipala. 2017. TiML: A functional language for practical complexity analysis with invariants. Proceedings of the ACM on Programming Languages 1, OOPSLA, Article 79 (2017), 26 pages. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Ben Wegbreit. 1975. Mechanical program analysis. Communications of the Association for Computing Machinery 18, 9 (1975), 528–539. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Denotational recurrence extraction for amortized analysis

        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