Skip to main content
SpringerLink
Log in
Menu
Find a journal Publish with us
Search
Go to cart
Book cover

European Symposium on Programming

ESOP 2021: Programming Languages and Systems pp 292–319Cite as

  1. Home
  2. Programming Languages and Systems
  3. Conference paper
For a Few Dollars More

For a Few Dollars More

Verified Fine-Grained Algorithm Analysis Down to LLVM

  • Maximilian P. L. Haslbeck  ORCID: orcid.org/0000-0003-4306-869X9 &
  • Peter Lammich  ORCID: orcid.org/0000-0003-3576-050410 
  • Conference paper
  • Open Access
  • First Online: 23 March 2021
  • 3203 Accesses

  • 1 Citations

  • 1 Altmetric

Part of the Lecture Notes in Computer Science book series (LNTCS,volume 12648)

Abstract

We present a framework to verify both, functional correctness and worst-case complexity of practically efficient algorithms. We implemented a stepwise refinement approach, using the novel concept of resource currencies to naturally structure the resource analysis along the refinement chain, and allow a fine-grained analysis of operation counts. Our framework targets the LLVM intermediate representation. We extend its semantics from earlier work with a cost model. As case study, we verify the correctness and \(O(n\log n)\) worst-case complexity of an implementation of the introsort algorithm, whose performance is on par with the state-of-the-art implementation found in the GNU C++ Library.

Keywords

  • Algorithm Analysis
  • Program Verification
  • Refinement

Download conference paper PDF

