International Conference on Interactive Theorem Proving

ITP 2015: Interactive Theorem Proving pp 137-153 | Cite as

Machine-Checked Verification of the Correctness and Amortized Complexity of an Efficient Union-Find Implementation

Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9236)

Abstract

Union-Find is a famous example of a simple data structure whose amortized asymptotic time complexity analysis is non-trivial. We present a Coq formalization of this analysis. Moreover, we implement Union-Find as an OCaml library and formally endow it with a modular specification that offers a full functional correctness guarantee as well as an amortized complexity bound. Reasoning in Coq about imperative OCaml code relies on the CFML tool, which is based on characteristic formulae and Separation Logic, and which we extend with time credits. Although it was known in principle that amortized analysis can be explained in terms of time credits and that time credits can be viewed as resources in Separation Logic, we believe our work is the first practical demonstration of this approach.

References

  1. 1.
    Aho, A.V., Hopcroft, J.E., Ullman, J.D.: The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading (1974)MATHGoogle Scholar
  2. 2.
    Alstrup, S., Thorup, M., Gørtz, I.L., Rauhe, T., Zwick, U.: Union-find with constant time deletions. ACM Trans. Algorithms 11(1), 6:1–6:28 (2014)CrossRefGoogle Scholar
  3. 3.
    Amadio, rm, et al.: Certified complexity (CerCo). In: Lago, U.D., Peña, R. (eds.) FOPARA 2013. LNCS, vol. 8552, pp. 1–18. Springer, Heidelberg (2014) Google Scholar
  4. 4.
    Atkey, R.: Amortised resource analysis with separation logic. Logical Methods in Computer Science 7(2:17), 1–33 (2011)MathSciNetGoogle Scholar
  5. 5.
    Blelloch, G.E., Greiner, J.: Parallelism in sequential functional languages. In: Functional Programming Languages and Computer Architecture (FPCA) (1995)Google Scholar
  6. 6.
    Charguéraud, A.: Characteristic formulae for the verification of imperative programs in HOSC (2012, to appear)Google Scholar
  7. 7.
    Charguéraud, A.: Characteristic Formulae for Mechanized Program Verification. Ph.D. Thesis, Université Paris 7 (2010)Google Scholar
  8. 8.
    Charguéraud, A., Pottier, F.: Self-contained archive (2015). http://gallium.inria.fr/~fpottier/dev/uf/
  9. 9.
    Chlipala, A.: The Bedrock structured programming system: combining generative metaprogramming and Hoare logic in an extensible program verifier. In: International Conference on Functional Programming (ICFP) (2013)Google Scholar
  10. 10.
    Chlipala, A., Malecha, G., Morrisett, G., Shinnar, A., Wisnesky, R.: Effective interactive proofs for higher-order imperative programs. In: International Conference on Functional Programming (ICFP) (2009)Google Scholar
  11. 11.
    Conchon, S., Filliâtre, J.: A persistent union-find data structure. In: ACM Workshop on ML (2007)Google Scholar
  12. 12.
    Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms, 3rd edn. MIT Press, Cambridge (2009) MATHGoogle Scholar
  13. 13.
    Danielsson, N.A.: Lightweight semiformal time complexity analysis for purely functional data structures. In: Principles of Programming Languages (POPL) (2008)Google Scholar
  14. 14.
    Danner, N., Paykin, J., Royer, J.S.: A static cost analysis for a higher-order language. In: Programming Languages Meets Program Verification (PLPV) (2013)Google Scholar
  15. 15.
    Galler, B.A., Fischer, M.J.: An improved equivalence algorithm. Commun. ACM 7(5), 301–303 (1964)MATHCrossRefGoogle Scholar
  16. 16.
    Hoffmann, J., Aehlig, K., Hofmann, M.: Multivariate amortized resource analysis. ACM Trans. Program. Lang. Syst. 34(3), 14:1–14:62 (2012)CrossRefGoogle Scholar
  17. 17.
    Hoffmann, J., Hofmann, M.: Amortized resource analysis with polynomial potential. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 287–306. Springer, Heidelberg (2010) CrossRefGoogle Scholar
  18. 18.
    Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: Principles of Programming Languages (POPL) (2003)Google Scholar
  19. 19.
    Hopcroft, J.E., Ullman, J.D.: Set merging algorithms. SIAM J. Comput. 2(4), 294–303 (1973)MATHMathSciNetCrossRefGoogle Scholar
  20. 20.
    Kaplan, H., Shafrir, N., Tarjan, R.E.: Union-find with deletions. In: Symposium on Discrete Algorithms (SODA) (2002)Google Scholar
  21. 21.
    Kozen, D.C.: The Design and Analysis of Algorithms. Texts and Monographs in Computer Science. Springer, Heidelberg (1992)CrossRefGoogle Scholar
  22. 22.
    Le Métayer, D.: ACE: an automatic complexity evaluator. ACM Trans. Program. Lang. Syst. 10(2), 248–266 (1988)CrossRefGoogle Scholar
  23. 23.
    Leino, K.R.M., Moskal, M.: VACID-0: Verification of ample correctness of invariants of data-structures, edition 0, manuscript KRML 209 (2010)Google Scholar
  24. 24.
    Nipkow, T.: Amortized complexity verified. In: Interactive Theorem Proving (2015)Google Scholar
  25. 25.
    Pilkiewicz, A., Pottier, F.: The essence of monotonic state. In: Types in Language Design and Implementation (TLDI) (2011)Google Scholar
  26. 26.
    Reynolds, J.C.: Separation logic: A logic for shared mutable data structures. In: Logic in Computer Science (LICS) (2002)Google Scholar
  27. 27.
    Tarjan, R.E.: Class notes: Disjoint set union (1999)Google Scholar
  28. 28.
    Tarjan, R.E., van Leeuwen, J.: Worst-case analysis of set union algorithms. J. ACM 31(2), 245–281 (1984)MATHCrossRefGoogle Scholar
  29. 29.
    Tarjan, R.E.: Efficiency of a good but not linear set union algorithm. J. ACM 22(2), 215–225 (1975)MATHMathSciNetCrossRefGoogle Scholar
  30. 30.
    Wegbreit, B.: Mechanical program analysis. Commun. ACM 18(9), 528–539 (1975)MATHMathSciNetCrossRefGoogle Scholar

Copyright information

© Springer International Publishing Switzerland 2015

Authors and Affiliations

  1. 1.Inria and LRIUniversité Paris Sud, CNRSOrsayFrance
  2. 2.InriaParis-RocquencourtFrance

Personalised recommendations