Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Denotational recurrence extraction for amortized analysis

Published: 03 August 2020 Publication History

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.

Supplementary Material

Presentation at ICFP '20 (a97-cutler-presentation.mp4)

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.
[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.
[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.
[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.
[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.
[6]
Ralph Benzinger. 2004. Automated higher-order complexity analysis. Theoretical Computer Science 318, 1-2 (2004), 79–103.
[7]
Joseph W. Cutler, Daniel R. Licata, and Norman Danner. 2020. Denotational recurrence extraction for amortized analysis. arXiv: 2006.15036
[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.
[9]
Norman Danner and Daniel R. Licata. 2020. Denotational semantics as a foundation for cost recurrence extraction for functional languages. arXiv: 2002.07262v1
[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.
[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.
[12]
Norman Danner and James S. Royer. 2007. Adventures in time and space. Logical Methods in Computer Science 3, 9 (2007), 1–53.
[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.
[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.
[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.
[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.
[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.
[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.
[19]
Martin Hofmann. 2003. Linear Types and Non-Size-Increasing Polynomial Time Computation. Information and Computation 183, 1 (2003), 57–85.
[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.
[21]
Hudson, Bowornmet. 2016. Computer-Checked Recurrence Extraction for Functional Programs. Master’s thesis. Wesleyan University.
[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.
[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).
[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.
[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.
[26]
Daniel Le Métayer. 1988. ACE: an automatic complexity evaluator. ACM Transactions on Programming Languages and Systems 10, 2 (1988), 248–266.
[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.
[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.
[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.
[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.
[31]
Chris Okasaki. 1998. Purely Functional Data Structures. Cambridge University Press.
[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.
[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.
[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.
[35]
David Sands. 1990. Calculi for Time Analysis of Functional Programs. Ph.D. Dissertation. University of London.
[36]
Jon Shultis. 1985. On the complexity of higher-order programs. Technical Report CU-CS-288-85. University of Colorado at Boulder.
[37]
Daniel Dominic Sleator and Robert Endre Tarjan. 1985. Self-adjusting binary search trees. Journal of the ACM 32, 3 (1985).
[38]
Kathryn Van Stone. 2003. A Denotational Approach to Measuring Complexity in Functional Programs. Ph.D. Dissertation. Carnegie Mellon University.
[39]
Robert Endre Tarjan. 1985. Amortized computational complexity. SIAM J. Algebraic Discrete Methods 6, 2 (1985), 306–318.
[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.
[41]
Ben Wegbreit. 1975. Mechanical program analysis. Communications of the Association for Computing Machinery 18, 9 (1975), 528–539.

Cited By

View all
  • (2024)Story of Your Lazy Function’s Life: A Bidirectional Demand Semantics for Mechanized Cost Analysis of Lazy ProgramsProceedings of the ACM on Programming Languages10.1145/36746268:ICFP(30-63)Online publication date: 15-Aug-2024
  • (2024)Robust Resource Bounds with Static Analysis and Bayesian InferenceProceedings of the ACM on Programming Languages10.1145/36563808:PLDI(76-101)Online publication date: 20-Jun-2024
  • (2023)Automatic Amortized Resource Analysis with Regular Recursive Types2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS56636.2023.10175720(1-14)Online publication date: 26-Jun-2023
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Proceedings of the ACM on Programming Languages
Proceedings of the ACM on Programming Languages  Volume 4, Issue ICFP
August 2020
1070 pages
EISSN:2475-1421
DOI:10.1145/3415018
Issue’s Table of Contents
This work is licensed under a Creative Commons Attribution International 4.0 License.

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 03 August 2020
Published in PACMPL Volume 4, Issue ICFP

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. amortized analysis
  2. cost semantics
  3. denotational semantics
  4. higher order recurrences
  5. recurrence extraction
  6. resource analysis

Qualifiers

  • Research-article

Funding Sources

  • AFRL
  • NSF
  • AFOSR

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)78
  • Downloads (Last 6 weeks)12
Reflects downloads up to 03 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Story of Your Lazy Function’s Life: A Bidirectional Demand Semantics for Mechanized Cost Analysis of Lazy ProgramsProceedings of the ACM on Programming Languages10.1145/36746268:ICFP(30-63)Online publication date: 15-Aug-2024
  • (2024)Robust Resource Bounds with Static Analysis and Bayesian InferenceProceedings of the ACM on Programming Languages10.1145/36563808:PLDI(76-101)Online publication date: 20-Jun-2024
  • (2023)Automatic Amortized Resource Analysis with Regular Recursive Types2023 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS56636.2023.10175720(1-14)Online publication date: 26-Jun-2023
  • (2022)Denotational semantics as a foundation for cost recurrence extraction for functional languagesJournal of Functional Programming10.1017/S095679682200003X32Online publication date: 5-Jul-2022
  • (2021)Dynaplex: analyzing program complexity using dynamically inferred recurrence relationsProceedings of the ACM on Programming Languages10.1145/34855155:OOPSLA(1-23)Online publication date: 15-Oct-2021
  • (2021)On continuation-passing transformations and expected cost analysisProceedings of the ACM on Programming Languages10.1145/34735925:ICFP(1-30)Online publication date: 19-Aug-2021
  • (2021)Reasoning about the garden of forking pathsProceedings of the ACM on Programming Languages10.1145/34735855:ICFP(1-28)Online publication date: 19-Aug-2021
  • (2021)Automatic amortized resource analysis with the Quantum physicist’s methodProceedings of the ACM on Programming Languages10.1145/34735815:ICFP(1-29)Online publication date: 19-Aug-2021
  • (2021)Relational cost analysis in a functional-imperative settingJournal of Functional Programming10.1017/S095679682100007131Online publication date: 2-Nov-2021

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Full Access

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media