References

  1. Atkey, R.: Amortised resource analysis with separation logic. In: Gordon, A.D. (ed.) European Symposium on Programming, ESOP 2010. Lecture Notes in Computer Science, vol. 6012, pp. 85–103. Springer (2010). https://doi.org/10.1007/978-3-642-11957-6_6, https://doi.org/10.1007/978-3-642-11957-6_6

  2. Blazy, S., Leroy, X.: Mechanized semantics for the Clight subset of the C language. J. Autom. Reason. 43(3), 263–288 (2009). https://doi.org/10.1007/s10817-009-9148-3, https://doi.org/10.1007/s10817-009-9148-3

  3. Calcagno, C., O’Hearn, P.W., Yang, H.: Local action and abstract separation logic. In: Symposium on Logic in Computer Science (LICS 2007). pp. 366–378. IEEE Computer Society (2007). https://doi.org/10.1109/LICS.2007.30, https://doi.org/10.1109/LICS.2007.30

  4. Carbonneaux, Q., Hoffmann, J., Ramananandro, T., Shao, Z.: End-to-end verification of stack-space bounds for C programs. In: O’Boyle, M.F.P., Pingali, K. (eds.) ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’14, Edinburgh, United Kingdom - June 09 - 11, 2014. pp. 270–281. ACM (2014). https://doi.org/10.1145/2594291.2594301, https://doi.org/10.1145/2594291.2594301

  5. Charguéraud, A.: Separation logic for sequential programs (functional pearl). Proc. ACM Program. Lang. 4(ICFP), 116:1–116:34 (2020). https://doi.org/10.1145/3408998, https://doi.org/10.1145/3408998

  6. 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. 62(3), 331–365 (2019). https://doi.org/10.1007/s10817-017-9431-7, https://doi.org/10.1007/s10817-017-9431-7

  7. cppreference: C++ standard library specification of sort. https://en.cppreference.com/w/cpp/algorithm/sort, accessed: 2020-10-12

  8. The GNU C++ library, https://gcc.gnu.org/onlinedocs/libstdc++/, version 7.4.0

  9. Guéneau, A., Charguéraud, A., Pottier, F.: A fistful of dollars: Formalizing asymptotic complexity claims via deductive program verification. In: Ahmed, A. (ed.) Programming Languages and Systems - 27th European Symposium on Programming, ESOP 2018. Lecture Notes in Computer Science, vol. 10801, pp. 533–560. Springer (2018). https://doi.org/10.1007/978-3-319-89884-1_19, https://doi.org/10.1007/978-3-319-89884-1_19

  10. Guéneau, A., Jourdan, J., Charguéraud, A., Pottier, F.: Formal proof and analysis of an incremental cycle detection algorithm. In: Harrison, J., O’Leary, J., Tolmach, A. (eds.) 10th International Conference on Interactive Theorem Proving, ITP 2019. LIPIcs, vol. 141, pp. 18:1–18:20. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2019). https://doi.org/10.4230/LIPIcs.ITP.2019.18, https://doi.org/10.4230/LIPIcs.ITP.2019.18

  11. Haslbeck, M.P.L., Lammich, P.: Refinement with time - refining the run-time of algorithms in Isabelle/HOL. In: Harrison, J., O’Leary, J., Tolmach, A. (eds.) 10th International Conference on Interactive Theorem Proving, ITP 2019. LIPIcs, vol. 141, pp. 20:1–20:18. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2019). https://doi.org/10.4230/LIPIcs.ITP.2019.20, https://doi.org/10.4230/LIPIcs.ITP.2019.20

  12. Hoare, C.A.R.: Algorithm 64: Quicksort. Commun. ACM 4(7), 321– (Jul 1961). https://doi.org/10.1145/366622.366644, https://doi.org/10.1145/366622.366644

  13. Krauss, A.: Recursive definitions of monadic functions. In: Bove, A., Komendantskaya, E., Niqui, M. (eds.) Proceedings Workshop on Partiality and Recursion in Interactive Theorem Provers, PAR 2010, Edinburgh, UK, 15th July 2010. EPTCS, vol. 43, pp. 1–13 (2010). https://doi.org/10.4204/EPTCS.43.1, https://doi.org/10.4204/EPTCS.43.1

  14. Lammich, P.: Refinement to Imperative/HOL. In: Urban, C., Zhang, X. (eds.) Interactive Theorem Proving - 6th International Conference, ITP 2015. Lecture Notes in Computer Science, vol. 9236, pp. 253–269. Springer (2015). https://doi.org/10.1007/978-3-319-22102-1_17, https://doi.org/10.1007/978-3-319-22102-1_17

  15. Lammich, P.: Generating verified LLVM from Isabelle/HOL. In: Harrison, J., O’Leary, J., Tolmach, A. (eds.) 10th International Conference on Interactive Theorem Proving, ITP 2019. LIPIcs, vol. 141, pp. 22:1–22:19. Schloss Dagstuhl - Leibniz-Zentrum für Informatik (2019). https://doi.org/10.4230/LIPIcs.ITP.2019.22, https://doi.org/10.4230/LIPIcs.ITP.2019.22

  16. Lammich, P.: Refinement to Imperative HOL. J. Autom. Reason. 62(4), 481–503 (2019). https://doi.org/10.1007/s10817-017-9437-1, https://doi.org/10.1007/s10817-017-9437-1

  17. Lammich, P.: Efficient verified implementation of introsort and pdqsort. In: Peltier, N., Sofronie-Stokkermans, V. (eds.) IJCAR 2020. Lecture Notes in Computer Science, vol. 12167, pp. 307–323. Springer (2020). https://doi.org/10.1007/978-3-030-51054-1_18, https://doi.org/10.1007/978-3-030-51054-1_18

  18. Lammich, P., Meis, R.: A Separation Logic Framework for Imperative HOL. Archive of Formal Proofs (Nov 2012), http://isa-afp.org/entries/Separation_Logic_Imperative_HOL.html, Formal proof development

  19. Lammich, P., Tuerk, T.: Applying data refinement for monadic programs to Hopcroft’s algorithm. In: Beringer, L., Felty, A.P. (eds.) Interactive Theorem Proving - Third International Conference, ITP 2012. Lecture Notesin Computer Science, vol. 7406, pp. 166–182. Springer (2012). https://doi.org/10.1007/978-3-642-32347-8_12, https://doi.org/10.1007/978-3-642-32347-8_12

  20. ”libc++” c++ standard library, https://libcxx.llvm.org/

  21. Mével, G., Jourdan, J., Pottier, F.: Time credits and time receipts in Iris. In: Caires, L. (ed.) Programming Languages and Systems - 28th European Symposium on Programming, ESOP 2019. Lecture Notes in Computer Science, vol. 11423, pp. 3–29. Springer (2019). https://doi.org/10.1007/978-3-030-17184-1_1, https://doi.org/10.1007/978-3-030-17184-1_1

  22. Musser, D.R.: Introspective sorting and selection algorithms. Softw. Pract. Exp. 27(8), 983–993 (1997)

    Google Scholar 

  23. Nipkow, T., Eberl, M., Haslbeck, M.P.L.: Verified textbook algorithms - A biased survey. In: Hung, D.V., Sokolsky, O. (eds.) Automated Technology for Verification and Analysis - 18th International Symposium, ATVA 2020. Lecture Notes in Computer Science, vol. 12302, pp. 25–53. Springer (2020). https://doi.org/10.1007/978-3-030-59152-6_2, https://doi.org/10.1007/978-3-030-59152-6_2

  24. Wadler, P.: Comprehending monads. In: Proceedings of the 1990 ACM Conference on LISP and Functional Programming. p. 6178. LFP ’90, Association for Computing Machinery, New York, NY, USA (1990). https://doi.org/10.1145/91556.91592, https://doi.org/10.1145/91556.91592

  25. Wang, P., Wang, D., Chlipala, A.: TiML: a functional language for practical complexity analysis with invariants. Proc. ACM Program. Lang. 1(OOPSLA), 79:1–79:26 (2017). https://doi.org/10.1145/3133903, https://doi.org/10.1145/3133903

  26. Zhan, B., Haslbeck, M.P.L.: Verifying asymptotic time complexity of imperative programs in Isabelle. In: Galmiche, D., Schulz, S., Sebastiani, R. (eds.) Automated Reasoning - 9th International Joint Conference, IJCAR 2018. Lecture Notes in Computer Science, vol. 10900, pp. 532–548. Springer (2018). https://doi.org/10.1007/978-3-319-94205-6_35, https://doi.org/10.1007/978-3-319-94205-6_35

