skip to main content

Thunks and Debits in Separation Logic with Time Credits

Published:05 January 2024Publication History
Skip Abstract Section

Abstract

A thunk is a mutable data structure that offers a simple memoization service: it stores either a suspended computation or the result of this computation. Okasaki [1999] presents many data structures that exploit thunks to achieve good amortized time complexity. He analyzes their complexity by associating a debit with every thunk. A debit can be paid off in several increments; a thunk whose debit has been fully paid off can be forced. Quite strikingly, a debit is associated also with future thunks, which do not yet exist in memory. Some of the debit of a faraway future thunk can be transferred to a nearer future thunk. We present a complete machine-checked reconstruction of Okasaki's reasoning rules in Iris$, a rich separation logic with time credits. We demonstrate the applicability of the rules by verifying a few operations on streams as well as several of Okasaki's data structures, namely the physicist's queue, implicit queues, and the banker's queue.

References

  1. Robert Atkey. 2011. Amortised Resource Analysis with Separation Logic. Logical Methods in Computer Science, 7, 2:17 (2011), http://bentnib.org/amortised-sep-logic-journal.pdf Google ScholarGoogle Scholar
  2. Arthur Charguéraud and François Pottier. 2017. Verifying the Correctness and Amortized Complexity of a Union-Find Implementation in Separation Logic with Time Credits. Journal of Automated Reasoning, Sept., http://cambium.inria.fr/~fpottier/publis/chargueraud-pottier-uf-sltc.pdf Google ScholarGoogle Scholar
  3. Nils Anders Danielsson. 2008. Lightweight Semiformal Time Complexity Analysis for Purely Functional Data Structures. In Principles of Programming Languages (POPL). http://www.cse.chalmers.se/~nad/publications/danielsson-popl2008.pdf Google ScholarGoogle Scholar
  4. James R. Driscoll, Neil Sarnak, Daniel Dominic Sleator, and Robert Endre Tarjan. 1989. Making Data Structures Persistent. J. Comput. System Sci., 38, 1 (1989), 86–124. https://doi.org/10.1016/0022-0000(89)90034-2 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Jennifer Hackett and Graham Hutton. 2019. Call-by-need is clairvoyant call-by-value. Proceedings of the ACM on Programming Languages, 3, ICFP (2019), 114:1–114:23. https://doi.org/10.1145/3341718 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Martin A. T. Handley, Niki Vazou, and Graham Hutton. 2020. Liquidate your assets: reasoning about resource usage in Liquid Haskell. Proceedings of the ACM on Programming Languages, 4, POPL (2020), 24:1–24:27. https://doi.org/10.1145/3371092 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Maximilian P. L. Haslbeck and Peter Lammich. 2021. For a Few Dollars More - Verified Fine-Grained Algorithm Analysis Down to LLVM. In European Symposium on Programming (ESOP) (Lecture Notes in Computer Science, Vol. 12648). Springer, 292–319. https://www21.in.tum.de/~haslbema/documents/Haslbeck_Lammich_LLVM_with_Time.pdf Google ScholarGoogle Scholar
  8. Maximilian P. L. Haslbeck and Tobias Nipkow. 2018. Hoare Logics for Time Bounds: A Study in Meta Theory. In Tools and Algorithms for Construction and Analysis of Systems (TACAS) (Lecture Notes in Computer Science, Vol. 10805). Springer, 155–171. https://www21.in.tum.de/~nipkow/pubs/tacas18.pdf Google ScholarGoogle Scholar
  9. Jan Hoffmann, Michael Marmar, and Zhong Shao. 2013. Quantitative Reasoning for Proving Lock-Freedom. In Logic in Computer Science (LICS). 124–133. http://www.cs.cmu.edu/~janh/papers/lockfree2013.pdf Google ScholarGoogle Scholar
  10. John Hughes. 1989. Why Functional Programming Matters. Computer Journal, 32, 2 (1989), 98–107. http://www.cse.chalmers.se/~rjmh/Papers/whyfp.pdf Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Aleš Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. Journal of Functional Programming, 28 (2018), e20. https://people.mpi-sws.org/~dreyer/papers/iris-ground-up/paper.pdf Google ScholarGoogle ScholarCross RefCross Ref
  12. Yao Li, Li-yao Xia, and Stephanie Weirich. 2021. Reasoning about the garden of forking paths. Proceedings of the ACM on Programming Languages, 5, ICFP (2021), 1–28. https://doi.org/10.1145/3473585 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ravichandhran Madhavan, Sumith Kulal, and Viktor Kuncak. 2017. Contract-based resource verification for higher-order functions with memoization. In Principles of Programming Languages (POPL). 330–343. https://doi.org/10.1145/3009837.3009874 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Simon Marlow, Simon L. Peyton Jones, and Satnam Singh. 2009. Runtime support for multicore Haskell. In International Conference on Functional Programming (ICFP). 65–78. https://www.microsoft.com/en-us/research/wp-content/uploads/2009/09/multicore-ghc.pdf Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Jay A. McCarthy, Burke Fetscher, Max S. New, Daniel Feltey, and Robert Bruce Findler. 2016. A Coq Library for Internal Verification of Running-Times. In Functional and Logic Programming (Lecture Notes in Computer Science, Vol. 9613). Springer, 144–162. https://users.cs.northwestern.edu/~robby/publications/papers/flops2016-mfnff.pdf Google ScholarGoogle ScholarCross RefCross Ref
  16. Glen Mével, Jacques-Henri Jourdan, and François Pottier. 2019. Time credits and time receipts in Iris. In European Symposium on Programming (ESOP) (Lecture Notes in Computer Science, Vol. 11423). Springer, 1–27. http://cambium.inria.fr/~fpottier/publis/mevel-jourdan-pottier-time-in-iris-2019.pdf Google ScholarGoogle ScholarCross RefCross Ref
  17. Tobias Nipkow and Hauke Brinkop. 2019. Amortized Complexity Verified. Journal of Automated Reasoning, 62, 3 (2019), 367–391. https://www21.in.tum.de/~nipkow/pubs/jar18.pdf Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Chris Okasaki. 1999. Purely Functional Data Structures. Cambridge University Press. https://doi.org/10.1017/CBO9780511530104 Google ScholarGoogle ScholarCross RefCross Ref
  19. Alexandre Pilkiewicz and François Pottier. 2011. The essence of monotonic state. In Types in Language Design and Implementation (TLDI). http://cambium.inria.fr/~fpottier/publis/pilkiewicz-pottier-monotonicity.pdf Google ScholarGoogle Scholar
  20. François Pottier, Armaël Guéneau, Jacques-Henri Jourdan, and Glen Mével. 2023. Thunks and Debits in Separation Logic with Time Credits: Coq Formalization. https://gitlab.inria.fr/cambium/iris-time-proofs Google ScholarGoogle Scholar
  21. Robert Endre Tarjan. 1985. Amortized Computational Complexity. SIAM J. Algebraic Discrete Methods, 6, 2 (1985), 306–318. http://dx.doi.org/10.1137/0606031 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Bohua Zhan and Maximilian P. L. Haslbeck. 2018. Verifying Asymptotic Time Complexity of Imperative Programs in Isabelle. In International Joint Conference on Automated Reasoning. arxiv:1802.01336 Google ScholarGoogle Scholar

Index Terms

  1. Thunks and Debits in Separation Logic with Time Credits

      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

      • Article Metrics

        • Downloads (Last 12 months)70
        • Downloads (Last 6 weeks)17

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader