Skip to main content

Runtime Complexity Analysis of Logically Constrained Rewriting

  • Conference paper
  • First Online:
Logic-Based Program Synthesis and Transformation (LOPSTR 2020)

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

Abstract

Logically constrained rewrite systems (LCTRSs) are a versatile and efficient rewriting formalism that can be used to model programs from various programming paradigms, as well as simplification systems in compilers and SMT solvers. In this paper, we investigate techniques to analyse the worst-case runtime complexity of LCTRSs. For that, we exploit synergies between previously developed decomposition techniques for standard term rewriting by Avanzini et al. in conjunction with alternating time and size bound approximations for integer programs by Brockschmidt et al. and adapt these techniques suitably to LCTRSs. Furthermore, we provide novel modularization techniques to exploit loop bounds from recurrence equations which yield sublinear bounds. We have implemented the method in to test the viability of our method.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 64.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 84.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Non-left-linear rules are rare in practice; and moreover repeated occurrences of a variable x in \(\ell \) can be substituted by a fresh variable \(x'\), adding \(x \approx x'\) to \(\varphi \). Though this implies that x can only be substituted by theory terms in rewrite sequences, for innermost evaluation this is not a limitation.

  2. 2.

    For more precision one could restrict to active variables, as done in [8].

  3. 3.

    The code is available from https://github.com/bytekid/tct-lctrs.

  4. 4.

    See http://cl-informatik.uibk.ac.at/users/swinkler/lctrs_complexity/.

  5. 5.

    See http://www.complang.tuwien.ac.at/cti/bench/.

  6. 6.

    http://termination-portal.org/.

  7. 7.

    https://sv-comp.sosy-lab.org/.

