Skip to main content

Verified Analysis of Random Binary Tree Structures

  • Conference paper
  • First Online:
Interactive Theorem Proving (ITP 2018)

Abstract

This work is a case study of the formal verification and complexity analysis of some famous probabilistic algorithms and data structures in the proof assistant Isabelle/HOL. In particular, we consider the expected number of comparisons in randomised quicksort, the relationship between randomised quicksort and average-case deterministic quicksort, the expected shape of an unbalanced random Binary Search Tree, and the expected shape of a Treap. The last two have, to our knowledge, not been analysed using a theorem prover before and the last one is of particular interest because it involves continuous distributions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 79.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 99.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    In fact, any non-discrete probability distribution works, where by ‘non-discrete’ we mean that all singleton sets have probability 0. In the formalisation, however, we restricted ourselves to the case of a uniform distribution over a real interval.

References

  1. Nipkow, T.: Amortized complexity verified. In: Urban, C., Zhang, X. (eds.) ITP 2015. LNCS, vol. 9236, pp. 310–324. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-22102-1_21

    Chapter  Google Scholar 

  2. Nipkow, T.: Automatic functional correctness proofs for functional search trees. In: Blanchette, J.C., Merz, S. (eds.) ITP 2016. LNCS, vol. 9807, pp. 307–322. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-43144-4_19

    Chapter  Google Scholar 

  3. Nipkow, T.: Verified root-balanced trees. In: Chang, B.-Y.E. (ed.) APLAS 2017. LNCS, vol. 10695, pp. 255–272. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-71237-6_13

    Chapter  Google Scholar 

  4. Nipkow, T., Wenzel, M., Paulson, L.C. (eds.): Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9

    Book  MATH  Google Scholar 

  5. Nipkow, T., Klein, G.: Concrete Semantics. With Isabelle/HOL. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-10542-0

    Book  MATH  Google Scholar 

  6. Eberl, M.: The number of comparisons in QuickSort. Archive of Formal Proofs, Formal proof development, March 2017. http://isa-afp.org/entries/Quick_Sort_Cost.html

  7. Eberl, M.: Expected shape of random binary search trees. Archive of Formal Proofs, Formal proof development, April 2017. http://isa-afp.org/entries/Random_BSTs.html

  8. Haslbeck, M., Eberl, M., Nipkow, T.: Treaps. Archive of Formal Proofs, Formal proof development, March 2018. http://isa-afp.org/entries/Treaps.html

  9. Hölzl, J., Heller, A.: Three chapters of measure theory in Isabelle/HOL. In: van Eekelen, M., Geuvers, H., Schmaltz, J., Wiedijk, F. (eds.) ITP 2011. LNCS, vol. 6898, pp. 135–151. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22863-6_12

    Chapter  Google Scholar 

  10. Gouëzel, S.: Ergodic theory. Archive of Formal Proofs, Formal proof development, December 2015. http://isa-afp.org/entries/Ergodic_Theory.html

  11. Eberl, M., Hölzl, J., Nipkow, T.: A verified compiler for probability density functions. In: Vitek, J. (ed.) ESOP 2015. LNCS, vol. 9032, pp. 80–104. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46669-8_4

    Chapter  Google Scholar 

  12. Hölzl, J.: Markov chains and Markov decision processes in Isabelle/HOL. J. Autom. Reason. 59, 345–387 (2017)

    Article  MathSciNet  Google Scholar 

  13. Basin, D.A., Lochbihler, A., Sefidgar, S.R.: Crypthol: game-based proofs in higher-order logic. Cryptology ePrint Archive, report 2017/753 (2017). https://eprint.iacr.org/2017/753

  14. Giry, M.: A categorical approach to probability theory. In: Banaschewski, B. (ed.) Categorical Aspects of Topology and Analysis. LNM, vol. 915, pp. 68–85. Springer, Heidelberg (1982). https://doi.org/10.1007/BFb0092872

    Chapter  Google Scholar 

  15. Hoare, C.A.R.: Quicksort. Comput. J. 5(1), 10 (1962)

    Article  MathSciNet  Google Scholar 

  16. Sedgewick, R.: The analysis of Quicksort programs. Acta Inf. 7(4), 327–355 (1977)

    Article  MathSciNet  Google Scholar 

  17. Cichoń, J.: Quick Sort - average complexity. http://cs.pwr.edu.pl/cichon/Math/QSortAvg.pdf

  18. Cormen, T.H., Stein, C., Rivest, R.L., Leiserson, C.E.: Introduction to Algorithms, 2nd edn. McGraw-Hill Higher Education, Boston (2001)

    MATH  Google Scholar 

  19. Knuth, D.E.: The Art of Computer Programming. Sorting and Searching, vol. 3. Addison Wesley Longman Publishing Co., Redwood City (1998)

    MATH  Google Scholar 

  20. Ottmann, T., Widmayer, P.: Algorithmen und Datenstrukturen, 5th edn. Spektrum Akademischer Verlag, Auflage (2012)

    Book  Google Scholar 

  21. Reed, B.: The height of a random binary search tree. J. ACM 50(3), 306–332 (2003)

    Article  MathSciNet  Google Scholar 

  22. Aslam, J.A.: A simple bound on the expected height of a randomly built binary search tree. Technical report TR2001-387, Dartmouth College, Hanover, NH (2001). Abstract and paper lost

    Google Scholar 

  23. Vuillemin, J.: A unifying look at data structures. Commun. ACM 23(4), 229–239 (1980)

    Article  MathSciNet  Google Scholar 

  24. Seidel, R., Aragon, C.R.: Randomized search trees. Algorithmica 16(4), 464–497 (1996)

    Article  MathSciNet  Google Scholar 

  25. Hurd, J.: Formal verification of probabilistic algorithms. Ph.D. thesis, University of Cambridge (2002)

    Google Scholar 

  26. Audebaud, P., Paulin-Mohring, C.: Proofs of randomized algorithms in Coq. Sci. Comput. Program. 74(8), 568–589 (2009)

    Article  MathSciNet  Google Scholar 

  27. Barthe, G., Grégoire, B., Béguelin, S.Z.: Formal certification of code-based cryptographic proofs. In: Proceedings of the 36th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2009, pp. 90–101 (2009)

    Google Scholar 

  28. Petcher, A., Morrisett, G.: The foundational cryptography framework. In: Focardi, R., Myers, A. (eds.) POST 2015. LNCS, vol. 9036, pp. 53–72. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46666-7_4

    Chapter  Google Scholar 

  29. Lochbihler, A.: Probabilistic functions and cryptographic oracles in higher order logic. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 503–531. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49498-1_20

    Chapter  MATH  Google Scholar 

  30. van der Weegen, E., McKinna, J.: A machine-checked proof of the average-case complexity of quicksort in Coq. In: Berardi, S., Damiani, F., de’Liguoro, U. (eds.) TYPES 2008. LNCS, vol. 5497, pp. 256–271. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02444-3_16

    Chapter  Google Scholar 

  31. Kaminski, B.L., Katoen, J.-P., Matheja, C., Olmedo, F.: Weakest Precondition reasoning for expected run–times of probabilistic programs. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 364–389. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49498-1_15

    Chapter  Google Scholar 

  32. Hölzl, J.: Formalising semantics for expected running time of probabilistic programs. In: Blanchette, J.C., Merz, S. (eds.) ITP 2016. LNCS, vol. 9807, pp. 475–482. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-43144-4_30

    Chapter  Google Scholar 

  33. Tassarotti, J., Harper, R.: Verified tail bounds for randomized programs. In: Avigad, J., Mahboubi, A. (eds.) Interactive Theorem Proving. Springer International Publishing, Cham (2018)

    Google Scholar 

  34. Karp, R.M.: Probabilistic recurrence relations. J. ACM 41(6), 1136–1150 (1994)

    Article  MathSciNet  Google Scholar 

  35. Kwiatkowska, M.Z., Norman, G., Parker, D.: Quantitative analysis with the probabilistic model checker PRISM. Electr. Notes Theor. Comput. Sci. 153(2), 5–31 (2006)

    Article  Google Scholar 

  36. Flajolet, P., Salvy, B., Zimmermann, P.: Lambda-Upsilon-Omega: an assistant algorithms analyzer. In: Mora, T. (ed.) AAECC 1988. LNCS, vol. 357, pp. 201–212. Springer, Heidelberg (1989). https://doi.org/10.1007/3-540-51083-4_60

    Chapter  Google Scholar 

  37. Chatterjee, K., Fu, H., Murhekar, A.: Automated recurrence analysis for almost-linear expected-runtime bounds. In: Majumdar, R., Kunčak, V. (eds.) CAV 2017. LNCS, vol. 10426, pp. 118–139. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63387-9_6

    Chapter  Google Scholar 

  38. Wenzel, M.: Isabelle/Isar – a versatile environment for human-readable formal proof documents. Ph.D. thesis, Institut für Informatik, Technische Universität München (2002). https://mediatum.ub.tum.de/node?id=601724

Download references

Acknowledgement

This work was funded by DFG grant NI 491/16-1. We thank Johannes Hölzl and Andreas Lochbihler for helpful discussions, Johannes Hölzl for his help with the construction of the tree space, and Bohua Zhan and Maximilian P. L. Haslbeck for comments on a draft. We also thank the reviewers for their suggestions.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Manuel Eberl .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer International Publishing AG, part of Springer Nature

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Eberl, M., Haslbeck, M.W., Nipkow, T. (2018). Verified Analysis of Random Binary Tree Structures. In: Avigad, J., Mahboubi, A. (eds) Interactive Theorem Proving. ITP 2018. Lecture Notes in Computer Science(), vol 10895. Springer, Cham. https://doi.org/10.1007/978-3-319-94821-8_12

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-94821-8_12

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-94820-1

  • Online ISBN: 978-3-319-94821-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics