Complexity Analysis for Term Rewriting by Integer Transition Systems

  • Matthias Naaf
  • Florian Frohn
  • Marc Brockschmidt
  • Carsten Fuhs
  • Jürgen GieslEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10483)


We present a new method to infer upper bounds on the innermost runtime complexity of term rewrite systems (TRSs), which benefits from recent advances on complexity analysis of integer transition systems (ITSs). To this end, we develop a transformation from TRSs to a generalized notion of ITSs with (possibly non-tail) recursion. To analyze their complexity, we introduce a modular technique which allows us to use existing tools for standard ITSs in order to infer complexity bounds for our generalized ITSs. The key idea of our technique is a summarization method that allows us to analyze components of the transition system independently. We implemented our contributions in the tool AProVE, and our experiments show that one can now infer bounds for significantly more TRSs than with previous state-of-the-art tools for term rewriting.



We thank A. Flores-Montoya for his help with CoFloCo and the anonymous reviewers for their suggestions and comments.


  1. 1.
    Albert, E., Arenas, P., Genaim, S., Puebla, G.: Closed-form upper bounds in static cost analysis. J. Autom. Reasoning 46(2), 161–203 (2011)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Albert, E., Arenas, P., Genaim, S., Puebla, G., Zanardini, D.: Cost analysis of object-oriented bytecode programs. Theor. Comput. Sc. 413(1), 142–159 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 3.
    Albert, E., Genaim, S., Gutièrrez, R.: A transformational approach to resource analysis with typed-norms. In: Gupta, G., Peña, R. (eds.) LOPSTR 2013. LNCS, vol. 8901, pp. 38–53. Springer, Cham (2014). Google Scholar
  4. 4.
    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
  5. 5.
  6. 6.
    Avanzini, M., Felgenhauer, B.: Type introduction for runtime complexity analysis. In: WST 2014, pp. 1–5 (2014).
  7. 7.
    Avanzini, M., Moser, G., Schaper, M.: TcT: Tyrolean complexity tool. In: Chechik, M., Raskin, J.F. (eds.) TACAS 2016. LNCS, vol. 9636, pp. 407–423. Springer, Berlin, Heidelberg (2016). CrossRefGoogle Scholar
  8. 8.
    Avanzini, M., Moser, G.: A combination framework for complexity. Inform. Comput. 248, 22–55 (2016)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 9.
    Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge U. Press, Cambridge (1998)CrossRefzbMATHGoogle Scholar
  10. 10.
    Baillot, P., Dal Lago, U., Moyen, J.Y.: On quasi-interpretations, blind abstractions and implicit complexity. Math. Struct. Compt. Sci. 22(4), 549–580 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  11. 11.
    Blanc, R., Henzinger, T.A., Hottelier, T., Kovàcs, L.: ABC: Algebraic bound computation for loops. In: Clarke, E.M., Voronkov, A. (eds.) LPAR 2010. LNCS, vol. 6355, pp. 103–118. Springer, Berlin, Heidelberg (2010). CrossRefGoogle Scholar
  12. 12.
    Bonfante, G., Cichon, A., Marion, J.Y., Touzet, H.: Algorithms with polynomial interpretation termination proof. J. Funct. Program. 11(1), 33–53 (2001)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C., Giesl, J.: Analyzing runtime and size complexity of integer programs. ACM TOPLAS 38(4), 13 (2016)CrossRefGoogle Scholar
  14. 14.
    Carbonneaux, Q., Hoffmann, J., Shao, Z.: Compositional certified resource bounds. In: PLDI 2015, pp. 467–478 (2015)Google Scholar
  15. 15.
    Debray, S., Lin, N.: Cost analysis of logic programs. TOPLAS 15(5), 826–875 (1993)CrossRefGoogle 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). Google Scholar
  17. 17.
    Flores-Montoya, A.: Upper and lower amortized cost bounds of programs expressed as cost relations. In: Fitzgerald, J., Heitmeyer, C., Gnesi, S., Philippou, A. (eds.) FM 2016. LNCS, vol. 9995, pp. 254–273. Springer, Cham (2016). CrossRefGoogle Scholar
  18. 18.
    Frohn, F., Naaf, M., Hensel, J., Brockschmidt, M., Giesl, J.: Lower runtime bounds for integer programs. In: Olivetti, N., Tiwari, A. (eds.) IJCAR 2016. LNCS, vol. 9706, pp. 550–567. Springer, Cham (2016). Google Scholar
  19. 19.
    Frohn, F., Giesl, J.: Analyzing runtime complexity via innermost runtime complexity. In: LPAR 2017, pp. 249–268 (2017)Google Scholar
  20. 20.
    Frohn, F., Giesl, J., Hensel, J., Aschermann, C., Ströder, T.: Lower bounds for runtime complexity of term rewriting. J. Autom. Reasoning 59(1), 121–163 (2017)MathSciNetCrossRefzbMATHGoogle Scholar
  21. 21.
    Fuhs, C., Giesl, J., Parting, M., Schneider-Kamp, P., Swiderski, S.: Proving termination by dep. pairs and inductive theorem proving. JAR 47(2), 133–160 (2011)CrossRefzbMATHGoogle Scholar
  22. 22.
    Giesl, J., Aschermann, C., Brockschmidt, M., Emmes, F., Frohn, F., Fuhs, C., Hensel, J., Otto, C., Plücker, M., Schneider-Kamp, P., Ströder, T., Swiderski, S., Thiemann, R.: Analyzing program termination and complexity automatically with AProVE. J. Autom. Reasoning 58, 3–31 (2017)MathSciNetCrossRefzbMATHGoogle Scholar
  23. 23.
    Gulwani, S.: SPEED: Symbolic complexity bound analysis. In: Bouajjani, A., Maler, O. (eds.) CAV 2009. LNCS, vol. 5643, pp. 51–62. Springer, Berlin, Heidelberg (2009). CrossRefGoogle Scholar
  24. 24.
    Hirokawa, N., Moser, G.: Automated complexity analysis based on the dependency pair method. In: Armando, A., Baumgartner, P., Dowek, G. (eds.) IJCAR 2008. LNCS, vol. 5195, pp. 364–379. Springer, Berlin, Heidelberg (2008). CrossRefGoogle Scholar
  25. 25.
    Hofbauer, D., Lautemann, C.: Termination proofs and the length of derivations. In: Dershowitz, N. (ed.) RTA 1989. LNCS, vol. 355, pp. 167–177. Springer, Heidelberg (1989). doi: 10.1007/3-540-51081-8_107 CrossRefGoogle Scholar
  26. 26.
    Hoffmann, J.: Types with Potential: Polynomial Resource Bounds via Automatic Amortized Analysis. Ph.D. thesis, Ludwig-Maximilians-University Munich (2011)Google Scholar
  27. 27.
    Hoffmann, J., Aehlig, K., Hofmann, M.: Multivariate amortized resource analysis. ACM Trans. Program. Lang. Syst. 34(3), 14 (2012)CrossRefzbMATHGoogle Scholar
  28. 28.
    Hoffmann, J., Das, A., Weng, S.C.: Towards automatic resource bound analysis for OCaml. In: POPL 2017, pp. 359–373 (2017)Google Scholar
  29. 29.
    Hofmann, M., Moser, G.: Multivariate amortised resource analysis for term rewrite systems. In: TLCA 2015, pp. 241–256 (2015)Google Scholar
  30. 30.
    Kapur, D., Narendran, P., Zhang, H.: On sufficient completeness and related properties of term rewriting systems. Acta Informatica 24, 395–415 (1987)MathSciNetCrossRefzbMATHGoogle Scholar
  31. 31.
    Emmanuel, K.: Completeness in data type specifications. In: Caviness, B.F. (ed.) EUROCAL 1985. LNCS, vol. 204, pp. 348–362. Springer, Heidelberg (1985). doi: 10.1007/3-540-15984-3_291 Google Scholar
  32. 32.
    Noschinski, L., Emmes, F., Giesl, J.: Analyzing innermost runtime complexity of term rewriting by dependency pairs. J. Autom. Reasoning 51(1), 27–56 (2013)MathSciNetCrossRefzbMATHGoogle Scholar
  33. 33.
    Serrano, A., López-García, P., Hermenegildo, M.: Resource usage analysis of logic programs via abstract interpretation using sized types. Theory Pract. Logic Program. 14(4–5), 739–754 (2014)CrossRefzbMATHGoogle Scholar
  34. 34.
    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)MathSciNetCrossRefzbMATHGoogle Scholar
  35. 35.
    Wegbreit, B.: Mechanical program analysis. Commun. ACM 18, 528–539 (1975)MathSciNetCrossRefzbMATHGoogle Scholar
  36. 36.
    Zankl, H., Korp, M.: Modular complexity analysis for term rewriting. Logical Meth. Comput. Sci. 10(1), 1–34 (2014)MathSciNetCrossRefzbMATHGoogle Scholar
  37. 37.
    Zantema, H.: Termination of term rewriting: interpretation and type elimination. J. Symbol. Comput. 17(1), 23–50 (1994)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer International Publishing AG 2017

Authors and Affiliations

  • Matthias Naaf
    • 1
  • Florian Frohn
    • 1
  • Marc Brockschmidt
    • 2
  • Carsten Fuhs
    • 3
  • Jürgen Giesl
    • 1
    Email author
  1. 1.LuFG Informatik 2, RWTH Aachen UniversityAachenGermany
  2. 2.Microsoft ResearchCambridgeUK
  3. 3.Birkbeck, University of LondonLondonUK

Personalised recommendations