Advertisement

From Shapes to Amortized Complexity

  • Tomáš Fiedor
  • Lukáš Holík
  • Adam Rogalewicz
  • Moritz Sinn
  • Tomáš Vojnar
  • Florian Zuleger
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10747)

Abstract

We propose a new method for the automated resource bound analysis of programs manipulating dynamic data structures built on top of an underlying shape and resource bound analysis. Our approach first constructs an integer abstraction for the input program using information gathered by a shape analyser; then a resource bound analyzer is run on the resulting integer program. The integer abstraction is based on shape norms — numerical measures on dynamic data structures (e.g., the length of a linked list). In comparison to related approaches, we consider a larger class of shape norms which we derive by a lightweight program analysis. The analysis identifies paths through the involved dynamic data structures, and filters the norms which are unlikely to be useful for the later bound analysis. We present a calculus for deriving the numeric changes of the shape norms, thereby generating the integer program. Our calculus encapsulates the minimal information which is required from the shape analysis.

We have implemented our approach on top of the Forester shape analyser and evaluated it on a number of programs manipulating various list and tree structures using the Loopus tool as the underlying bounds analyser. We report on programs with complex data structures and/or using complex algorithms that could not be analysed in a fully automated and precise way before.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Sinn, M., Zuleger, F., Veith, H.: Complexity and resource bound analysis of imperative programs using difference constraints. J. Autom. Reasoning 59(1), 3–45 (2017)MathSciNetCrossRefMATHGoogle Scholar
  2. 2.
    Gulwani, S., Lev-Ami, T., Sagiv, M.: A combination framework for tracking partition sizes. In: Proc. of POPL 2009, pp. 239–251 (2009)Google Scholar
  3. 3.
    Hofmann, M., Rodriguez, D.: Automatic type inference for amortised heap-space analysis. In: Felleisen, M., Gardner, P. (eds.) ESOP 2013. LNCS, vol. 7792, pp. 593–613. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-37036-6_32 CrossRefGoogle Scholar
  4. 4.
    Atkey, R.: Amortised resource analysis with separation logic. Logical Methods in Computer Science 7(2) (2011)Google Scholar
  5. 5.
    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).  https://doi.org/10.1007/978-3-642-28717-6_1 CrossRefGoogle Scholar
  6. 6.
    Frohn, F., Giesl, J.: Complexity analysis for Java with AProVE. In: Polikarpova, N., Schneider, S. (eds.) IFM 2017. LNCS, vol. 10510, pp. 85–101. Springer, Cham (2017).  https://doi.org/10.1007/978-3-319-66845-1_6 CrossRefGoogle Scholar
  7. 7.
    Holík, L., Hruška, M., Lengál, O., Rogalewicz, A., Šimáček, J., Vojnar, T.: Forester: shape analysis using tree automata (competition contribution). In: Baier, C., Tinelli, C. (eds.) TACAS 2015. LNCS, vol. 9035, pp. 432–435. Springer, Heidelberg (2015).  https://doi.org/10.1007/978-3-662-46681-0_37 Google Scholar
  8. 8.
    Sinn, M., Zuleger, F.: Loopus - a tool for computing loop bounds for c programs. In: Proc. of WING@ETAPS/IJCAR (2010)Google Scholar
  9. 9.
    Ströder, T., Aschermann, C., Frohn, F., Hensel, J., Giesl, J.: AProVE: termination and memory safety of C programs (competition contribution). In: Baier, C., Tinelli, C. (eds.) TACAS 2015. LNCS, vol. 9035, pp. 417–419. Springer, Heidelberg (2015).  https://doi.org/10.1007/978-3-662-46681-0_32 Google Scholar
  10. 10.
    Bouajjani, A., Bozga, M., Habermehl, P., Iosif, R., Moro, P., Vojnar, T.: Programs with Lists are Counter Automata. Formal Methods in System Design 38(2) (2011)Google Scholar
  11. 11.
    Berdine, J., Cook, B., Distefano, D., O’Hearn, P.W.: Automatic termination proofs for programs with shape-shifting heaps. In: Ball, T., Jones, R.B. (eds.) CAV 2006. LNCS, vol. 4144, pp. 386–400. Springer, Heidelberg (2006).  https://doi.org/10.1007/11817963_35 CrossRefGoogle Scholar
  12. 12.
    Lahiri, S., Qadeer, S.: Verifying properties of well-founded linked lists. In: Proc. of POPL 2006. ACM Press (2006)Google Scholar
  13. 13.
    Yavuz-Kahveci, T., Bultan, T.: Automated verification of concurrent linked lists with counters. In: Hermenegildo, M.V., Puebla, G. (eds.) SAS 2002. LNCS, vol. 2477, pp. 69–84. Springer, Heidelberg (2002).  https://doi.org/10.1007/3-540-45789-5_8 CrossRefGoogle Scholar
  14. 14.
    Berdine, J., Chawdhary, A., Cook, B., Distefano, D., O’Hearn, P.: Variance analyses from invariance analyses. In: Proc. of POPL 2007. ACM (2007)Google Scholar
  15. 15.
    Rugina, R.: Quantitative shape analysis. In: Giacobazzi, R. (ed.) SAS 2004. LNCS, vol. 3148, pp. 228–245. Springer, Heidelberg (2004).  https://doi.org/10.1007/978-3-540-27864-1_18 CrossRefGoogle Scholar
  16. 16.
    Habermehl, P., Iosif, R., Rogalewicz, A., Vojnar, T.: Proving termination of tree manipulating programs. In: Namjoshi, K.S., Yoneda, T., Higashino, T., Okamura, Y. (eds.) ATVA 2007. LNCS, vol. 4762, pp. 145–161. Springer, Heidelberg (2007).  https://doi.org/10.1007/978-3-540-75596-8_12 CrossRefGoogle Scholar
  17. 17.
    Magill, S., Tsai, M.H., Lee, P., Tsay, Y.K.: Automatic numeric abstractions for heap-manipulating programs. In: Proc. of POPL 2010 (2010)Google Scholar
  18. 18.
    Magill, S., Tsai, M.-H., Lee, P., Tsay, Y.-K.: THOR: a tool for reasoning about shape and arithmetic. In: Gupta, A., Malik, S. (eds.) CAV 2008. LNCS, vol. 5123, pp. 428–432. Springer, Heidelberg (2008).  https://doi.org/10.1007/978-3-540-70545-1_41 CrossRefGoogle Scholar
  19. 19.
    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).  https://doi.org/10.1007/978-3-319-08867-9_50 Google Scholar
  20. 20.
    Bouajjani, A., Habermehl, P., Vojnar, T.: Abstract regular model checking. In: Alur, R., Peled, D.A. (eds.) CAV 2004. LNCS, vol. 3114, pp. 372–386. Springer, Heidelberg (2004).  https://doi.org/10.1007/978-3-540-27813-9_29 CrossRefGoogle Scholar
  21. 21.
    Abdulla, P.A., Haziza, F., Holík, L., Jonsson, B., Rezine, A.: An integrated specification and verification technique for highly concurrent data structures. In: Piterman, N., Smolka, S.A. (eds.) TACAS 2013. LNCS, vol. 7795, pp. 324–338. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-36742-7_23 CrossRefGoogle Scholar
  22. 22.
    Holík, L., Hruška, M., Lengál, O., Rogalewicz, A., Vojnar, T.: Counterexample validation and interpolation-based refinement for forest automata. In: Bouajjani, A., Monniaux, D. (eds.) VMCAI 2017. LNCS, vol. 10145, pp. 288–309. Springer, Cham (2017).  https://doi.org/10.1007/978-3-319-52234-0_16 CrossRefGoogle Scholar
  23. 23.
    Holík, L., Lengál, O., Rogalewicz, A., Šimáček, J., Vojnar, T.: Fully automated shape analysis based on forest automata. In: Sharygina, N., Veith, H. (eds.) CAV 2013. LNCS, vol. 8044, pp. 740–755. Springer, Heidelberg (2013).  https://doi.org/10.1007/978-3-642-39799-8_52 CrossRefGoogle Scholar
  24. 24.
    Bjørner, N.: The Z3 Theorem Prover. https://github.com/Z3Prover/z3/

Copyright information

© Springer International Publishing AG 2018

Authors and Affiliations

  • Tomáš Fiedor
    • 1
  • Lukáš Holík
    • 1
  • Adam Rogalewicz
    • 1
  • Moritz Sinn
    • 3
  • Tomáš Vojnar
    • 1
  • Florian Zuleger
    • 2
  1. 1.FIT, IT4Innovations Centre of ExcellenceBrno University of TechnologyBrnoCzech Republic
  2. 2.TU WienViennaAustria
  3. 3.St. Pölten University of Applied SciencesSankt PöltenAustria

Personalised recommendations