Download references

Author information

Authors and Affiliations

  1. Technische Universität München, München, Germany

    Maximilian P. L. Haslbeck

  2. The University of Manchester, Manchester, England

    Peter Lammich

Authors
  1. Maximilian P. L. Haslbeck
    View author publications

    You can also search for this author in PubMed Google Scholar

  2. Peter Lammich
    View author publications

    You can also search for this author in PubMed Google Scholar

Corresponding author

Correspondence to Maximilian P. L. Haslbeck .

Editor information

Editors and Affiliations

  1. Imperial College, London, UK

    Nobuko Yoshida

Rights and permissions

Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.

The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.

Reprints and Permissions

Copyright information

© 2021 The Author(s)

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Haslbeck, M.P.L., Lammich, P. (2021). For a Few Dollars More. In: Yoshida, N. (eds) Programming Languages and Systems. ESOP 2021. Lecture Notes in Computer Science(), vol 12648. Springer, Cham. https://doi.org/10.1007/978-3-030-72019-3_11

Download citation

  • .RIS
  • .ENW
  • .BIB
  • DOI: https://doi.org/10.1007/978-3-030-72019-3_11

  • Published: 23 March 2021

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-72018-6

  • Online ISBN: 978-3-030-72019-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Share this paper

Anyone you share the following link with will be able to read this content:

Sorry, a shareable link is not currently available for this article.

Provided by the Springer Nature SharedIt content-sharing initiative

  • The European Joint Conferences on Theory and Practice of Software.

    Published in cooperation with

    http://www.etaps.org/

Search

Navigation

  • Find a journal
  • Publish with us

Discover content

  • Journals A-Z
  • Books A-Z

Publish with us

  • Publish your research
  • Open access publishing

Products and services

  • Our products
  • Librarians
  • Societies
  • Partners and advertisers

Our imprints

  • Springer
  • Nature Portfolio
  • BMC
  • Palgrave Macmillan
  • Apress
  • Your US state privacy rights
  • Accessibility statement
  • Terms and conditions
  • Privacy policy
  • Help and support

Not affiliated

Springer Nature

© 2023 Springer Nature