Journal of Automated Reasoning

, Volume 62, Issue 3, pp 367–391 | Cite as

Amortized Complexity Verified

  • Tobias Nipkow
  • Hauke Brinkop


A framework for the analysis of the amortized complexity of functional data structures is formalized in the proof assistant Isabelle/HOL and applied to a number of standard examples and to the following non-trivial ones: skew heaps, splay trees, splay heaps and pairing heaps. The proofs are completely algebraic and are presented in some detail.


Amortized complexity Interactive verification Functional Programming 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.



Berry Schoenmakers patiently answered many questions about his work. We thank the referees for their careful reading and helpful suggestions.


  1. 1.
    Atkey, R.: Amortised resource analysis with separation logic. Log. Methods Comput. Sci. 7, 2 (2011)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Benzinger, R.: Automated higher-order complexity analysis. Theor. Comput. Sci. 318(1–2), 79–103 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Brinkop, H., Nipkow, T.: Pairing heap. Archive of Formal Proofs (2016). Formal proof development.
  4. 4.
    Carbonneaux, Q., Hoffmann, J., Reps, T.W., Shao, Z.: Automated resource analysis with Coq proof objects. In: Majumdar, R., Kuncak, V. (eds.) Computer Aided Verification, CAV 2017, Part II. Lecture Notes in Computer Science, vol. 10427, pp. 64–85. Springer, Berlin (2017)Google Scholar
  5. 5.
    Charguéraud, A., Pottier, F.: Verifying the correctness and amortized complexity of a union-find implementation in separation logic with time credits. J. Autom. Reason. To appearGoogle Scholar
  6. 6.
    Charguéraud, A., Pottier, F.: Machine-checked verification of the correctness and amortized complexity of an efficient union-find implementation. In: Urban, C., Zhang, X. (eds.) ITP 2015, volume 9236 of LNCS, pp. 137–153. Springer, Berlin (2015)Google Scholar
  7. 7.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L.: Introduction to Algorithms. MIT Press, Cambridge (1990)zbMATHGoogle Scholar
  8. 8.
    Crary, K., Weirich, S.: Resource bound certification. In: Proceeding of the 27th Symposium on Principles of Programming Languages, POPL ’00, pp. 184–198. ACM (2000)Google Scholar
  9. 9.
    Danielsson, N. A.: Lightweight semiformal time complexity analysis for purely functional data structures. In: Proceeding of the 35th Symposium on Principles of Programming Languages, POPL ’08, pp. 133–144. ACM (2008)Google Scholar
  10. 10.
    Danner, N., Licata, D. R., Ramyaa, R.: Denotational cost semantics for functional languages with inductive types. In: Proceedings of the International Conference on Functional Programming, ICFP 2015, pp. 140–151. ACM (2015)Google Scholar
  11. 11.
    Danner, N., Paykin, J., Royer, J.: A static cost analysis for a higher-order language. In: Proceeding of the Workshop Programming Languages Meets Program Verification, PLPV ’13, pp. 25–34. ACM (2013)Google Scholar
  12. 12.
    Flajolet, P., Salvy, B., Zimmermann, P.: Automatic average-case analysis of algorithms. Theor. Comput. Sci. 79(1), 37–109 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Fredman, M.L., Sedgewick, R., Sleator, D., Tarjan, R.: The pairing heap: a new form of self-adjusting heap. Algorithmica 1(1), 111–129 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  14. 14.
    Haeupler, B., Sen, S., Tarjan, R.E.: Rank-pairing heaps. SIAM J. Comput. 40(6), 1463–1485 (2011)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Haftmann, F., Nipkow, T.: Code generation via higher-order rewrite systems. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) Functional and Logic Programming (FLOPS 2010). Springer, Berlin (2010)Google Scholar
  16. 16.
    Harrison, J.: Verifying nonlinear real formulas via sums of squares. In: Schneider, K., Brandt, J. (eds.) TPHOLs 2007, volume 4732 of LNCS, pp. 102–118. Springer, Berlin (2007)Google Scholar
  17. 17.
    Hickey, T., Cohen, J.: Automating program analysis. J. ACM 35(1), 185–220 (1988)MathSciNetCrossRefzbMATHGoogle Scholar
  18. 18.
    Hoffmann, J., Aehlig, K., Hofmann, M.: Multivariate amortized resource analysis. ACM Trans. Program. Lang. Syst. 34(3), 14 (2012)CrossRefzbMATHGoogle Scholar
  19. 19.
    Hoffmann, J., Das, A., Weng, S.-C.: Towards automatic resource bound analysis for OCaml. In: Proceeding of the 44th Symposium on Principles of Programming Languages, POPL ’17, pp. 359–373. ACM (2017)Google Scholar
  20. 20.
    Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: Proceeding of the 30th ACM Symposium Principles of Programming Languages, pp. 185–197 (2003)Google Scholar
  21. 21.
    Hupel, L., Nipkow, T.: A verified compiler from Isabelle/HOL to CakeML. In: Ahmed, A. (eds.) European Symposium on Programming (ESOP 2018), volume of LNCS, Springer, Berlin (2018)Google Scholar
  22. 22.
    Iacono, J.: Improved upper bounds for pairing heaps. In: M. M. Halldórsson (ed.) Algorithm Theory - SWAT 2000, volume 1851 of LNCS, pp. 32–45. Springer (2000)Google Scholar
  23. 23.
    Kaldewaij, A., Schoenmakers, B.: The derivation of a tighter bound for top-down skew heaps. Inf. Process. Lett. 37, 265–271 (1991)MathSciNetCrossRefzbMATHGoogle Scholar
  24. 24.
    Krauss, A.: Partial recursive functions in higher-order logic. In: Furbach, U., Shankar, N. (eds.) Automated Reasoning (IJCAR 2006), volume 4130 of LNCS, pp. 589–603. Springer, Berlin (2006)Google Scholar
  25. 25.
    Kumar, R., Myreen, M. O., Norrish, M., Owens, S.: CakeML: A verified implementation of ML. In: Symposium Principles of Programming Languages, POPL ’14, pp. 179–191. ACM (2014)Google Scholar
  26. 26.
    Le Métayer, D.: ACE: an automatic complexity evaluator. ACM Trans. Program. Lang. Syst. 10(2), 248–266 (1988)CrossRefGoogle Scholar
  27. 27.
    Madhavan, R., Kulal, S., Kuncak, V.: Contract-based resource verification for higher-order functions with memoization. In: Principles of Programming Languages (POPL) (2017)Google Scholar
  28. 28.
    McCarthy, J. A., Fetscher, B., New, M. S., Feltey, D., Findler, R. B.: A Coq library for internal verification of running-times. In: Kiselyov, O., King, A. (eds.) Functional and Logic Programming (FLOPS 2016), volume 9613 of LNCS, pp. 144–162. Springer, Berlin (2016)Google Scholar
  29. 29.
    Nipkow, T.: Amortized complexity verified. Archive of Formal Proofs, 2014. Formal proof development.
  30. 30.
    Nipkow, T.: Skew heap. Archive of Formal Proofs, 2014. Formal proof development.
  31. 31.
    Nipkow, T.: Splay tree. Archive of Formal Proofs, 2014. Formal proof development.
  32. 32.
    Nipkow, T.: Amortized complexity verified. In: Urban, C., Zhang, X. (eds.) Interactive Theorem Proving (ITP 2015), volume 9236 of LNCS, pp. 310–324. Springer, Berlin (2015)Google Scholar
  33. 33.
    Nipkow, T.: Automatic functional correctness proofs for functional search trees. In: Blanchette, J., Merz, S. (eds.) Interactive Theorem Proving (ITP 2016), LNCS. Springer, Berlin (2016)Google Scholar
  34. 34.
    Nipkow, T.: Pairing heap. Archive of Formal Proofs (2016). Formal proof development.
  35. 35.
    Nipkow, T.: Verified root-balanced trees. In: Chang, B.-Y. E. (ed.) Asian Symposium on Programming Languages and Systems, APLAS 2017, volume 10695 of LNCS, pp. 255–272. Springer, Berlin (2017)Google Scholar
  36. 36.
    Nipkow, T., Klein, G.: Concrete Semantics with Isabelle/HOL. Springer (2014).
  37. 37.
    Nipkow, T., Paulson, L., Wenzel, M.: Isabelle/HOL—A Proof Assistant for Higher-Order Logic, volume 2283 of LNCS. Springer, Berlin (2002)Google Scholar
  38. 38.
    Okasaki, C.: Purely Functional Data Structures. Cambridge University Press, Cambridge (1998)CrossRefzbMATHGoogle Scholar
  39. 39.
    Sands, D.: Complexity analysis for a lazy higher-order language. In: Jones, N. (eds.) European Symposium on Programming (ESOP), volume 432 of LNCS, pp. 361–376. Springer, Berlin (1990)Google Scholar
  40. 40.
    Schoenmakers, B.: A systematic analysis of splaying. Inf. Process. Lett. 45, 41–50 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  41. 41.
    Sleator, D.D., Tarjan, R.E.: Self-adjusting binary search trees. J. ACM 32(3), 652–686 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  42. 42.
    Sleator, D.D., Tarjan, R.E.: Self-adjusting heaps. SIAM J. Comput. 15(1), 52–69 (1986)MathSciNetCrossRefzbMATHGoogle Scholar
  43. 43.
    Tarjan, R.E.: Amortized complexity. SIAM J. Algebraic. Disc. Meth. 6(2), 306–318 (1985)MathSciNetCrossRefzbMATHGoogle Scholar
  44. 44.
    Traytel, D., Berghofer, S., Nipkow, T.: Extending Hindley–Milner type inference with coercive structural subtyping. In: Yang, H. (eds.) APLAS 2011, volume 7078 of LNCS, pp. 89–104. Springer, Berlin (2011)Google Scholar
  45. 45.
    Vasconcelos, P. B., Hammond, K.: Inferring cost equations for recursive, polymorphic and higher-order functional programs. In: Trinder, P., Michaelson, G., Pena, R. (eds.) Implementation of Functional Languages, IFL 2003, volume 3145 of LNCS, pp. 86–101. Springer, Berlin (2004)Google Scholar
  46. 46.
    Wegbreit, B.: Mechanical program analysis. Commun. ACM 18(9), 528–539 (1975)MathSciNetCrossRefzbMATHGoogle Scholar
  47. 47.
    Wenzel, M.: Isabelle/Isar—A Versatile Environment for Human-Readable Formal Proof Documents. PhD thesis, Institut für Informatik, Technische Universität München (2002)Google Scholar

Copyright information

© Springer Science+Business Media B.V., part of Springer Nature 2018

Authors and Affiliations

  1. 1.Technische Universität MünchenMünchenGermany

Personalised recommendations