References

  1. Albert, E., Arenas, P., Genaim, S., Puebla, G.: Automatic inference of upper bounds for recurrence relations in cost analysis. In: Alpuente, M., Vidal, G. (eds.) SAS 2008. LNCS, vol. 5079, pp. 221–237. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-69166-2_15

    Chapter  MATH  Google Scholar 

  2. Albert, E., Genaim, S., Masud, A.N.: On the inference of resource usage upper and lower bounds. ACM TOCL 14(3), 22 (2013). https://doi.org/10.1145/2499937.2499943

    Article  MathSciNet  MATH  Google Scholar 

  3. Avanzini, M., Dal Lago, U., Moser, G.: Analysing the complexity of functional programs: higher-order meets first-order. In: Proceedings of the 20th ICFP, pp. 152–164. ACM (2015). https://doi.org/10.1145/2784731.2784753

  4. Avanzini, M., Moser, G.: A combination framework for complexity. Inf. Comput. 248, 22–55 (2016). https://doi.org/10.1016/j.ic.2015.12.007

    Article  MathSciNet  MATH  Google Scholar 

  5. 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, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49674-9_24

    Chapter  Google Scholar 

  6. Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press (1998). https://doi.org/10.1017/CBO9781139172752

  7. Bagnara, R., Mesnard, F.: Eventual linear ranking functions. In: Proceedings of the 15th PPDP, pp. 229–238 (2013). https://doi.org/10.1145/2505879.2505884

  8. Brockschmidt, M., Emmes, F., Falke, S., Fuhs, C., Giesl, J.: Analyzing runtime and size complexity of integer programs. ACM Trans. Program. Lang. Syst. 38(4), 131–1350 (2016). https://doi.org/10.1145/2866575

    Article  Google Scholar 

  9. Chatterjee, K., Fu, H., Goharshady, A.K.: Non-polynomial worst-case analysis of recursive programs. In: Majumdar, R., Kunčak, V. (eds.) CAV 2017. LNCS, vol. 10427, pp. 41–63. Springer, Cham (2017). https://doi.org/10.1007/978-3-319-63390-9_3

    Chapter  Google Scholar 

  10. Ciobâcă, Ş., Lucanu, D.: A coinductive approach to proving reachability properties in logically constrained term rewriting systems. In: Galmiche, D., Schulz, S., Sebastiani, R. (eds.) IJCAR 2018. LNCS (LNAI), vol. 10900, pp. 295–311. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-94205-6_20

    Chapter  Google Scholar 

  11. Clavel, M., et al.: All About Maude - A High-Performance Logical Framework. LNCS, vol. 4350. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-71999-1

    Book  MATH  Google Scholar 

  12. de Moura, L., Bjørner, N.: Z3: an efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-78800-3_24

    Chapter  Google Scholar 

  13. Debray, S.K., López-García, P., Hermenegildo, M.V., Lin, N.: Lower bound cost estimation for logic programs. In: Proceedings of the 14th ILPS, pp. 291–305 (1997). https://doi.org/10.7551/mitpress/4283.003.0035

  14. Dutertre, B.: Yices 2.2. In: Biere, A., Bloem, R. (eds.) CAV 2014. LNCS, vol. 8559, pp. 737–744. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-08867-9_49

    Chapter  Google Scholar 

  15. Falke, S., Kapur, D., Sinz, C.: Termination analysis of C programs using compiler intermediate languages. In: Proceedings of the 22nd RTA, Volume 10 of LIPIcs, pp. 41–50 (2011). https://doi.org/10.4230/LIPIcs.RTA.2011.41

  16. 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). https://doi.org/10.1007/978-3-319-48989-6_16

    Chapter  Google Scholar 

  17. Flores-Montoya, A.: Cost analysis of programs based on the refinement of cost relations. Ph.D. thesis, Universität Darmstadt (2017)

    Google Scholar 

  18. 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

    Chapter  Google Scholar 

  19. Fuhs, C., Giesl, J., Plücker, M., Schneider-Kamp, P., Falke, S.: Proving termination of integer term rewriting. In: Treinen, R. (ed.) RTA 2009. LNCS, vol. 5595, pp. 32–47. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02348-4_3

    Chapter  MATH  Google Scholar 

  20. Fuhs, C., Kop, C., Nishida, N.: Verifying procedural programs via constrained rewriting induction. ACM TOCL 18(2), 14:1–14:50 (2017). https://doi.org/10.1145/3060143

    Article  MathSciNet  MATH  Google Scholar 

  21. Furuichi, Y., Nishida, N., Sakai, M., Kusakari, K., Sakabe, T.: Approach to procedural program verification based on implicit induction of constrained term rewriting systems. IPSJ Trans. Inf. Syst. 1(2), 100–121 (2008). (in Japanese)

    Google Scholar 

  22. Giesl, J., et al.: Analyzing program termination and complexity automatically with AProVE. J. Autom. Reasoning 58(1), 3–31 (2017). https://doi.org/10.1007/s10817-016-9388-y

    Article  MathSciNet  MATH  Google Scholar 

  23. Giesl, J., Ströder, T., Schneider-Kamp, P., Emmes, F., Fuhs, C.: Symbolic evaluation graphs and term rewriting–a general methodology for analyzing logic programs. In: Proceedings of the 14th PPDP, pp. 1–12. ACM Press (2012). https://doi.org/10.1007/978-3-642-38197-3_1

  24. Gulwani, S.: SPEED: symbolic complexity bound analysis. In: Bouajjani, A., Maler, O. (eds.) CAV 2009. LNCS, vol. 5643, pp. 51–62. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02658-4_7

    Chapter  Google Scholar 

  25. Hirokawa, N., Moser, G.: Automated complexity analysis based on the dependency pair method. In: Armando, A., Baumgartner, P., Dowek, G. (eds.) IJCAR 2008. LNCS (LNAI), vol. 5195, pp. 364–379. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-71070-7_32

    Chapter  MATH  Google Scholar 

  26. Hoffmann, J., Das, A., Weng, S.-C.: Towards automatic resource bound analysis for OCaml. In: Proceedings of the 44th POPL, pp. 359–373. ACM (2017). https://doi.org/10.1145/3009837

  27. Kop, C.: Termination of LCTRSs. In: Proceedings of the 13th WST, pp. 59–63 (2013)

    Google Scholar 

  28. Kop, C., Nishida, N.: Term rewriting with logical constraints. In: Fontaine, P., Ringeissen, C., Schmidt, R.A. (eds.) FroCoS 2013. LNCS (LNAI), vol. 8152, pp. 343–358. Springer, Heidelberg (2013). https://doi.org/10.1007/978-3-642-40885-4_24

    Chapter  Google Scholar 

  29. Kop, C., Nishida, N.: Constrained term rewriting tooL. In: Davis, M., Fehnker, A., McIver, A., Voronkov, A. (eds.) LPAR 2015. LNCS, vol. 9450, pp. 549–557. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-48899-7_38

    Chapter  Google Scholar 

  30. Lopes, N., Menendez, D., Nagarakatte, S., Regehr, J.: Practical verification of peephole optimizations with Alive. Commun. ACM 61(2), 84–91 (2018). https://doi.org/10.1145/3166064

    Article  Google Scholar 

  31. Mesnard, F., Neumerkel, U.: Applying static analysis techniques for inferring termination conditions of logic programs. In: Cousot, P. (ed.) SAS 2001. LNCS, vol. 2126, pp. 93–110. Springer, Heidelberg (2001). https://doi.org/10.1007/3-540-47764-0_6

    Chapter  MATH  Google Scholar 

  32. Moser, G., Schaper, M.: From Jinja bytecode to term rewriting: a complexity reflecting transformation. Inf. Comput. 261(Part), 116–143 (2018). https://doi.org/10.1016/j.ic.2018.05.007

    Article  MathSciNet  MATH  Google Scholar 

  33. Nishida, N., Winkler, S.: Loop detection by logically constrained term rewriting. In: Piskac, R., Rümmer, P. (eds.) VSTTE 2018. LNCS, vol. 11294, pp. 309–321. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03592-1_18

    Chapter  Google Scholar 

  34. Noschinski, L., Emmes, F., Giesl, J.: Analyzing innermost runtime complexity of term rewriting by dependency pairs. J. Autom. Reasoning 51(1), 27–56 (2013). https://doi.org/10.1007/s10817-013-9277-6

    Article  MathSciNet  MATH  Google Scholar 

  35. Podelski, A., Rybalchenko, A.: A complete method for the synthesis of linear ranking functions. In: Steffen, B., Levi, G. (eds.) VMCAI 2004. LNCS, vol. 2937, pp. 239–251. Springer, Heidelberg (2004). https://doi.org/10.1007/978-3-540-24622-0_20

    Chapter  Google Scholar 

  36. Serrano, A., López-García, P., Hermenegildo, M.: Resource usage analysis of logic programs via abstract interpretation using sized types. TPLP 14(4–5), 739–754 (2014). https://doi.org/10.1017/S147106841400057X

    Article  MATH  Google Scholar 

  37. TeReSe: Term rewriting systems. In: Cambridge Tracts in Theoretical Computer Science, vol. 55. Cambridge University Press (2003)

    Google Scholar 

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

  39. Wilhelm, R., et al.: The worst-case execution-time problem - overview of methods and survey of tools. ACM Trans. Prog. Lang. Syst. 7(3) (2008). https://doi.org/10.1145/1347375.1347389

  40. Wilhelm, R., Grund, D.: Computation takes time, but how much? Commun. ACM 57(2), 94–103 (2014). https://doi.org/10.1145/2500886

    Article  Google Scholar 

  41. Winkler, S., Middeldorp, A.: Completion for logically constrained rewriting. In Proceedings of the 3rd FSCD, Volume 108 of LIPIcs, pp. 30:1–30:18 (2018). https://doi.org/10.4230/LIPIcs.FSCD.2018.30

  42. Winkler, S., Moser, G.: Runtime complexity analysis of logically constrained rewriting (extended version). http://cl-informatik.uibk.ac.at/users/swinkler/lctrs_complexity/paper.pdf

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Sarah Winkler .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Winkler, S., Moser, G. (2021). Runtime Complexity Analysis of Logically Constrained Rewriting. In: Fernández, M. (eds) Logic-Based Program Synthesis and Transformation. LOPSTR 2020. Lecture Notes in Computer Science(), vol 12561. Springer, Cham. https://doi.org/10.1007/978-3-030-68446-4_2

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-68446-4_2

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-68445-7

  • Online ISBN: 978-3-030-68446-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics