Automated Resource Analysis with Coq Proof Objects

  • Quentin CarbonneauxEmail author
  • Jan Hoffmann
  • Thomas Reps
  • Zhong Shao
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10427)


This paper addresses the problem of automatically performing resource-bound analysis, which can help programmers understand the performance characteristics of their programs. We introduce a method for resource-bound inference that (i) is compositional, (ii) produces machine-checkable certificates of the resource bounds obtained, and (iii) features a sound mechanism for user interaction if the inference fails. The technique handles recursive procedures and has the ability to exploit any known program invariants. An experimental evaluation with an implementation in the tool Pastis shows that the new analysis is competitive with state-of-the-art resource-bound tools while also creating Coq certificates.



We thank Vilhelm Sjöberg and Lionel Rieg for their helpful suggestions during the implementation of proof certificates in Coq.


  1. 1.
    Albert, E., Arenas, P., Genaim, S., Gómez-Zamalloa, M., Puebla, G.: Automatic inference of resource consumption bounds. In: Bjørner, N., Voronkov, A. (eds.) LPAR 2012. LNCS, vol. 7180, pp. 1–11. Springer, Heidelberg (2012). doi: 10.1007/978-3-642-28717-6_1 CrossRefGoogle Scholar
  2. 2.
    Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of Java bytecode. In: Nicola, R. (ed.) ESOP 2007. LNCS, vol. 4421, pp. 157–172. Springer, Heidelberg (2007). doi: 10.1007/978-3-540-71316-6_12 CrossRefGoogle Scholar
  3. 3.
    Albert, E., Bubel, R., Genaim, S., Hähnle, R., Román-Díez, G.: Verified resource guarantees for heap manipulating programs. In: Lara, J., Zisman, A. (eds.) FASE 2012. LNCS, vol. 7212, pp. 130–145. Springer, Heidelberg (2012). doi: 10.1007/978-3-642-28872-2_10 CrossRefGoogle Scholar
  4. 4.
    Albert, E., Fernández, J.C., Román-Díez, G.: Non-cumulative resource analysis. In: Baier, C., Tinelli, C. (eds.) TACAS 2015. LNCS, vol. 9035, pp. 85–100. Springer, Heidelberg (2015). doi: 10.1007/978-3-662-46681-0_6 Google Scholar
  5. 5.
    Alias, C., Darte, A., Feautrier, P., Gonnord, L.: Multi-dimensional rankings, program termination, and complexity bounds of flowchart programs. In: Cousot, R., Martel, M. (eds.) SAS 2010. LNCS, vol. 6337, pp. 117–133. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-15769-1_8 CrossRefGoogle Scholar
  6. 6.
    Atkey, R.: Amortised resource analysis with separation logic. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 85–103. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-11957-6_6 CrossRefGoogle Scholar
  7. 7.
    Avanzini, M., Lago, U.D., Moser, G.: Analysing the complexity of functional programs: higher-order meets first-order. In: ICFP (2012)Google Scholar
  8. 8.
    Bagnara, R., Rodríguez-Carbonell, E., Zaffanella, E.: Generation of basic semi-algebraic invariants using convex polyhedra. In: Hankin, C., Siveroni, I. (eds.) SAS 2005. LNCS, vol. 3672, pp. 19–34. Springer, Heidelberg (2005). doi: 10.1007/11547662_4 CrossRefGoogle Scholar
  9. 9.
    Blazy, S., Maroneze, A., Pichardie, D.: Formal verification of loop bound estimation for WCET analysis. In: Cohen, E., Rybalchenko, A. (eds.) VSTTE 2013. LNCS, vol. 8164, pp. 281–303. Springer, Heidelberg (2014). doi: 10.1007/978-3-642-54108-7_15 CrossRefGoogle Scholar
  10. 10.
    Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C., Giesl, J.: Alternating runtime and size complexity analysis of integer programs. In: Ábrahám, E., Havelund, K. (eds.) TACAS 2014. LNCS, vol. 8413, pp. 140–155. Springer, Heidelberg (2014). doi: 10.1007/978-3-642-54862-8_10 CrossRefGoogle Scholar
  11. 11.
    Carbonneaux, Q., Hoffmann, J., Shao, Z.: Compositional certified resource bounds. In: PLDI (2015)Google Scholar
  12. 12.
    Carbonneaux, Q., Hoffmann, J., Ramananandro, T., Shao, Z.: End-to-end verification of stack-space bounds for C programs. In: PLDI (2014)Google Scholar
  13. 13.
    Černý, P., Henzinger, T.A., Kovács, L., Radhakrishna, A., Zwirchmayr, J.: Segment abstraction for worst-case execution time analysis. In: Vitek, J. (ed.) ESOP 2015. LNCS, vol. 9032, pp. 105–131. Springer, Heidelberg (2015). doi: 10.1007/978-3-662-46669-8_5 CrossRefGoogle Scholar
  14. 14.
    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. LNCS, vol. 9236, pp. 137–153. Springer, Cham (2015). doi: 10.1007/978-3-319-22102-1_9 Google Scholar
  15. 15.
    Cousot, P., Cousot, R.: Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. In: POPL (1977)Google Scholar
  16. 16.
    Flores-Montoya, A., Hähnle, R.: Resource analysis of complex programs with cost equations. In: Garrigue, J. (ed.) APLAS 2014. LNCS, vol. 8858, pp. 275–295. Springer, Cham (2014). doi: 10.1007/978-3-319-12736-1_15 Google Scholar
  17. 17.
    Hoffmann, J., Das, A., Weng, S.C.: Towards automatic resource bound analysis for OCaml. In: POPL (2017)Google Scholar
  18. 18.
    Hoffmann, J., Hofmann, M.: Amortized resource analysis with polymorphic recursion and partial big-step operational semantics. In: Ueda, K. (ed.) APLAS 2010. LNCS, vol. 6461, pp. 172–187. Springer, Heidelberg (2010). doi: 10.1007/978-3-642-17164-2_13 CrossRefGoogle Scholar
  19. 19.
    Hoffmann, J., Aehlig, K., Hofmann, M.: Multivariate amortized resource analysis. In: POPL (2011)Google Scholar
  20. 20.
    Hofmann, M., Jost, S.: Static prediction of heap space usage for first-order functional programs. In: POPL (2003)Google Scholar
  21. 21.
    Hofmann, M., Jost, S.: Type-based amortised heap-space analysis. In: Sestoft, P. (ed.) ESOP 2006. LNCS, vol. 3924, pp. 22–37. Springer, Heidelberg (2006). doi: 10.1007/11693024_3 CrossRefGoogle Scholar
  22. 22.
    Kincaid, Z., Breck, J., Forouhi Boroujeni, A., Reps, T.: Compositional recurrence analysis revisited. In: PLDI (2017)Google Scholar
  23. 23.
    Madhavan, R., Kulal, S., Kuncak, V.: Contract-based resource verification for higher-order functions with memoization. In: POPL (2017)Google Scholar
  24. 24.
    Monniaux, D.: Automatic modular abstractions for template numerical constraints. LMCS 6(3:4) (2010)Google Scholar
  25. 25.
    Müller-Olm, M., Seidl, H.: Precise interprocedural analysis through linear algebra. In: POPL (2004)Google Scholar
  26. 26.
    Nipkow, T.: Amortized complexity verified. In: Urban, C., Zhang, X. (eds.) ITP 2015. LNCS, vol. 9236, pp. 310–324. Springer, Cham (2015). doi: 10.1007/978-3-319-22102-1_21 Google Scholar
  27. 27.
    Sankaranarayanan, S., Sipma, H.B., Manna, Z.: Scalable analysis of linear systems using mathematical programming. In: Cousot, R. (ed.) VMCAI 2005. LNCS, vol. 3385, pp. 25–41. Springer, Heidelberg (2005). doi: 10.1007/978-3-540-30579-8_2 CrossRefGoogle Scholar
  28. 28.
    Serrano, A., López-García, P., Hermenegildo, M.V.: Resource usage analysis of logic programs via abstract interpretation using sized types. TPLP 14(4–5), 739–754 (2014)zbMATHGoogle Scholar
  29. 29.
    Sinn, M., Zuleger, F., Veith, H.: A simple and scalable static analysis for bound analysis and amortized complexity analysis. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 745–761. Springer, Cham (2014). doi: 10.1007/978-3-319-08867-9_50 Google Scholar
  30. 30.
    Sinn, M., Zuleger, F., Veith, H.: Difference constraints: an adequate abstraction for complexity analysis of imperative programs. In: FMCAD (2015)Google Scholar
  31. 31.
    Srikanth, A., Sahin, B., Harris, W.R.: Complexity verification using guided theorem enumeration. In: POPL (2017)Google Scholar
  32. 32.
    The Coq development team: Reference manual (v8.6). Accessed May 2017
  33. 33.
    Vasconcelos, P., Jost, S., Florido, M., Hammond, K.: Type-based allocation analysis for co-recursion in lazy functional languages. In: Vitek, J. (ed.) ESOP 2015. LNCS, vol. 9032, pp. 787–811. Springer, Heidelberg (2015). doi: 10.1007/978-3-662-46669-8_32 CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  • Quentin Carbonneaux
    • 1
    Email author
  • Jan Hoffmann
    • 2
  • Thomas Reps
    • 3
    • 4
  • Zhong Shao
    • 1
  1. 1.Yale UniversityNew HavenUSA
  2. 2.Carnegie Mellon UniversityPittsburghUSA
  3. 3.University of WisconsinMadisonUSA
  4. 4.GrammaTech, Inc.IthacaUSA

Personalised recommendations