Skip to main content
Log in

Lower Bounds for Runtime Complexity of Term Rewriting

  • Published:
Journal of Automated Reasoning Aims and scope Submit manuscript

Abstract

We present the first approach to deduce lower bounds for (worst-case) runtime complexity of term rewrite systems (TRSs) automatically. Inferring lower runtime bounds is useful to detect bugs and to complement existing methods that compute upper complexity bounds. Our approach is based on two techniques: the induction technique generates suitable families of rewrite sequences and uses induction proofs to find a relation between the length of a rewrite sequence and the size of the first term in the sequence. The loop detection technique searches for “decreasing loops”. Decreasing loops generalize the notion of loops for TRSs, and allow us to detect families of rewrite sequences with linear, exponential, or infinite length. We implemented our approach in the tool AProVE and evaluated it by extensive experiments.

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

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2

Similar content being viewed by others

Notes

  1. This TRS corresponds to the example “Rubio_04/quick.xml” from the Termination Problem Data Base (TPDB) used in the annual Termination Competition [28].

  2. W.l.o.g., here one may rename the variables in every rule. Then it is not a problem if the variable x is used with type \(\tau _1\) in one rule and with type \(\tau _2\) in another rule. Requiring that \(\ell \) and r have the same type ensures that rewriting transforms any well-typed term of type \(\tau \) into a well-typed term of the same type \(\tau \).

  3. For types with several recursive or non-recursive constructors, our heuristic prefers to use those constructors for the generator equations that occur in the left-hand sides of (preferably recursive) rules of the TRS. For a constructor with several recursive argument positions like \({\textsf {node}} \), we examine how often the TRS contains recursive calls in the respective arguments of \({\textsf {node}} \). If there are more recursive calls in the first arguments of \({\textsf {node}} \) than in the second one, then we take the generator equation \(\gamma _{\mathbf{Tree }}(n+1) = {\textsf {node}} (\gamma _{\mathbf{Tree }}(n),{\textsf {leaf}})\) instead of \(\gamma _{\mathbf{Tree }}(n+1) = {\textsf {node}} ({\textsf {leaf}}, \gamma _{\mathbf{Tree }}(n))\).

  4. Termination of \(\rightarrow _{{\mathcal {G}}/{\mathcal {A}}}\) follows from the definition of generator equations (Definition 5), since the argument of \(\gamma _{\tau }\) decreases with each application of an equation and since we excluded mutually recursive types.

  5. In our implementation, the (breadth-first) construction of a narrowing tree is aborted when reaching depth 50, or when the tree has 250 nodes or 40 leaves. Here, we prefer narrowing with previously proven rewrite lemmas \({\mathcal {L}} \) (i.e., narrowing with the rules \({\mathcal {R}} \) is only done for those subterms where no rewrite lemma is applicable). Our implementation generates (at most) one rewrite lemma \(f(\ldots )\rightarrow ^{\ge \mathcal {rt}(\dots )} \ldots \) for every \(f \in \varSigma _{ def }({\mathcal {R}})\).

  6. Rewriting with \(\{r \rightarrow \ell \mid \ell = r \in {\mathcal {G}} _{\mathcal {R}} \}\) terminates as each rewrite step reduces the number of symbols from \(\varSigma _{ con }({\mathcal {R}})\).

  7. We always simplify arithmetic expressions in terms and substitutions, e.g., the substitution \([n_1/0+1]\) in the second sample point is simplified to \([n_1/1]\).

  8. In the constraints (8), n is instantiated by an actual number d. Thus, if \( pol ^{ left }_\pi = c_0 + c_1 \cdot n + \ldots + c_e \cdot n^e\), then \( pol ^{ left }_\pi (d)\) is a linear polynomial over the unknowns \(c_0,\ldots ,c_e\). While solving the constraints (8) only requires linear integer arithmetic, the resulting rewrite lemmas contain polynomials \( pol ^{ left }_\pi \) and \( pol ^{ right }_\pi \) of degree e. Thus, rewriting or narrowing w.r.t. the rewrite lemmas \({\mathcal {L}} \) may require non-linear integer arithmetic.

  9. In our implementation, whenever 5 new depths of a narrowing tree have been computed, we check how many sample points one can generate from the current tree. If we can create at least 3 sample points with different recursion depths, we stop constructing the narrowing tree.

  10. In the second case of Lemma 24, we fix a small inaccuracy from [9, 10] where we inadvertently wrote \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega (b^{\root e \of {n}})\).

  11. For each node t in the resulting narrowing tree, we check if the corresponding rewrite sequence from the root to t is a decreasing loop. As a heuristic, our implementation stops the (breadth-first) construction of narrowing trees if we reach depth 20 or constructed 100 terms.

  12. To simplify the explanation, here we consider the case where \({\mathcal {V}} (C) \cap {\text {dom}} (\theta ) = {\mathcal {V}} (C) \cap {\text {dom}} (\sigma ) = \varnothing \) and \({\text {dom}} (\theta ) \cap {\mathcal {V}} (\mathrm {range}(\sigma )) = \varnothing \). Otherwise, the resulting term is more complicated.

  13. The slides in [18] propose an approach for derivational complexity, where lower bounds are also deduced from induction proofs. However, no formal details are given in [18].

  14. For derivational complexity, one considers arbitrary rewrite sequences that may also start with non-basic terms. Here, every non-empty TRS has a trivial linear lower bound. In contrast, proving linear lower bounds for runtime complexity is not trivial. Thus, lower bounds for derivational complexity are in general unsound for runtime complexity. Therefore, an experimental comparison with tools for derivational complexity is not meaningful.

  15. Our implementation stops as soon as we have rewrite lemmas for all defined function symbols, i.e., we do not backtrack to replace a generated rewrite lemma for a function f by a “better” rewrite lemma for f. Thus if we run into a timeout, then we did not manage to obtain rewrite lemmas for all defined function symbols.

  16. To see why \({\mathcal {V}} (x\,\theta ') \cap {\text {dom}} (\theta ') = \{ x \}\) holds, note that we have \(x \in {\text {dom}} (\theta ')\) by (13). Since (a) holds for the pumping substitution of any decreasing loop, it also holds for \(\theta '\). Hence, \(x \in {\text {dom}} (\theta ')\) implies \({\mathcal {V}} (x\,\theta ') \cap {\text {dom}} (\theta ') = \{ x \}\).

  17. \((a_1,\ldots ,a_n) \sqsubset (b_1 ,\ldots ,b_m)\) iff \(n = 0\) and \(m > 0\) or \(a_1 < b_1\) or \(a_1 = b_1\) and \((a_2,\ldots ,a_n) \sqsubset (b_2,\ldots ,b_m)\).

References

  1. Albert, E., Genaim, S., Masud, A.N.: On the inference of resource usage upper and lower bounds. ACM Trans. Comput. Log. 14(3), 22 (2013)

  2. AProVE. http://aprove.informatik.rwth-aachen.de/eval/lowerbounds-journal/

  3. Avanzini, M., Moser, G.: A combination framework for complexity. In: Proceedings of RTA ’13. LIPIcs 21, pp. 55–70 (2013)

  4. Avanzini, M., Moser, G., Schaper, M.: \({\sf TcT}\): Tyrolean complexity tool. In: Proceedings of TACAS ’16. LNCS 9636, pp. 407–423 (2016)

  5. Baader, F., Nipkow, T.: Term Rewriting and All That. Cambridge University Press, Cambridge (1998)

    Book  MATH  Google Scholar 

  6. Boyer, Robert S., Moore, J.S.: A Computational Logic. Academic Press, Cambridge (1979)

    MATH  Google Scholar 

  7. de Moura, L., Bjørner, N.: Z3: An efficient SMT solver. In: Proceedings of TACAS ’08. LNCS 4963, pp. 337–340 (2008)

  8. Emmes, F., Enger, T., Giesl, J.: Proving non-looping non-termination automatically. In: Proceedings of IJCAR ’12. LNAI 7364, pp. 225–240 (2012)

  9. Frohn, F., Giesl, J., Hensel, J., Aschermann, C., Ströder, T.: Inferring lower bounds for runtime complexity. In: Proceedings of RTA ’15. LIPIcs 36, pp. 334–349 (2015)

  10. Frohn, F., Naaf, M., Hensel, J., Brockschmidt, M., Giesl, J.: Lower runtime bounds for integer programs. In: Proceedings of IJCAR ’16. LNAI 9706, pp. 550–567 (2016)

  11. Fuhs, C., Giesl, J., Parting, M., Schneider-Kamp, P., Swiderski, S.: Proving termination by dependency pairs and inductive theorem proving. J. Autom. Reason. 47(2), 133–160 (2011)

    Article  MathSciNet  MATH  Google Scholar 

  12. Geser, A., Hofbauer, D., Waldmann, J.: Termination proofs for string rewriting systems via inverse match-bounds. J. Autom. Reason. 34(4), 365–385 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  13. Giesl, J., Thiemann, R., Schneider-Kamp, P.: Proving and disproving termination of higher-order functions. In: Proceedings of FroCoS ’05. LNAI 3717, pp. 216–231 (2005)

  14. Giesl, J., Raffelsieper, M., Schneider-Kamp, P., Swiderski, S., Thiemann, R.: Automated termination proofs for Haskell by term rewriting. ACM Trans. Program. Lang. Syst. 33(2), 7 (2011)

  15. 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 \({{\sf AProVE}}\). J. Autom. Reason (to appear). Preliminary version appeared in Proceedings of IJCAR ’14. LNAI 8562, pp. 184–191 (2014)

  16. Hirokawa, N., Moser, G.: Automated complexity analysis based on the dependency pair method. In: Proceedings of IJCAR ’08. LNAI 5195, pp. 364–379 (2008)

  17. Hofbauer, D., Lautemann, C.: Termination proofs and the length of derivations. In: Proceedings of RTA ’89. LNCS 355, pp. 167–177 (1989)

  18. Hofbauer, D., Waldmann, J.: Constructing lower bounds on the derivational complexity of rewrite systems. Slides of a Talk at the 2nd Workshop on Proof Theory and Rewriting. http://www.imn.htwk-leipzig.de/~waldmann/talk/10/pr/main.pdf (2010)

  19. Hofmann, M., Moser, G.: Amortised resource analysis and typed polynomial interpretations. In: Proceedings of RTA-TLCA ’14. LNCS 8560, pp. 272–286 (2014)

  20. Hooper, P.K.: The undecidability of the Turing machine immortality problem. J. Symb. Log. 31(2), 219–234 (1966)

    Article  MathSciNet  MATH  Google Scholar 

  21. Knuth, D.: Johann Faulhaber and sums of powers. Math. Comput. 61(203), 277–294 (1993)

    Article  MathSciNet  MATH  Google Scholar 

  22. Lynch, C., Morawska, B.: Basic syntactic mutation. In: Proceedings of CADE ’18. LNAI 2392, pp. 471–485 (2002)

  23. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

  24. Moser, G., Schnabl, A.: The derivational complexity induced by the dependency pair method. Log. Methods Comput. Sci. 7(3:01), 1–38 (2011)

  25. Noschinski, L., Emmes, F., Giesl, J.: Analyzing innermost runtime complexity of term rewriting by dependency pairs. J. Autom. Reason. 51(1), 27–56 (2013)

    Article  MathSciNet  MATH  Google Scholar 

  26. Otto, C., Brockschmidt, M., von Essen, C., Giesl, J.: Automated termination analysis of Java Bytecode by term rewriting. In: Proceedings of RTA ’10. LIPIcs 6, pp. 259–276 (2010)

  27. Payet, É.: Loop detection in term rewriting using the eliminating unfoldings. Theor. Comput. Sci. 403(2–3), 307–327 (2008)

    Article  MathSciNet  MATH  Google Scholar 

  28. Termination Comp.http://termination-portal.org/wiki/Termination_Competition

  29. Waldmann, J.: Matchbox: A tool for match-bounded string rewriting. In: Proceedings of RTA ’04. LNCS 3091, pp. 85–94 (2004)

  30. Waldmann, J.: Automatic termination. In: Proceedings of RTA ’09. LNCS 5595, pp. 1–16 (2009)

  31. Zankl, H., Sternagel, C., Hofbauer, D., Middeldorp, A.: Finding and certifying loops. In: Proceedings of SOFSEM ’10. LNCS 5901, pp. 755–766 (2010)

  32. Zankl, H., Korp, M.: Modular complexity analysis for term rewriting. Log. Methods Comput. Sci. 10(1:19), 1–33 (2014)

  33. Zantema, H.: Termination of term rewriting: interpretation and type elimination. J. Symbol. Comput. 17(1), 23–50 (1994)

    Article  MathSciNet  MATH  Google Scholar 

  34. Zantema, H.: Termination of string rewriting proved automatically. J. Autom. Reason. 34(2), 105–139 (2005)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Acknowledgements

We thank Fabian Emmes for important initial ideas for the induction technique and Chris Lynch, René Thiemann, and Carsten Fuhs for helpful suggestions.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jürgen Giesl.

Additional information

Supported by the DFG Grant GI 274/6-1 and the Air Force Research Laboratory (AFRL).

Appendices

Appendix 1: Detecting Innermost Decreasing Loops to Infer Lower Bounds

So far, we used loop detection to prove lower bounds for runtime complexity of full rewriting. However, TRSs resulting from the translation of programs typically have to be evaluated with an innermost strategy (e.g., [14, 26]). As usual, a rewrite step is innermost (denoted \(s \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}} t\)) if the reduced subterm of s does not have redexes as proper subterms. Hence, we now show how to adapt loop detection to innermost runtime complexity. (A corresponding adaption of the induction technique from Sect. 3 was already presented in [9].) To do so, we introduce innermost decreasing loops, which are like decreasing loops, but here only non-overlapping rewrite sequences are considered.

Definition 44

(Non-overlapping rewriting) For a TRS \({\mathcal {R}} \), we say that a term s reduces to t by non-overlapping rewriting (denoted \(s \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } t\)) iff there is a \(\pi \in {\text {pos}} (s)\), a substitution \(\sigma \), and a rule \(\ell \rightarrow r \in {\mathcal {R}} \) such that \(s|_\pi = \ell \sigma \), \(t = s[r \sigma ]_\pi \), and no proper non-variable subterm of \(\ell \sigma \) unifies with any (variable-renamed) left-hand side of a rule in \({\mathcal {R}} \).

Clearly, any non-overlapping rewrite step is an innermost step (i.e., \(s \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } t\) implies \(s \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } t\)), but not vice versa. For innermost decreasing loops, instead of reductions \(\ell \rightarrow ^+_{\mathcal {R}} C[r]\) we now consider reductions of the form \(\ell \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\).

Definition 45

(Innermost decreasing loop) Let \(\ell \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\) for some linear basic term \(\ell \) and some \(r \notin {\mathcal {V}} \). We call \(\ell \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } _{\mathcal {R}} ^+ C[r]\) an innermost decreasing loop if there are pairwise different variables \(x_1,\dots ,x_m\) (with \(m \ge 0\)) and positions \(\pi _1,\ldots ,\pi _m\) with \(x_i=\ell |_{\pi _i}\) for all \(1 \le i \le m\) such that

figure f

To find non-overlapping rewrite sequences, non-overlapping narrowing can be used instead of narrowing. Similar to non-overlapping rewriting, non-overlapping narrowing does not allow reduction steps where a proper non-variable subterm of the redex unifies with a (variable-renamed) left-hand side of a rule.

The following theorem shows that each innermost decreasing loop gives rise to a linear lower bound for innermost runtime complexity. Here, the innermost runtime complexity \(\mathrm {irc}_{{\mathcal {R}}}\) is defined analogous to \(\mathrm {rc}_{\mathcal {R}} \), i.e., \(\mathrm {irc}_{\mathcal {R}} (n) = \sup \{\, {\mathrm {dh}(t,\overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}})} \mid t \in {{\mathcal {T}} _B}, |t| \le n \,\}\).

Theorem 46

(Linear lower bounds for \(\mathrm {irc}\) by loop detection) If a TRS \({\mathcal {R}} \) has an innermost decreasing loop, then we have \(\mathrm {irc}_{{\mathcal {R}}}(n) \in \varOmega (n)\).

The following example shows that we indeed have to require \(\ell \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\) instead of just \(\ell \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\) in the definition of innermost decreasing loops. The essential property of non-overlapping rewriting is that if a substitution \(\delta \) instantiates all variables with normal forms, then \(s \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } t\) still implies \(s \delta \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } t \delta \). In contrast, \(s \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } t\) does not imply \(s \delta \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } t \delta \).

Example 47

(Non-overlapping rewriting) Consider the TRS \({\mathcal {R}} \) with the rules \({\textsf {f}} (y) \rightarrow {\textsf {h}} ({\textsf {g}} (y))\), \({\textsf {h}} ({\textsf {g}} (y)) \rightarrow {\textsf {f}} ({\textsf {g}} (y))\), and \({\textsf {g}} ({\textsf {g}} (y)) \rightarrow y\). We clearly have \({\textsf {f}} (y) \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} {\textsf {f}} ({\textsf {g}} (y))\), but . If we replaced “\(\ell \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\)” by “\(\ell \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} C[r]\)” in Definition 45, then \({\textsf {f}} (y) \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} {\textsf {f}} ({\textsf {g}} (y))\) would be an innermost decreasing loop. However, all innermost rewrite sequences that start with basic terms have at most length 4 for this TRS, i.e., \(\mathrm {irc}_{\mathcal {R}} (n) \in \varOmega (1)\). The problem is that the rewrite sequence \({\textsf {f}} (y) \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} {\textsf {f}} ({\textsf {g}} (y))\) does not remain an innermost sequence anymore if one instantiates y with the normal form \({\textsf {g}} (y)\), i.e., we have .

Based on Definition 45 and Theorem 46, it is straightforward to adapt the concept of compatible decreasing loops in Definition 36 and Theorem 37 to innermost rewriting.

Appendix 2: Proofs

Theorem 14

(Proving conjectures) Let \({\mathcal {R}} \), s, t, and \({\overline{n}}\) be as in Definition 6 and let \(n \in {\mathcal {V}} (s)\). If \(s[n/0] \; \rightharpoonup ^* \; t[n/0]\) and \(s[n/n+1] \; \rightharpoonup ^*_{{\text {IH}},n} \; t[n/n+1]\), where \({\text {IH}} \) is the rule \(s \rightarrow t\), then the conjecture \(s \rightarrow ^{*} t\) is valid for \({\mathcal {R}} \).

Proof

The theorem is implied by the stronger Theorem 18, which we prove instead below. \(\square \)

To prove Theorem 18, we need two auxiliary lemmas. Lemma 48 shows that \(\rightharpoonup \) is closed under instantiations of variables with natural numbers.

Lemma 48

(Stability of \(\rightharpoonup \) and \(\rightharpoonup _{\ell \rightarrow r,n}\)) Let \({\mathcal {R}} \) be a TRS, let \(\ell , r, s, t\) be terms where s only contains variables of type \(\mathbb {N} \), and let \(\mu : {\mathcal {V}} (s) \rightarrow \mathbb {N} \). Then we have:

  1. (a)

    \(s \rightharpoonup t\) implies \(s\mu \rightharpoonup t\mu \)

  2. (b)

    \(s \rightharpoonup _{\ell \rightarrow r,n} t\) implies that there is a substitution \(\sigma : {\mathcal {V}} (\ell ) \rightarrow \mathbb {N} \) with \(n \sigma = n \mu \) and \(m\sigma \ge m \mu \) for all \(m \in {\mathcal {V}} (\ell ) {\setminus } \{ n \}\) such that \(s\mu \rightharpoonup _{\ell \sigma \rightarrow r\sigma ,n} t\mu \).

Proof

Since rewriting is closed under substitutions, we immediately have (a). For (b), let \(s \rightharpoonup _{\ell \rightarrow r,n} t\). If we also have \(s \rightharpoonup t\), then the claim follows from (a). Otherwise, we have \(s \mapsto _{\ell \rightarrow r,n} t\). Hence, there is a term \(s'\), an increasing substitution \(\sigma '\), and \(\pi \in {\text {pos}} (s')\) such that \(s \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} s'\), \(s'|_\pi = \ell \sigma '\), and \(s'[r\sigma ']_\pi \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} t\), where \(n \sigma ' = n\). Let \(\sigma = \sigma '\mu \). Then \(s\mu \mapsto _{\ell \sigma \rightarrow r\sigma ,n} t\mu \), since \(s\mu \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} s'\mu \), \(s'\mu |_\pi = s'|_\pi \mu = \ell \sigma '\mu = \ell \sigma \), and \(s'\mu [r\sigma ]_\pi = s'\mu [r\sigma '\mu ]_\pi = (s'[r\sigma ']_\pi )\mu \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} t\mu \). Moreover, \(n \sigma = n \sigma '\mu = n\mu \) and as \(\sigma '\) is increasing, \(m\sigma ' \ge m\) implies \(m\sigma = m \sigma '\mu \ge m \mu \). \(\square \)

Lemma 49 infers information on rewrite sequences with \(\rightarrow _{\mathcal {R}} \) from the relation \(\rightharpoonup \). Here, we again regard each rule \(\ell \rightarrow r \in {\mathcal {R}} \) as a rewrite lemma \(\ell \rightarrow ^{\ge 1} r\).

Lemma 49

(From \(\rightharpoonup \) to \(\rightarrow _{\mathcal {R}} \)) Let \({\mathcal {R}} \) be a TRS, let \(\ell , r\) be terms with \({\text {root}} (\ell ) \in \varSigma _{ def }({\mathcal {R}})\), and let st be ground terms. Moreover, let \({\mathcal {R}} \), \(\ell \rightarrow r\), and s be well typed w.r.t. \(\varSigma '\) and \({\mathcal {V}} '\), where s does not have the type \(\mathbb {N} \).

  1. (a)

    If \(s \rightharpoonup t\) and this reduction is done using \(\ell \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} r \in {\mathcal {R}} \cup {\mathcal {L}} \) and the substitution \(\sigma \), then we have \(s\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\mathcal {R}} ^{\ge \mathcal {rt}({\overline{n}}\sigma )} t\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

  2. (b)

    If \(s \mapsto _{\ell \rightarrow r,n} t\) and \(\ell , r\) are ground terms, then \(s\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\{\ell \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \, \rightarrow \, r\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\}} t\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

Proof

In (a), we have \(s \rightharpoonup t\), i.e., there is a term \(s'\), a substitution \(\sigma \), and \(\pi \in {\text {pos}} (s')\) such that \(s \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} s'\), \(s'|_\pi = \ell \sigma \), and \(s'[r\sigma ]_\pi \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} t\).

Note that \(s \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} s'\) implies \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) as \(\rightarrow _{{\mathcal {G}}/{\mathcal {A}}}\) is terminating and confluent modulo \({\mathcal {A}} \). Again, \(\rightarrow _{{\mathcal {G}}/{\mathcal {A}}}\) is the rewrite relation resulting from orienting \({\mathcal {G}} \) from left to right where rewriting is performed modulo \({\mathcal {A}} \) (i.e., modulo arithmetic). As s is a ground term that does not have the type \(\mathbb {N} \), \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) does not contain subterms of type \(\mathbb {N} \) and therefore, \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) implies \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

Since \(\ell \) matches \(s'|_\pi \), \(s'\) has a symbol from \(\varSigma _{ def }({\mathcal {R}})\) at position \(\pi \). Hence, there are no generator symbols and no subterms of type \(\mathbb {N} \) in \(s'\) on or above the position \(\pi \). Therefore, \({\mathcal {G}} \) and \({\mathcal {A}} \) cannot be applied on or above \(\pi \). This implies \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[(s'|_\pi )\downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi \).

If \(\ell \rightarrow r \in {\mathcal {L}} \), then Definition 7 implies that \(\ell \sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\sigma )}_{\mathcal {R}} r\sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Hence, \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = {s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi } \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\sigma )}_{\mathcal {R}} s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[r\sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi = (s'[r\sigma ]_\pi )\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). As \(t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) does not contain subterms of type \(\mathbb {N} \), we have \((s'[r\sigma ]_\pi )\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

If \(\ell \rightarrow r \in {\mathcal {R}} \), then \(\ell \) does not contain generator function symbols or subterms of type \(\mathbb {N} \). Hence, we have \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \sigma ']_\pi \) for the substitution where \(x\sigma ' = x\sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) for all \(x \in {\mathcal {V}} \). Then \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \sigma ']_\pi \rightarrow _{\mathcal {R}} s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[r\sigma ']_\pi = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[r\sigma \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi = (s'[r\sigma ]_\pi )\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

In case (b), \(s \mapsto _{\ell \rightarrow r,n} t\) implies that there is a term \(s'\) and a \(\pi \in {\text {pos}} (s')\) such that \(s \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} s'\), \(s'|_\pi = \ell \), and \(s'[r]_\pi \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} t\), since \(\ell ,r\) are ground. As in case (a), since s is a ground term that does not have the type \(\mathbb {N} \), we can conclude \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Moreover, \(s'\) again has a defined symbol at position \(\pi \), since \({\text {root}} (\ell ) \in \varSigma _{ def }({\mathcal {R}})\). As in (a), this implies \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi \). Thus, we obtain \(s\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[\ell \downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi \rightarrow _{\{\ell \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \, \rightarrow \, r\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\}} s'\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[r\downarrow _{{\mathcal {G}}/{\mathcal {A}}}]_\pi = s'[r]_\pi \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Since \(\ell \rightarrow r\) is well typed and \(\ell \) does not have type \(\mathbb {N} \), \(t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) does not contain subterms of type \(\mathbb {N} \). Hence, we have \(s'[r]_\pi \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\), which proves (b). \(\square \)

Now we can prove Theorem 18 (on proving conjectures by induction and on inferring complexity bounds from this proof).

Theorem 18

(Explicit runtime of rewrite lemmas) Let \(s \rightarrow ^{*} t\) be a conjecture with an induction proof as in Theorem 14, where \(\mathcal {ih}, \mathcal {ib}\), and \(\mathcal {is}\) are as in Definition 17. Then \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) is a rewrite lemma, where \(\mathcal {rt}({\overline{n}})= \mathcal {ih}^n \cdot \mathcal {ib}({\widetilde{n}}) \; + \; \sum \nolimits _{i=0}^{n-1} \mathcal {ih}^{n-1-i} \cdot \mathcal {is}({\overline{n}}[n/i])\).

Proof

Let \(\mathcal {rt}\) be defined by the recurrence Eq. (9). We show that \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) is a rewrite lemma. More precisely, for any \(\mu : {\mathcal {V}} (s) \rightarrow \mathbb {N} \) we prove \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\mu )}_{\mathcal {R}} \; t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) by induction on \(n\mu \).

In the induction base, we have \(n\mu = 0\). We first regard the case \(s[n/0] \equiv _{{\mathcal {G}}/{\mathcal {A}}} t[n/0]\). This implies \(s\mu = s[n/0]\mu \equiv _{{\mathcal {G}}/{\mathcal {A}}} t[n/0]\mu = t\mu \). Since \(\rightarrow _{{\mathcal {G}}/{\mathcal {A}}}\) is terminating and confluent modulo \({\mathcal {A}} \), \(s\mu \equiv _{{\mathcal {G}}/{\mathcal {A}}} t\mu \) implies \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Since \(s\mu \) and \(t\mu \) are ground terms that do not have the type \(\mathbb {N} \), \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) and \(t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) do not contain any subterms of type \(\mathbb {N} \). Hence, \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\; \equiv _{\mathcal {A}} t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) implies \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \;= t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\), which proves the desired claim, since \(\mathcal {ib}({\widetilde{n}}\mu ) = 0\) and thus \(\mathcal {rt}({\overline{n}}\mu ) = 0\).

Now we regard the case \(s[n/0] = u_1 \rightharpoonup \ldots \rightharpoonup u_{b+1} = t[n/0]\) for \(b\ge 1\). By Lemma 48 (a), \(\rightharpoonup \) is stable and thus, \(s \mu = s[n/0]\mu = u_1\mu \rightharpoonup \ldots \rightharpoonup u_{b+1}\mu = t[n/0]\mu = t\mu \). When regarding rewrite rules also as rewrite lemmas, Lemma 49 (a) implies \(s \mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = u_1\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\mathcal {R}} ^{\ge \mathcal {rt}({\overline{y}}_1\sigma _1\mu )} \ldots \rightarrow _{\mathcal {R}} ^{\ge \mathcal {rt}({\overline{y}}_b\sigma _b\mu )} u_{b+1}\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). This means \(s \mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\mathcal {R}} ^{\ge \mathcal {ib}({\widetilde{n}}\mu )} t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) or in other words, \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\mu )}_{\mathcal {R}} \; t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\).

In the induction step, we have \(n\mu > 0\). Let \(\mu ': {\mathcal {V}} (s) \rightarrow \mathbb {N} \) where \(\mu '\) is like \(\mu \) for all \({\mathcal {V}} (s) {\setminus } \{ n \}\) and \(n\mu ' = n\mu - 1\). If \(s[n/n+1] \equiv _{{\mathcal {G}}/{\mathcal {A}}} t[n/n+1]\), we obtain \(s\mu \equiv _{\mathcal {A}} s[n/n+1]\mu ' \equiv _{{\mathcal {G}}/{\mathcal {A}}} t[n/n+1]\mu ' \equiv _{\mathcal {A}} t\mu \). Thus, we again have \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \equiv _{\mathcal {A}} t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) which implies \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). This proves the desired claim, since \(\mathcal {ih}=0\) and \(\mathcal {is}({\overline{n}}\mu ') = 0\) and thus \(\mathcal {rt}({\overline{n}}\mu ) = \mathcal {rt}({\overline{n}}[n/n+1]\mu ') = 0\).

Now we regard the case \(s[n/n+1] = v_1 \rightharpoonup _{{\text {IH}},n} \ldots \rightharpoonup _{{\text {IH}},n} v_{k+1} = t[n/n+1]\) for \(k\ge 1\). By Lemma 48 (b), we obtain \(s[n/n+1] \mu ' = v_1\mu ' \rightharpoonup _{{\text {IH}} \sigma _1,n} \ldots \rightharpoonup _{{\text {IH}} \sigma _k,n} v_{k+1}\mu ' = t[n/n+1]\mu '\) for substitutions \(\sigma _j\) such that \({\text {IH}} \,\sigma _j\) is ground and such that \(n \sigma _j = n \mu '\) and \(m\sigma _j \ge m \mu '\) for all \(m \in {\mathcal {V}} (s) {\setminus } \{ n \}\).

If \(v_j\mu ' \rightharpoonup v_{j+1}\mu '\), then Lemma 49 (a) implies \(v_j\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\mathcal {R}} ^{\ge \mathcal {rt}'_j({\overline{z}}_j\theta _j\mu ')} v_{j+1}\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Otherwise, if \(v_j\mu ' \mapsto _{{\text {IH}} \sigma _j,n} v_{j+1}\mu '\), then by Lemma 49 (b) we have \(v_j\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\{s\sigma _j\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \, \rightarrow \, t\sigma _j\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\}} v_{j+1}\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). The induction hypothesis implies \(s\sigma _j\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\sigma _j)}_{\mathcal {R}} \; t\sigma _j\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\), since \(n\sigma _j = n \mu ' = n\mu - 1\). As \({\overline{n}}\sigma _j \ge {\overline{n}}\mu '\) and as \(\mathcal {rt}\) is weakly monotonic, this implies \(s\sigma _j\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\mu ')}_{\mathcal {R}} \; t\sigma _j\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Hence, from \(v_j\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\{s\sigma _j\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \, \rightarrow \, t\sigma _j\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\}} v_{j+1}\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) we can infer \(v_j\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}\mu ')}_{\mathcal {R}} v_{j+1}\mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). Since there are \(\mathcal {ih}\) many of these steps, we get \(s[n/n+1] \mu '\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow _{\mathcal {R}} ^{\ge \mathcal {ih}\cdot \mathcal {rt}({\overline{n}}\mu ') + \mathcal {is}({\overline{n}}\mu ')} t[n/n+1]\mu '\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) or in other words, \(s[n/n+1]\mu '\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^{\ge \mathcal {rt}({\overline{n}}[n/n+1]\mu ')}_{\mathcal {R}} \; t[n/n+1]\mu '\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). This proves the desired claim, since \(s\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = s[n/n+1]\mu '\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\), \(t\mu \downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; = t[n/n+1]\mu '\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\), and \(\mathcal {rt}({\overline{n}}\mu ) = \mathcal {rt}({\overline{n}}[n/n+1]\mu ')\).

Finally we show by induction on n that the closed form for \(\mathcal {rt}({\overline{n}})\) in Theorem 18 satisfies the recurrence Eq. (9). We obtain \(\mathcal {rt}({\overline{n}}[n/0])= \mathcal {ih}^0 \cdot \mathcal {ib}({\widetilde{n}}) = \mathcal {ib}({\widetilde{n}})\), as required in (9). Similarly, \(\mathcal {rt}({\overline{n}}[n/n+1])= \mathcal {ih}^{n+1} \cdot \mathcal {ib}({\widetilde{n}}) \; + \; \sum \nolimits _{i=0}^{n} \mathcal {ih}^{n-i} \cdot \mathcal {is}({\overline{n}}[n/i]) = \mathcal {ih}\cdot (\, \mathcal {ih}^{n} \cdot \mathcal {ib}({\widetilde{n}}) \; + \; \sum \nolimits _{i=0}^{n-1} \mathcal {ih}^{n-1-i} \cdot \mathcal {is}({\overline{n}}[n/i]) \,) + \mathcal {is}({\overline{n}}) = \mathcal {ih}\cdot \mathcal {rt}({\overline{n}}) + \mathcal {is}({\overline{n}})\), as in (9). \(\square \)

Corollary 21

(Asymptotic runtime of rewrite lemmas) Let \(s \rightarrow ^* t\) be a valid conjecture with \(\mathcal {ih}\), \(\mathcal {ib}\), and \(\mathcal {is}\) as in Definition 17. Moreover, let \(\mathcal {ib}\) and \(\mathcal {is}\) be polynomials of degree \(d_\mathcal {ib}\) and \(d_\mathcal {is}\), respectively. Then there is a rewrite lemma \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) such that

  • \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^{\max \{d_\mathcal {ib},d_\mathcal {is}\}})\), if \(\mathcal {ih}=0\)

  • \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^{\max \{d_\mathcal {ib},d_\mathcal {is}+1\}})\), if \(\mathcal {ih}= 1\)

  • \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (\mathcal {ih}^n)\), if \(\mathcal {ih}> 1\)

Proof

Let \(\mathcal {rt}\) be defined as in Theorem 18. As explained in the text, if \(\mathcal {ih}=0\) then Corollary 21 follows from (9), and if \(\mathcal {ih}>1\), we have \(\mathcal {rt}({\overline{n}}) \ge \frac{\mathcal {ih}^n-1}{\mathcal {ih}-1}\) and thus, \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (\mathcal {ih}^n)\).

Finally if \(\mathcal {ih}=1\), then \(\mathcal {rt}({\overline{n}})\) has the form (10). Hence, we obtain

$$\begin{aligned} \begin{array}{rcll} \mathrm {degree}(\mathcal {rt}) &{}=&{} \max \{ d_\mathcal {ib}, \mathrm {degree}( t_k \cdot \sum \nolimits _{i=0}^{n-1}i^k ) \mid 0 \le k \le d_\mathcal {is}\} &{} \text {by (10)}\\ &{}=&{} \max \{d_\mathcal {ib}, \mathrm {degree}( t_k ) + k + 1 \mid 0 \le k \le d_\mathcal {is}\} &{} \text {by Faulhaber's formula}\\ &{}=&{} \max \{d_\mathcal {ib},d_\mathcal {is}+1\}, &{} \end{array} \end{aligned}$$

as \(d_\mathcal {is}= \max \{ \mathrm {degree}(t_k n^k) \mid 0 \le k \le d_\mathcal {is}\} = \max \{ \mathrm {degree}(t_k) + k \mid 0 \le k \le d_\mathcal {is}\}\). \(\square \)

Theorem 23

(Explicit bounds for \(\mathrm {rc}_{\mathcal {R}} \)) Let \(s \rightarrow ^{\ge \mathcal {rt}(n_1,\dots ,n_m)} t\) be a rewrite lemma for \({\mathcal {R}} \), let \(\mathcal {sz}:\mathbb {N} ^m \rightarrow \mathbb {N} \) such that \(\mathcal {sz}(b_1,\dots ,b_m)\) is the size of \(s[n_1/b_1,\dots ,n_m/b_m]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) for all \(b_1,\ldots ,b_m \in \mathbb {N} \), and let \(\mathcal {sz}_{\mathbb {N}}\) be injective, i.e., \(\mathcal {sz}^{-1}_\mathbb {N} \) exists. Then for all \(n \in \mathbb {N} \) with \(n \ge \min (\mathrm {img}(\mathcal {sz}_\mathbb {N}))\), \(\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor \) is a lower bound for \(\mathrm {rc}_{\mathcal {R}} \), i.e., \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor )(n) \le \mathrm {rc}_{\mathcal {R}} (n)\).

Proof

If \(n \ge \min (\mathrm {img}(\mathcal {sz}_\mathbb {N}))\), then there is a maximal \(n' \le n\) such that \(n' \in \mathrm {img}(\mathcal {sz}_\mathbb {N})\). Thus, \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n) = \mathcal {sz}_\mathbb {N} ^{-1}(n')\). By the rewrite lemma \(s \rightarrow ^{\ge \mathcal {rt}(n_1,\dots ,n_m)} t\), \(s[n_1/\mathcal {sz}_\mathbb {N} ^{-1}(n'), \ldots , n_m/\mathcal {sz}_\mathbb {N} ^{-1}(n')]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) has an evaluation of at least length \(\mathcal {rt}(\mathcal {sz}_\mathbb {N} ^{-1}(n'),\ldots , \mathcal {sz}_\mathbb {N} ^{-1}(n')) = \mathcal {rt}(\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n),\dots ,\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n)) = (\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n)\). The size of the start term \(s[n_1/\mathcal {sz}_\mathbb {N} ^{-1}(n'), \ldots , n_m/\mathcal {sz}_\mathbb {N} ^{-1}(n')]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) is \(\mathcal {sz}(\mathcal {sz}_\mathbb {N} ^{-1}(n'), \ldots , \mathcal {sz}_\mathbb {N} ^{-1}(n')) = \mathcal {sz}_\mathbb {N} (\mathcal {sz}_\mathbb {N} ^{-1}(n')) = n'\). As s has a defined symbol only at the root, \(s[n_1/\mathcal {sz}_\mathbb {N} ^{-1}(n'),\ldots , n_m/\mathcal {sz}_\mathbb {N} ^{-1}(n')]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\) is a basic term. As this basic term has the size \(n' \le n\) and its evaluation has at least the length \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n)\), this implies \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \le \mathrm {rc}_{\mathcal {R}} (n)\). \(\square \)

Lemma 24

(Asymptotic bounds for function composition) Let \(\mathcal {rt}_\mathbb {N},\mathcal {sz}_\mathbb {N}: \mathbb {N} \rightarrow \mathbb {N} \) where \(\mathcal {sz}_\mathbb {N} \in \mathcal {O}(n^e)\) for some \(e \ge 1\) and \(\mathcal {sz}_\mathbb {N} \) is strictly monotonically increasing.

  • If \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^d)\) with \(d \ge 0\), then \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega (n^{\frac{d}{e}})\).

  • If \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (b^n)\) with \(b \ge 1\), then \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in b^{\varOmega (\root e \of {n})}\).

Proof

To prove the lemma, we first have to prove that

$$\begin{aligned} \lfloor h \rfloor (n) \in \{\lceil h \rceil (n), \lceil h \rceil (n) - 1\} \quad \text{ for } \text{ all } n \in \mathbb {N} \end{aligned}$$
(11)

holds for any infinite subset M of \(\mathbb {N} \) and any function \(h: M \rightarrow \mathbb {N} \) that is strictly monotonically increasing and surjective. Here, \(\lceil h \rceil (n): \mathbb {N} \rightarrow \mathbb {N} \) is defined by \(\lceil h \rceil (n) = h(\min \{n' \mid n' \in M, n' \ge n\})\). Note that infinity of h’s domain M ensures that there is always an \(n' \in M\) with \(n' \ge n\).

To prove (11), let \(n \in \mathbb {N} \). If \(n \in M\), then \(\lfloor h\rfloor (n) = \lceil h \rceil (n)\).

If \(n \notin M\) and \(n < \min (M)\), then \(\lfloor h \rfloor (n) = 0\). Moreover, since h is strictly monotonically increasing and surjective, we also have \(\lceil h \rceil (n) = 0\).

If \(n \notin M\) and \(n > \min (M)\), let \(n' = \max \{n' \mid n' \in M, n' < n\}\) and \(n'' = \min \{n'' \mid n'' \in M, n'' > n\}\). Thus, \(n'< n < n''\). Strict monotonicity of h implies \(h(n') < h(n'')\). Assume that \(h(n'') - h (n') > 1\). Then by surjectivity of h, there is an \({\hat{n}} \in M\) with \(h({\hat{n}}) = h (n') + 1\) and thus \(h(n')< h({\hat{n}}) < h(n'')\). By strict monotonicity of h, we obtain \(n'< {\hat{n}} < n''\). Since \(n \notin M\) and \({\hat{n}} \in M\) implies \(n \ne {\hat{n}}\), we either have \({\hat{n}} < n\) which contradicts \(n' = \max \{n' \mid n' \in M, n' < n\}\) or \({\hat{n}} > n\) which contradicts \(n'' = \min \{n'' \mid n'' \in M, n'' > n\}\). Hence, \(\lfloor h \rfloor (n) = h(n') = h(n'') - 1 = \lceil h \rceil (n) - 1\), which proves (11).

Now we prove Lemma 24. Here, \(\mathcal {sz}_\mathbb {N} (n)\in \mathcal {O}(n^e)\) implies \(\exists n_0, c>0.\quad \forall n\in \mathbb {N}, n > n_0. c \cdot n^e \ge \mathcal {sz}_\mathbb {N} (n)\). By instantiating n with \(\mathcal {sz}_\mathbb {N} ^{-1}(n)\), we obtain

$$\begin{aligned} \exists n_0, c>0.\quad \forall n \in \mathrm {img}(\mathcal {sz}_\mathbb {N}), \mathcal {sz}_\mathbb {N} ^{-1}(n) > n_0.\quad c \cdot (\mathcal {sz}_\mathbb {N} ^{-1}(n))^e \ge \mathcal {sz}_\mathbb {N} (\mathcal {sz}_\mathbb {N} ^{-1}(n)). \end{aligned}$$

Since \(\mathcal {sz}_\mathbb {N} \) is strictly monotonically increasing, this also holds for \(\mathcal {sz}_\mathbb {N} ^{-1}\). Thus, there is an \(n_1\) such that \(\mathcal {sz}_\mathbb {N} ^{-1}(n) > n_0\) holds for all \(n > n_1\) with \(n \in \mathrm {img}(\mathcal {sz}_\mathbb {N})\). Hence,

$$\begin{aligned} \exists n_1, c>0.\quad \forall n \in \mathrm {img}(\mathcal {sz}_\mathbb {N}), n > n_1.\quad c \cdot (\mathcal {sz}_\mathbb {N} ^{-1}(n))^e \ge \mathcal {sz}_\mathbb {N} (\mathcal {sz}_\mathbb {N} ^{-1}(n)). \end{aligned}$$

This simplifies to \(\exists n_1, c>0.\quad \forall n \in \mathrm {img}(\mathcal {sz}_\mathbb {N}), n > n_1.\quad c \cdot (\mathcal {sz}_\mathbb {N} ^{-1}(n))^e \ge n\). When dividing by c and building the e-th root on both sides, we get \(\exists n_1, c>0.\forall n \in \mathrm {img}(\mathcal {sz}_\mathbb {N}), n > n_1.\quad \mathcal {sz}_\mathbb {N} ^{-1}(n) \ge \root e \of {\frac{n}{c}}\). By monotonicity of \(\root e \of {\frac{n}{c}}\), this implies

$$\begin{aligned} \exists n_1, c>0.\quad \forall n \in \mathbb {N}, n > n_1.\quad \lceil \mathcal {sz}_\mathbb {N} ^{-1}\rceil (n) \ge \hbox { }\ \root e \of {\frac{n}{c}}. \end{aligned}$$

Note that \(\mathcal {sz}_\mathbb {N} \) is total and hence, \(\mathcal {sz}_\mathbb {N} ^{-1}\) is surjective. Moreover, by strict monotonicity of \(\mathcal {sz}_\mathbb {N} \), \(\mathrm {img}(\mathcal {sz}_\mathbb {N})\) is infinite. Hence, by (11) we get \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor (n) + 1 \ge \lceil \mathcal {sz}_\mathbb {N} ^{-1}\rceil (n)\) for all \(n \in \mathbb {N} \). Thus, \(\exists n_1, c>0.\quad \forall n \in \mathbb {N}, n > n_1.\quad \lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor (n) + 1 \ge \root e \of {\frac{n}{c}}\). Hence,

$$\begin{aligned} \exists n_1, c>0.\quad \forall n \in \mathbb {N}, n > n_1.\quad \lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor (n) \ge \hbox { }\ \root e \of {\frac{n}{c}} - 1. \end{aligned}$$
(12)

Let \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^d)\) (the case \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (b^n)\) is analogous). This implies \(\exists n_0, c'> 0. \forall n \in \mathbb {N}, n > n_0.\quad c' \cdot n^d \le \mathcal {rt}_\mathbb {N} (n)\). By instantiating n with \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1}(n)\rfloor \), we get

$$\begin{aligned} \exists n_0, c'> 0.\quad \forall n \in \mathbb {N}, \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n)>n_0.\quad c' \cdot (\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n))^d \le \mathcal {rt}_\mathbb {N} (\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n)). \end{aligned}$$

Since \(\mathcal {sz}_\mathbb {N} ^{-1}\) is strictly monotonically increasing, \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor \) is weakly monotonically increasing by construction. As \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor \) is surjective, there is an \(n_2\) such that for all \(n > n_2\) we have \(\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n) > n_0\). Thus, we obtain

$$\begin{aligned} \exists n_2, c'> 0.\quad \forall n \in \mathbb {N}, n > n_2.\quad c' \cdot (\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n))^d \le \mathcal {rt}_\mathbb {N} (\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n)). \end{aligned}$$

With (12) and weak monotonicity of \(c'\cdot n^d\), by choosing \(n_3 = \max \{n_1,n_2\}\) we get \(\exists n_3, c, c'> 0.\quad \forall n \in \mathbb {N}, n > n_3.\quad c' \cdot (\root e \of {\frac{n}{c}} - 1)^d \le \mathcal {rt}_\mathbb {N} (\lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor (n))\). Therefore, \( \exists c>0.\; (\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega \left( \left( \root e \of {\frac{n}{c}} - 1\right) ^d\right) \) and thus, \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega (n^{\frac{d}{e}})\). \(\square \)

Corollary 25

(Asymptotic bounds for \(\mathrm {rc}_{\mathcal {R}} \)) Let \(s \rightarrow ^* t\) be a valid conjecture and let \(\mathcal {sz}:\mathbb {N} ^m \rightarrow \mathbb {N} \) be the function \(\mathcal {sz}(b_1,\dots ,b_m) = \left| s[n_1/b_1,\dots , n_m/b_m]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\right| \), where \(\mathcal {sz}_\mathbb {N} (n) \in \mathcal {O}(n^e)\) for some \(e\ge 1\), and \(\mathcal {sz}_\mathbb {N} \) is strictly monotonically increasing. Moreover, let \(\mathcal {ih}\), \(\mathcal {ib}\), and \(\mathcal {is}\) be defined as in Definition 17, where \(\mathcal {ib}\) and \(\mathcal {is}\) have the degrees \(d_\mathcal {ib}\) and \(d_\mathcal {is}\).

  1. (a)

    \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}\}}{e}})\), if \(\mathcal {ih}= 0\)

  2. (b)

    \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}+1\}}{e}})\), if \(\mathcal {ih}= 1\)

  3. (c)

    \(\mathrm {rc}_{\mathcal {R}} (n) \in \mathcal {ih}^{\varOmega (\root e \of {n})}\), if \(\mathcal {ih}> 1\)

Proof

  1. (a)

    In this case, Corollary 21 implies that there is a rewrite lemma \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) such that \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^{\max \{d_\mathcal {ib},d_\mathcal {is}\}})\). With Lemma 24, we get \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}\}}{e}})\). Moreover, Theorem 23 states that \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \le \mathrm {rc}_{\mathcal {R}} (n)\) holds for all \(n \in \mathbb {N} \). Thus, we obtain \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}\}}{e}})\).

  2. (b)

    Now Corollary 21 implies that there is a rewrite lemma \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) with \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (n^{\max \{d_\mathcal {ib},d_\mathcal {is}+1\}})\). Thus, with Lemma 24, we result in \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1} \rfloor )(n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}+1\}}{e}})\). Similar to (a), this implies \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n^{\frac{\max \{d_\mathcal {ib},d_\mathcal {is}+1\}}{e}})\).

  3. (c)

    By Corollary 21 there is a lemma \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t\) with \(\mathcal {rt}_\mathbb {N} (n) \in \varOmega (\mathcal {ih}^n)\). By Lemma 24, we get \((\mathcal {rt}_\mathbb {N} \circ \lfloor \mathcal {sz}_\mathbb {N} ^{-1}\rfloor )(n) \in \mathcal {ih}^{\varOmega (\root e \of {n})}\). As in (a), we have \(\mathrm {rc}_{\mathcal {R}} (n) \in \mathcal {ih}^{\varOmega (\root e \of {n})}\).

\(\square \)

Theorem 31

(Linear lower bounds by loop detection) If a TRS \({\mathcal {R}} \) has a decreasing loop, then we have \(\mathrm {rc}_{{\mathcal {R}}}(n) \in \varOmega (n)\).

Proof

For all \(n \in \mathbb {N}\) and any substitution \(\delta \), we prove that \(\overline{\ell } \, \theta ^n \, \delta \; \rightarrow _{\mathcal {R}} ^+ \circ \unrhd \; \overline{\ell }\, \theta ^{n-1} \, \delta '\) for a substitution \(\delta '\). Thus, these rewrite steps can be repeated n times. We have

$$\begin{aligned} \overline{\ell }\,\theta ^n\, \delta= & {} \ell \, \theta ^{n-1}\, \delta \; \rightarrow _{\mathcal {R}} ^+ C[r]\, \theta ^{n-1}\, \delta \; \unrhd \; r\,\theta ^{n-1}\,\delta \\= & {} \overline{\ell }\, \sigma \, \theta ^{n-1}\, \delta \; \mathop {=}\limits ^{(\star )} \; \overline{\ell }\, \theta ^{n-1} \, (\sigma \theta ^{n-1})|_{{\text {dom}} (\sigma )} \, \delta = \overline{\ell }\,\theta ^{n-1}\,\delta ' \end{aligned}$$

for the substitution \(\delta ' = (\sigma \,\theta ^{n-1})|_{{\text {dom}} (\sigma )} \,\delta \). Here, \((\sigma \,\theta ^{n-1})|_{{\text {dom}} (\sigma )}\) denotes the composition of the substitutions \(\sigma \) and \(\theta ^{n-1}\), but restricted to the domain of \(\sigma \).

The step marked with \((\star )\) holds since \(\sigma \) does not instantiate variables in the domain or range of \(\theta \). To see why \({\text {dom}} (\sigma )\) is disjoint from \({\text {dom}} (\theta ) = \{x_1,\ldots ,x_m\}\), note that \(x_i\,\sigma \ne x_i\) would mean \(\overline{\ell }|_{\xi _i}\,\sigma \ne r|_{\xi _i}\). As \(\overline{\ell }|_{\xi _i}\,\sigma = \overline{\ell }\,\sigma |_{\xi _i}\), this would imply \(\overline{\ell }\,\sigma |_{\xi _i}\ne r|_{\xi _i}\), which contradicts \(\overline{\ell }\,\sigma = r\). Moreover, since \(\ell \) is linear, the sets \({\mathcal {V}} (\overline{\ell })\) and \(({\mathcal {V}} (\ell |_{\xi _1}) \cup \ldots \cup {\mathcal {V}} (\ell |_{\xi _m})) {\setminus } \{x_1,\ldots ,x_m\}\) are disjoint. Clearly, the substitution \(\sigma \) that matches \(\overline{\ell }\) to r can be chosen such that its domain only includes variables occurring in \(\overline{\ell }\). Then \(\sigma \) also does not instantiate any variables occurring in the range of \(\theta \).

Thus, for each \(n \in \mathbb {N} \), there is a rewrite sequence of length \(n\) starting with \(\overline{\ell }\,\theta ^n\). This term is basic, since the range of \(\theta \) only contains terms of the form \(\ell |_{\xi _i}\). Each \(\ell |_{\xi _i}\) is a constructor term, since \(\xi _i\) cannot be the root position, due to \(r \notin {\mathcal {V}} \). By construction, \(\theta \) does not duplicate variables, as \(\ell \) and thus \(\overline{\ell }|_{\xi _1}, \ldots , \overline{\ell }|_{\xi _m}\) only contain each \(x_i\) once. Therefore, we have \(|\overline{\ell }\,\theta ^n| \in \mathcal {O}(n)\) and obtain \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\). \(\square \)

Corollary 32

(Infinite lower bounds by loop detection) If there is a decreasing loop for a TRS \({\mathcal {R}} \) with an empty set of abstracted positions, then \(\mathrm {rc}_{{\mathcal {R}}}(n) \in \varOmega (\omega )\).

Proof

The corollary holds because of the loop \(\ell \rightarrow ^+_{\mathcal {R}} C[r] \unrhd r = \overline{\ell }\sigma = \ell \sigma \). \(\square \)

The following lemma is needed for the proof of Theorem 37. It shows that for compatible loops, the ranges and domains of pumping substitutions do not interfere with each other. This ensures that the size of a start term like \(\overline{\ell }_1\, \theta _1^n \, \theta _2^n\) is linear in n (i.e., applying pumping substitutions a linear number of times only leads to a term of linear size).

Lemma 50

(Ranges and domains of pumping substitutions) Let there be two compatible loops with pumping substitutions \(\theta \) and \(\theta '\). For any \(x \in {\text {dom}} (\theta )\), we have

  1. (a)

    \({\mathcal {V}} (x\,\theta ) \cap {\text {dom}} (\theta ) = \{ x \}\) and x only occurs once in \(x\,\theta \)

  2. (b)

    \({\mathcal {V}} (x\,\theta ) \cap {\text {dom}} (\theta ') \subseteq \{ x \}\)

Proof

The claim (a) follows from Definition 27, as \(\ell \) is linear. For (b), assume there is \(y \in {\mathcal {V}} (x\,\theta ) \cap {\text {dom}} (\theta ')\) with \(y \ne x\). Let \(\rho _1,\ldots ,\rho _d\) be all positions of \(x\,\theta \) where y occurs, i.e., \((x\,\theta )|_{\rho _1} = \ldots = (x\,\theta )|_{\rho _d} = y\). Thus, \(\rho _1,\ldots ,\rho _d\) are parallel positions. Note that

$$\begin{aligned} x \in {\text {dom}} (\theta '). \end{aligned}$$
(13)

To prove (13), note that otherwise, we would have \((x\,\theta '\,\theta )|_{\rho _1} = (x\,\theta )|_{\rho _1} = y\). On the other hand, we obtain \((x\,\theta \,\theta ')|_{\rho _1} = (x\,\theta )|_{\rho _1}\,\theta ' = y\,\theta '\). Since \(\theta \) and \(\theta '\) commute, this implies \(y = y\,\theta '\) which is a contradiction to \(y \in {\text {dom}} (\theta ')\).

Since \(x \in {\text {dom}} (\theta ) \cap {\text {dom}} (\theta ')\), by (a) there exist positions \(\pi \ne \varepsilon \) and \(\zeta \ne \varepsilon \) such that \((x\,\theta )|_\pi = x\) and \((x\,\theta ')|_\zeta = x\). By (a), \(x\) only occurs once in \(x\,\theta \) and only once in \(x\,\theta '\). Moreover, (a) implies that applying \(\theta \) (resp. \(\theta '\)) to any variable \(y \ne x\) does not introduce occurrences of \(x\). Hence, x only occurs once in \(x\,\theta '\,\theta \). Since \(\theta \) and \(\theta '\) commute, the same holds for \(x\,\theta \,\theta '\).

Hence, \((x\,\theta '\,\theta )|_{\zeta .\pi } = x\) and \((x\,\theta \,\theta ')|_{\pi .\zeta } = x\) implies \(\zeta .\pi = \pi .\zeta \). This means that

$$\begin{aligned} \text{ there } \text{ is } \text{ an } \alpha \in \mathbb {N} ^+ \text{ such } \text{ that } \pi = \alpha ^n \text{ and } \zeta = \alpha ^m \text{ for } n,m \in \mathbb {N}. \end{aligned}$$
(14)

Here, \(\alpha ^n\) stands for the position \(\alpha \,.\, \alpha \, \ldots \, \alpha \) where the sequence \(\alpha \) is repeated n times. To see why (14) holds, we prove that (14) follows from \(\zeta .\pi = \pi .\zeta \) for arbitrary positions \(\pi \) and \(\zeta \) (in this proof, we also allow \(\pi = \varepsilon \) or \(\zeta = \varepsilon \)). The proof is done by induction on \(\pi \) and \(\zeta \). In the induction base, \(\pi = \varepsilon \) or \(\zeta = \varepsilon \) immediately imply (14). In the induction step, we have \(\pi \ne \varepsilon \) and \(\zeta \ne \varepsilon \). W.l.o.g., let \(|\pi | \le |\zeta |\). Then \(\zeta .\pi = \pi .\zeta \) implies \(\zeta = \pi .\pi '\) for some position \(\pi '\). Hence, \(\zeta .\pi = \pi .\zeta \) now becomes \(\pi .\pi '.\pi = \pi .\pi .\pi '\) and thus, \(\pi '.\pi = \pi .\pi '\). Since \(\pi \ne \varepsilon \), the induction hypothesis implies \(\pi = \alpha ^n\) and \(\pi ' = \alpha ^m\) for some \(\alpha \in \mathbb {N} ^+\) and \(n,m \in \mathbb {N} \). Thus, \(\zeta = \pi .\pi ' = \alpha ^{n+m}\), which proves (14).

We now perform a case analysis on the relationship between \(\pi \) and \(\zeta \).

Case 1: \(\pi \le \zeta \)

In this case, we have \(\zeta = \pi .\pi '\) for some position \(\pi '\). We obtain \((x\,\theta '\,\theta )|_{\zeta .\rho _1} = ((x\,\theta ')|_\zeta \, \theta )|_{\rho _1} = (x \, \theta )|_{\rho _1} = y\). The commutation of \(\theta '\) and \(\theta \) implies that we also have \((x\,\theta \,\theta ')|_{\zeta .\rho _1} = y\). However, \((x\,\theta \,\theta ')|_{\zeta .\rho _1} = (x\,\theta \,\theta ')|_{\pi .\pi '.\rho _1} = ((x\,\theta )|_{\pi } \,\theta ')|_{\pi '.\rho _1} = (x \,\theta ')|_{\pi '.\rho _1}\). Note that \(x\, \theta '\) cannot contain the variable y, since \(y \in {\text {dom}} (\theta ')\) by the assumption at the beginning of the proof and \({\mathcal {V}} (x\,\theta ') \cap {\text {dom}} (\theta ') = \{ x \}\) by (13) and (a).Footnote 16 Thus, this contradicts \((x\,\theta \,\theta ')|_{\zeta .\rho _1} = y\).

Case 2: \(\pi \not \le \zeta \)

By (14), we have \(\zeta = \alpha ^m\) and \(\pi =\alpha ^{m+k}\) for \(m >0\) and \(k > 0\) (since \(\zeta \ne \varepsilon \) and \(\pi \ne \varepsilon \)). As \(y \in {\text {dom}} (\theta ')\), by (a) there is a unique position \(\kappa \) such that \(y\theta '|_\kappa = y\). Recall that \(\rho _1,\ldots ,\rho _d\) are the only positions where y occurs in \(x\theta \). Due to (a), \(\rho _1.\kappa , \ldots , \rho _d.\kappa \) are the only positions where y occurs in \(x\theta \theta '\) (since \((x\,\theta \,\theta ')|_{\rho _i.\kappa } = ((x\,\theta )_{\rho _i}\,\theta ')|_{\kappa } = (y \, \theta ')|_{\kappa } = y\)). Similarly, \(\zeta .\rho _1,\ldots ,\zeta .\rho _d\) are the only positions where y occurs in \(x\,\theta '\,\theta \) (since \((x\,\theta '\,\theta )|_{\zeta .\rho _i} = ((x\,\theta ')|_{\zeta }\,\theta )|_{\rho _i} = (x \,\theta )|_{\rho _i} = y\)). As \(x\,\theta \,\theta ' = x\,\theta '\,\theta \), the positions \(\rho _1.\kappa ,\ldots ,\rho _d.\kappa \) are the same as the positions \(\zeta .\rho _1,\ldots ,\zeta .\rho _d\). Let \(\rho _1,\ldots ,\rho _d\) be ordered according to the (total) lexicographic ordering \(\sqsubset \) on tuples of numbers (i.e., \(\rho _1 \sqsubset \rho _2 \sqsubset \ldots \sqsubset \rho _d\)).Footnote 17 Then we also have \(\rho _1.\kappa \sqsubset \ldots \sqsubset \rho _d.\kappa \) (as the \(\rho _i\) are parallel positions) and \(\zeta .\rho _1 \sqsubset \ldots \sqsubset \zeta .\rho _d\). This implies \(\rho _i.\kappa = \zeta .\rho _i\) for all \(1 \le i \le d\), i.e., in particular \(\rho _1.\kappa = \zeta .\rho _1\). As \(\zeta = \alpha ^m\), this means \(\rho _1.\kappa = \alpha ^m.\rho _1\).

Let e be the largest number such that \(\rho _1 = \alpha ^e.\rho '\) for some position \(\rho '\). Thus, \(\alpha \) is no prefix of \(\rho '\). We perform a case analysis on the relation between e and k.

If \(e \ge k\), then \(y = (x\,\theta \,\theta ')|_{\alpha ^m.\rho _1}= (x\,\theta \,\theta ')|_{\alpha ^{m+e}.\rho '} \; \unlhd \; (x\,\theta \,\theta ')|_{\alpha ^{m+k}} = (x\,\theta )|_{\alpha ^{m+k}} \,\theta ' = x \theta '\). But this contradicts (a), as \(x \in {\text {dom}} (\theta ')\) by (13). Thus, \(x\theta '\) cannot contain y.

Now we consider the case \(e < k\). Note that \(\rho _1.\kappa = \alpha ^m.\rho _1\) implies \(\alpha ^e.\rho '.\kappa = \alpha ^m.\alpha ^e.\rho '\), i.e., \(\rho '.\kappa = \alpha ^m.\rho '\). Since \(\alpha \) is no prefix of \(\rho '\), \(\rho '\) must be a (proper) prefix of \(\alpha \), since \(m>0\). Thus, we have \(\rho ' < \alpha \), which implies \(\alpha ^m.\rho _1 = \alpha ^{m+e}.\rho ' < \alpha ^{m + e + 1} \le \alpha ^{m+k}\), as \(e < k\). Hence, we have \(y = (x\,\theta \,\theta ')|_{\alpha ^m.\rho _1} \; \rhd \; (x\,\theta \,\theta ')|_{\alpha ^{m+k}} = x\). This is an immediate contradiction, because the variable y cannot contain the variable x as a subterm. \(\square \)

Theorem 37

(Exponential lower bounds by loop detection) If a TRS \({\mathcal {R}} \) has \(d \ge 2\) pairwise compatible decreasing loops, then we have \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (d^n)\).

Proof

For each \(1 \le j \le d\), let \(\theta _j\) be the pumping substitution and \(\sigma _j\) be the result substitution of the decreasing loop \(\ell \rightarrow ^+_{\mathcal {R}} C_j[r_j]_{\iota _j}\) where \(r = C_j[r_j]_{\iota _j}\). If \(\xi _{1},\ldots ,\xi _{m}\) are the abstracted positions of the j-th decreasing loop and \(x_{i} = r_j|_{\xi _{i}}\) for all \(1 \le i \le m\), then let \(\overline{\ell }_j = \ell [x_{1}]_{\xi _{1}} \ldots [x_{m}]_{\xi _{m}}\). Thus, we have \(\overline{\ell }_j\,\theta _j = \ell \) and \(\overline{\ell }_j \,\sigma _j = r_j\).

For all \(1 \le j \le d\), all \(n \in \mathbb {N}\), and any substitution \(\delta \), \(\overline{\ell }_j\,\theta _{1}^{n}\dots \theta _{d}^{n}\,\delta \) starts a reduction of asymptotic length \(d^n\). To show this, we prove \(\overline{\ell }_j\,\theta _{1}^{n}\dots \theta _{d}^{n}\, \delta \rightarrow ^+_{\mathcal {R}} q\) for some q such that for all \(1\le k\le d\), there is a substitution \(\delta '_k\) with \(q|_{\iota _k}= \overline{\ell }_k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta '_k\). Hence, q contains d terms of the form \(\overline{\ell }_k\,\theta _{1}^{n}\ldots \theta _j^{n-1}\ldots \theta _{d}^{n}\,\delta '_k\) at parallel positions.

$$\begin{aligned}&\overline{\ell }_j\,\theta _{1}^{n}\dots \theta _{d}^{n}\,\delta \mathop {=}\limits ^{(\dagger )} \overline{\ell }_j\,\theta _j\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta \\&\quad =\ell \,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta \rightarrow _{\mathcal {R}} ^+ r \,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta = q \end{aligned}$$

where \((\dagger )\) holds as \(\theta _j\) commutes with all \(\theta _i\) by Definition 36 (d). For any \(1 \le k \le d\),

$$\begin{aligned} q|_{\iota _k}&=r_k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta =\overline{\ell }_k\,\sigma _k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\,\delta \\&\mathop {=}\limits ^{(\star )}\overline{\ell }_k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n} \; (\sigma _k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n})|_{{\text {dom}} (\sigma _k)} \; \delta =\overline{\ell }_k\,\theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n} \,\delta '_k \end{aligned}$$

for the substitution \(\delta '_k = ( \sigma _k \, \theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n})|_{{\text {dom}} (\sigma _k)} \; \delta \).

For the step marked with \((\star )\), as in the proof of Theorem 31, \(\sigma _k\) does not instantiate variables in the domain or the range of \(\theta _k\). By Definition 36 (c) it also does not instantiate variables in the domain or the range of any other pumping substitution \(\theta _i\).

Since q contains \(\overline{\ell }_k \, \theta _{1}^{n}\dots \theta _j^{n-1}\dots \theta _{d}^{n}\, \delta '_k\) at parallel positions \(\iota _k\) (for \(1 \le k \le d\)), this results in a \(d\)-ary tree of rewrite sequences with root \(\overline{\ell }_j\,\theta _{1}^{n}\dots \theta _{d}^{n}\) for a \(1 \le j \le d\) which is complete up to height \(n\). The reason is that in the beginning, there are \(n\) substitutions \(\theta _j\) for each \(1 \le j \le d\) and each rewrite step removes one of them.

Hence, the tree has at least \(\lfloor \frac{d^{n + 1}-1}{d-1}\rfloor \) nodes. By Lemma 50, \(\theta _{1} \dots \theta _{d}\) does not duplicate variables. Thus, \(\left| \overline{\ell }_j\,\theta _{1}^{n}\dots \theta _{d}^{n}\right| \) is linear in \(n\) and we get \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (d^n)\). \(\square \)

Theorem 38

(Loop detection subsumes induction for linear bounds) Let \({\mathcal {R}} \) be a TRS and \({\mathcal {L}} \) be the set of rewrite lemmas that were speculated and proved by the technique of Sect. 3. If \({\mathcal {R}} \) is left-linear and there is a rewrite lemma \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t \in {\mathcal {L}} \) where \(\mathcal {rt}({\overline{n}})\) is not a constant, then \({\mathcal {R}} \) has a decreasing loop.

Proof

Let \(s \rightarrow ^{\ge \mathcal {rt}({\overline{n}})} t \in {\mathcal {L}} \) be the “first” rewrite lemma where the induction technique infers non-constant runtime. Thus, in its induction proof (according to Sect. 3.3) one only uses other rewrite lemmas of the form \(s' \rightarrow ^{\ge \mathcal {rt}'({\overline{n}}')} t'\) where \(\mathcal {rt}'({\overline{n}}')\) is a constant. Hence, in the induction proof for the conjecture \(s \rightarrow ^* t\), \(\mathcal {is}({\overline{n}})\) is a constant and the induction hypothesis is applied at least once, i.e., \(\mathcal {ih}\ge 1\). Therefore the rewrite sequence \(s[n/n+1] \; \rightharpoonup ^*_{{\text {IH}},n} \; t[n/n+1]\) of Theorem 14 starts with \(s[n/n+1] \; \rightharpoonup ^* C[s\sigma ]\) for some context C and an increasing substitution \(\sigma \) with \(n\sigma = n\). We even have \(s[n/n+1] \; \rightharpoonup ^+ C[s\sigma ]\), since \(s[n/n+1] \ne C[s\sigma ]\). To see this, note that \(s[n/n+1] \ne s\sigma \) since n occurs in s and \(n \sigma = n\). Moreover, \(s \sigma \) cannot be a proper subterm of \(s[n/n+1]\), since s does not contain defined symbols below the root by Definition 6.

For any \(\mu :{\mathcal {V}} (s) \rightarrow \mathbb {N} \), Lemmas 48 (a) and 49 (a) imply \(s[n/n+1]\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}} \; \rightarrow ^+_{\mathcal {R}} \; C\mu [s\sigma \mu ]\!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}\). The procedure in Sect. 3.2 only speculates conjectures where s has the form \(f(\gamma _{\tau _1}(s_1),\ldots , \gamma _{\tau _k}(s_k))\). Here, the arguments \(s_i\) of the generator functions are polynomials over the variables \({\overline{n}}\) with coefficients from \(\mathbb {N} \). In other words, \(s = f(\gamma _{\tau _1}( pol_1 ({\overline{n}})),\ldots , \gamma _{\tau _k}( pol_k ({\overline{n}})))\) for polynomials \( pol_1 ,\dots , pol_k \). By the definition of generator functions (see Definition 5) we get

for non-empty constructor ground contexts \(D_1,\dots ,D_k\) and constructor ground terms \(t_1,\dots ,t_k\). The reason is \(\gamma _{\tau _i}( pol_i ({\overline{n}}\mu )) \equiv _{{\mathcal {G}} \cup {\mathcal {A}}} D_i^{ pol_i ({\overline{n}}\mu )}[t_i]\) where \(t_i = \gamma _{\tau _i}(0)\).

If \( pol _i\) is a constant, we have \(D_i^{ pol_i ({\overline{n}}[n/n+1]\mu )}[t_i]= D_i^{ pol _i({\overline{n}}\sigma \mu )}[t_i] = q_i\) for some constructor ground term \(q_i\). Hence, \(f[D_1^{ pol_1 ({\overline{n}}[n/n+1]\mu )}[t_1],\dots ,D_k^{ pol_k ({\overline{n}}[n/n+1]\mu )}[t_k]]\) is of the form \(C'[D_{i_1}^{ pol_{i_1} ({\overline{n}}[n/n+1]\mu )}[t_{i_1}],\dots ,D_{i_m}^{ pol_{i_m} ({\overline{n}}[n/n+1]\mu )}[t_{i_m}]]\) for a ground context \(C'\) with root f which has no defined symbols below the root. Here, \(1 \le i_1< \ldots < i_m \le k\), all \( pol_{i_j} \) are non-constant, and all \( pol_i \) with \(i \in \{1,\ldots ,k\}{\setminus } \{i_1,\ldots ,i_m\}\) are constant. Similarly, \(C\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[f[D_1^{ pol_1 ({\overline{n}}\sigma \mu )}[t_1],\dots ,D_k^{ pol_k ({\overline{n}}\sigma \mu )}[t_k]]] = C\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[C'[D_{i_1}^{ pol_{i_1} ({\overline{n}}\sigma \mu )}[t_{i_1}],\dots ,D_{i_m}^{ pol_{i_m} ({\overline{n}}\sigma \mu )}[t_{i_m}]]]\). Note that the length of the reduction

$$\begin{aligned} \begin{array}{r@{\quad }l} &{}C'[D_{i_1}^{ pol_{i_1} ({\overline{n}}[n/n+1]\mu )}[t_{i_1}],\dots ,D_{i_m}^{ pol_{i_m} ({\overline{n}}[n/n+1]\mu )}[t_{i_m}]]\\ \rightarrow ^+_{\mathcal {R}} &{}C\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[C'[D_{i_1}^{ pol_{i_1} ({\overline{n}}\sigma \mu )}[t_{i_1}],\dots ,D_{i_m}^{ pol_{i_m} ({\overline{n}}\sigma \mu )}[t_{i_m}]]] \end{array} \end{aligned}$$
(15)

is at most \(\mathcal {is}({\overline{n}}\mu )\). Thus, its length is constant and does not depend on \(n\). Therefore, the subterms \(t_{i_1}, \ldots , t_{i_m}\) are not crucial for the reduction, i.e., we also have

$$\begin{aligned} \begin{array}{r@{\quad }l} &{}C'[D_{i_1}^{ pol_{i_1} (\overline{n}[n/n+1]\mu )}[x_{1}],\dots ,D_{i_m}^{ pol_{i_m} (\overline{n}[n/n+1]\mu )}[x_{m}]]\\ \rightarrow ^+_{\mathcal {R}} &{}C\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[C'[D_{i_1}^{ pol_{i_1} (\overline{n}\sigma \mu )}[x_{1}],\dots ,D_{i_m}^{ pol_{i_m} (\overline{n}\sigma \mu )}[x_{m}]]] \end{array} \end{aligned}$$

for fresh pairwise different variables \(x_1,\dots ,x_m\). The reason is that each \(t_{i_j}\) is embedded in the context \(D_{i_j}^{ pol_{i_j} ({\overline{n}}[n/n+1]\mu )}.\) Since \( pol_{i_j} \) is not a constant, the number \( pol_{i_j} ({\overline{n}}[n/n+1]\mu )\) depends on the instantiation \(\mu \). Therefore, the context \(D_{i_j}^{ pol_{i_j} ({\overline{n}}[n/n+1]\mu )}\) cannot be decomposed in the same constant number of rewrite steps for every \(\mu \). Hence, when replacing the subterm \(t_{i_j}\) by a fresh variable, the rewrite sequence (15) is still possible. Note that while several of the subterms \(t_{i_j}\) might be equal, we can still replace them by pairwise different fresh variables without affecting the rewrite sequence, since \({\mathcal {R}} \) is left-linear.

By choosing an arbitrary fixed instantiation \(\mu :{\mathcal {V}} (s) \rightarrow \mathbb {N} \), we obtain

$$\begin{aligned} C'[D_{i_1}^{c_1 + d_1}[x_1],\dots ,D_{i_m}^{c_m + d_m}[x_m]] \quad \rightarrow ^+_{\mathcal {R}} \quad C\mu \!\downarrow _{{\mathcal {G}}/{\mathcal {A}}}[C'[D_{i_1}^{c_1}[x_{1}],\dots ,D_{i_m}^{c_m}[x_m]]] \end{aligned}$$

for constants \(c_1,\ldots , c_m,d_1,\ldots , d_m \in \mathbb {N} \). As \(C'\) is ground, \(C'[D_{i_1}^{c_1 + d_1}[x_1],\ldots ,D_{i_m}^{c_m + d_m}[x_m]]\) is linear. Thus, this reduction sequence is a decreasing loop with the pumping substitution \(\theta = [x_1 / D^{d_1}_{i_1}[x_1], \dots , x_m / D^{d_m}_{i_m}[x_m]]\) and result substitution \(\sigma = \varnothing \). \(\square \)

To prove Theorem 39, we need several auxiliary lemmas. In the following, we restrict ourselves to linear TRSs \({\mathcal {R}} \) containing only rules \(\ell \rightarrow r\) where both \(\ell \) and r are basic. We first show that every rewrite sequence with basic terms gives rise to a corresponding narrowing sequence starting with a basic term \(f(x_1,\ldots ,x_k)\). For our restricted class of TRSs, a basic term s narrows to t (“\(s \, {\rightsquigarrow } {}_{{\mathcal {R}}} \, t\)”) iff there is a variable-renamed rule \(\ell \rightarrow r \in {\mathcal {R}} \) with \(\sigma = \mathrm {mgu}(s,\ell )\) and \(t = r\sigma \).

Lemma 51

(From rewrite sequences to narrowing sequences) Let \({\mathcal {R}} \) be a linear TRS where the terms in all rules are basic. Let \(m \in \mathbb {N} \) and let \(s \in {{\mathcal {T}} _B}\) with \({\text {root}} (s) = f\) such that \(s \rightarrow _{\mathcal {R}} ^m t\). Then we have \(f(x_1,\ldots ,x_k) \; {{\rightsquigarrow } _{\mathcal {R}} ^m} \; t'\) for pairwise different variables \(x_1,\ldots ,x_k\), where \(t'\) matches t.

Proof

The proof is done by induction on m. For \(m=0\), the claim is trivial. In the induction step, we have \(s \rightarrow _{\mathcal {R}} ^m \ell \delta \rightarrow _{\mathcal {R}} r\delta = t\) for some rule \(\ell \rightarrow r \in {\mathcal {R}} \) and some substitution \(\delta \). The induction hypothesis implies \(f(x_1,\ldots ,x_k) \; {\rightsquigarrow } _{\mathcal {R}} ^m \; u\) where u matches \(\ell \delta \). W.l.o.g., \(\ell \) is variable-disjoint from u. Thus, u and \(\ell \) are unifiable. Let \(\theta = \mathrm {mgu}(u,\ell )\). Hence, there exists a substitution \(\mu \) such that \(\theta \mu \) is like \(\delta \) on the variables of \(\ell \). Then we have \(u \; {\rightsquigarrow } _{\mathcal {R}} \; r \delta \) and \(r \theta \mu = r\delta = t\), i.e., \(r \theta \) matches t. \(\square \)

Moreover, we need the following lemma.

Lemma 52

(Size of unified terms) Let \(s,t \in {{\mathcal {T}} _B}\) be linear terms such that \({\mathcal {V}} (s) \cap {\mathcal {V}} (t) = \varnothing \) and let \(\mathrm {mgu}(s,t) = \theta \). Then for all \(x \in {\mathcal {V}} {\setminus }{\mathcal {V}} (t)\) we have \(|x\theta | \le |t|\).

Proof

If \(x \notin {\text {dom}} (\theta )\), then we trivially have \(|x\theta | = |x| = 1 \le |t|\). Otherwise, \(x \in {\text {dom}} (\theta )\) and \(x \notin {\mathcal {V}} (t)\) imply \(x \in {\mathcal {V}} (s)\). Since \(s\) is linear, there is a unique position \(\pi \) such that \(s|_\pi = x\). Moreover, \(x \in {\text {dom}} (\theta )\) implies \(\pi \in {\text {pos}} (t)\). Since \(t\) is linear and \({\mathcal {V}} (s) \cap {\mathcal {V}} (t) = \varnothing \), we have \(x\theta = t|_\pi \) and thus \(|x\theta | = |\, t|_\pi \, | \le |t|\). \(\square \)

Now we can show that a linear lower bound is equivalent to non-termination of narrowing for a term of the form \(f(x_1,\ldots ,x_k)\).

Lemma 53

(Linear lower bound means non-termination of narrowing) Let \({\mathcal {R}} \) be a linear TRS where the terms in all rules are basic. Then there is an infinite narrowing sequence that starts with a basic term \(f(x_1,\ldots ,x_k)\) for pairwise different variables \(x_1,\ldots ,x_k\) iff \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\).

Proof

For the “only if” direction, we have an infinite sequence \(f(x_1,\dots ,x_k) = t_0 \; \overset{\sigma _1}{{\rightsquigarrow }}_{\mathcal {R}} \; t_1 \; \overset{\sigma _2}{{\rightsquigarrow }}_{\mathcal {R}} \; \dots \) for pairwise different variables \(x_i\), where \(\sigma _i\) is the mgu used in the i-th narrowing step. Since the terms in all rules of \({\mathcal {R}} \) are basic, all \(\sigma _i\) are constructor substitutions (i.e., \(\mathrm {range}(\sigma _i)\) does not contain defined symbols). As \(t_0\) and \({\mathcal {R}} \) are linear, \(t_0\sigma _1\dots \sigma _{i}\) is linear and basic, and we have \(|{\mathcal {V}} (t_0\sigma _1\dots \sigma _{i})| \le k\) for all \(i \in \mathbb {N} \). By induction on i, we now prove that there is a \(c \in \mathbb {N} \) such that \(|t_0\sigma _1\dots \sigma _i| \le |t_0| + c \cdot i\) for all \(i \in \mathbb {N} \). Then the infinite family of rewrite sequences \(t_0\sigma _1\dots \sigma _i \rightarrow ^i_{\mathcal {R}} t_{i}\) is a witness for \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\). Let \(c = \max \{|\ell | \mid \ell \rightarrow r \in {\mathcal {R}} \} \cdot k\).

The case \(i = 0\) is trivial. In the induction step, by the induction hypothesis we know \(|t_0\sigma _1\dots \sigma _i| \le |t_0| + c \cdot i\). Note that \(\sigma _{i+1}\) is the mgu of \(t_i\) and \(\ell \), both of which are linear. Hence by Lemma 52 we have \(|x\sigma _{i+1}| \le |\ell |\) for all \(x \in {\mathcal {V}} (t_0\sigma _1\dots \sigma _i)\). As \(t_0\sigma _1\dots \sigma _{i}\) is linear and \(|{\mathcal {V}} (t_0\sigma _1\dots \sigma _{i})| \le k\), this implies \(|t_0\sigma _1\dots \sigma _{i+1}| \le |t_0\sigma _1\dots \sigma _i| + |\ell | \cdot k \le |t_0\sigma _1\dots \sigma _i| + c \le |t_0| + c \cdot (i+1) \).

For the “if” direction, \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\) implies that the TRS does not have constant runtime complexity. Hence, for each \(m \in \mathbb {N} \) there is a rewrite sequence of length m staring with a basic term \(f(\ldots )\). Since \(\varSigma _{ def }({\mathcal {R}})\) is finite, there exists an \(f \in \varSigma _{ def }({\mathcal {R}})\) such that there are rewrite sequences of lengths \(m_1< m_2< m_3 < \ldots \) that start with basic terms with root symbol f. By Lemma 51 this means that the term \(f(x_1,\ldots ,x_k)\) starts narrowing sequences of lengths \(m_1< m_2< m_3 < \ldots \), i.e., the narrowing tree with the root \(f(x_1,\ldots ,x_k)\) has infinitely many nodes. Since \({\rightsquigarrow } _{\mathcal {R}} \) is finitely branching, by König’s Lemma the tree has an infinite path, i.e., there is an infinite narrowing sequence starting with \(f(x_1,\ldots ,x_k)\). \(\square \)

We now show that non-termination of narrowing is equivalent to non-termination of rewriting on possibly infinite basic terms. To prove this equivalence, we need the following auxiliary lemma.

Lemma 54

(Unification with infinite terms) Let \(s,t\) be variable-disjoint linear finite terms. If there is a substitution \(\sigma \) such that \(s\sigma = t\sigma \) and \(\mathrm {range}(\sigma )\) contains infinite terms, then \(s\) and \(t\) unify and the range of \(\mathrm {mgu}(s,t)\) consists of linear finite terms.

Proof

We use structural induction on \(s\). If \(s \in {\mathcal {V}} \), then \(\mathrm {mgu}(s,t) = [s / t]\) and if \(t \in {\mathcal {V}} \), then \(\mathrm {mgu}(s,t) = [t / s]\). Now let \(s = f(s_1,\dots ,s_k)\) and since \(s\sigma = t\sigma \), we have \(t = f(t_1,\dots ,t_k)\). By the induction hypothesis, the ranges of the substitutions \(\sigma _1 = \mathrm {mgu}(s_1,t_1),\dots , \sigma _k = \mathrm {mgu}(s_k,t_k)\) consist of linear finite terms. Let \({\mathcal {V}} (\sigma _i) = {\text {dom}} (\sigma _i) \cup {\mathcal {V}} (\mathrm {range}(\sigma _i))\) for all \(1 \le i \le n\). Since \(s\) and \(t\) are variable-disjoint and linear, the sets \({\mathcal {V}} (\sigma _i)\) are pairwise disjoint and we have \(({\mathcal {V}} (s_i) \cup {\mathcal {V}} (t_i)) \cap {\mathcal {V}} (\sigma _j) = \varnothing \) for all \(i \ne j\). Hence, we get \(\mathrm {mgu}(s,t) = \sigma _1\dots \sigma _n\). As, by the induction hypothesis, \(\mathrm {range}(\sigma _i)\) consists of linear terms and the sets \({\mathcal {V}} (\sigma _i)\) are pairwise disjoint, the range of \(\mathrm {mgu}(s,t)\) consists of linear terms, too. Similarly, as \(\mathrm {range}(\sigma _i)\) only contains finite terms, this also holds for \(\mathrm {range}(\sigma _1\dots \sigma _n)\). \(\square \)

Lemma 55

(Narrowing and rewriting with infinite terms) Let \({\mathcal {R}} \) be a linear TRS where the terms in all rules are basic. Then \({\rightsquigarrow } _{\mathcal {R}} \) terminates on basic terms of the form \(f(x_1,\ldots ,x_k)\) iff \(\rightarrow _{\mathcal {R}} \) terminates on possibly infinite basic terms.

Proof

For the “if” direction, assume there is an infinite sequence \(f(x_1,\ldots ,x_k) = t_1 \overset{\sigma _1}{{\rightsquigarrow }}_{\mathcal {R}} \; t_2 \; \overset{\sigma _2}{{\rightsquigarrow }}_{\mathcal {R}} \; \dots \;\) Then \(t_1\sigma ^\omega _1 \rightarrow _{\mathcal {R}} t_2\sigma ^\omega _2 \rightarrow _{\mathcal {R}} \dots \) is an infinite \(\rightarrow _{\mathcal {R}} \)-sequence where \(\sigma ^\omega _i = \sigma _i\sigma _{i+1}\dots \;\) Since the terms in the rules of \({\mathcal {R}} \) are basic, all terms \(t_i\sigma ^\omega _i\) are basic, too.

For the “only if” direction, assume that there is an infinite rewrite sequence \(t_1 \rightarrow _{\mathcal {R}} t_2 \rightarrow _{\mathcal {R}} \dots \) on possibly infinite basic terms \(t_i\). We now show that for every finite prefix \(t_1 \rightarrow _{\mathcal {R}} t_2 \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m\) of this sequence, there is a rewrite sequence \(t_1' \rightarrow _{\mathcal {R}} t_2' \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m'\) with finite and linear basic terms \(t_i'\). This suffices for the current lemma, because it implies that the TRS does not have constant runtime complexity. As in the proof of Lemma 53 one can then show that there is an infinite narrowing sequence starting with a term \(f(x_1,\ldots ,x_k)\).

It remains to prove that for every finite rewrite sequence \(t_1 \rightarrow _{\mathcal {R}} t_2 \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m\) with possibly infinite basic terms \(t_i\), there is a rewrite sequence \(t_1' \rightarrow _{\mathcal {R}} t_2' \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m'\) with finite linear basic terms \(t_i'\), where there exists a substitution \(\sigma \) such that \(t_i'\sigma = t_i\) for all \(1 \le i \le m\). We prove this claim by induction on m.

The case \(m = 1\) is trivial. In the induction step, we consider the rewrite sequence \(t_1 \rightarrow _{\mathcal {R}} t_2 \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m\rightarrow _{\mathcal {R}} t_{m+1}\) of possibly infinite basic terms. By the induction hypothesis we have \(t_1' \rightarrow _{\mathcal {R}} t_2' \rightarrow _{\mathcal {R}} \dots \rightarrow _{\mathcal {R}} t_m'\) for finite linear basic terms \(t_i'\) where \(t_i' \sigma = t_i\) for all i. Let \(\ell \rightarrow r\) be the rule applied in the rewrite step from \(t_m\) to \(t_{m+1}\), i.e., \(t_m = \ell \delta \) and \(t_{m+1} = r\delta \). As \(t_m' \sigma = t_m = \ell \delta \) and as w.l.o.g., \(\ell \) is variable-disjoint from the \(t_i'\), this means that \(t_m'\) and \(\ell \) are unifiable. Let \(\theta = \mathrm {mgu}(t_m', \ell )\). By Lemma 54, the range of \(\theta \) consists of linear finite terms, as \(t_m'\) and \(\ell \) are linear and finite. Let \(\mu \) be a substitution such that \(\theta \mu \) is like \(\sigma \) on \(t_1',\ldots ,t_m'\) and like \(\delta \) on \(\ell \). We define \(t_i'' = t_i'\theta \) for all \(1 \le i \le m\) and \(t_{m+1}'' = r \theta \). Then we have \(t_1'' \rightarrow _{\mathcal {R}} \ldots \rightarrow _{\mathcal {R}} t_m'' = t_m'\theta = \ell \theta \rightarrow _{\mathcal {R}} r\theta = t_{m+1}''\). Moreover, we have \(t_i''\mu = t_i'\theta \mu = t_i'\sigma = t_i\) for all \(1 \le i \le m\) and \(t_{m+1}''\mu = r \theta \mu = r\delta = t_{m+1}\).

It remains to show that all \(t_i''\) are linear. Let \({\mathcal {V}} ' = {\mathcal {V}} (t'_1) \cup \ldots \cup {\mathcal {V}} (t_m')\). Since \(\ell \) is variable-disjoint from the \(t_i'\) and \(\theta = \mathrm {mgu}(t_m', \ell )\), \(\mathrm {range}(\theta |_{{\mathcal {V}} '})\) does not contain variables from \({\mathcal {V}} '\). Since each \(t_i'\) is linear and \(\mathrm {range}(\theta )\) consists of linear terms, this implies that \(t_1'', \ldots , t_m''\) are linear, too. Similarly, \(t_{m+1}''\) is linear, as \(\theta |_{{\mathcal {V}} (r)}\) does not contain variables from \({\mathcal {V}} (r)\), \(r\) is linear, and \(\mathrm {range}(\theta )\) consists of linear terms. \(\square \)

Lemmas 53 and 55 imply that for linear TRSs where the left- and right-hand sides of all rules are basic terms, a linear lower bound is equivalent to non-termination of rewriting on possibly infinite basic terms. We now reduce the immortality problem for Turing machines to this latter problem in order to show that it is undecidable.

Let \({\mathcal {M}} = (Q, \varGamma , \delta )\) be a Turing machine where \(Q\) is the set of states, \(\varGamma \) is the tape alphabet, and \(\_ \in \varGamma \) is the blank symbol. A configuration of the Turing machine has the form \((q,w,a,w')\) with \(q \in Q\), \(w, w' \in \varGamma ^\omega \), and \(a \in \varGamma \). It means that q is the current state, the symbol at the current position of the tape is a, the symbols right of the current position are described by the infinite word \(w'\), and the symbols left of it are described by the infinite word w. To ease the formulation, if \(w = b\,.\,{\overline{w}}\) then this means that b is the symbol directly left of the current position, i.e., w is the word obtained when reading the symbols on the tape from right to left. The transition function \(\delta : (Q \times \varGamma ) \rightarrow (Q \times \varGamma \times \{L,R\})\) induces a transition relation \(\rightarrow _{\mathcal {M}} \) on configurations where \((q_1,w_1,a_1,w_1') \rightarrow _{\mathcal {M}} (q_2,w_2,a_2,w_2')\) iff either

  • \(w_1 = a_2 \,.\, w_2, w_2' = b \,.\, w_1'\), and \(\delta (q_1,a_1) = (q_2, b, L)\)       or

  • \(w_2 = b \,.\, w_1, w_1' = a_2 \,.\, w_2'\), and \(\delta (q_1,a_1) = (q_2, b, R)\)

We say that \({\mathcal {M}} \) is mortal iff there is no infinite sequence \((q_1,w_1,a_1,w'_1) \rightarrow _{\mathcal {M}} (q_2,w_2,a_2,w'_2) \rightarrow _{\mathcal {M}} \dots \) of configurations. The difference to the halting problem is that for the mortality problem, one may start with a tape containing infinitely many non-blank symbols. Moreover, one can begin with any state \(q_1 \in Q\). As shown in [20], the (im)mortality problem for Turing machines is undecidable.

To reduce immortality of Turing machines to the termination of rewriting with infinite terms, we use the following encoding. For any Turing machine \({\mathcal {M}} =(Q, \varGamma , \delta )\), we define the TRS \({\mathcal {R}} _{\mathcal {M}} \). Here, \({\textsf {f}} \) has arity 4, all symbols from \(\varGamma \) become function symbols of arity 1, and \(Q \cup \{\underline{a} \mid a \in \varGamma \}\) are constants.

$$\begin{aligned} \begin{array}{rcll} {\mathcal {R}} _{\mathcal {M}} &{}=&{} \{{\textsf {f}} (q_1,a_2( xs ),\underline{a_1}, ys ) \rightarrow {\textsf {f}} (q_2, xs ,\underline{a_2},b( ys )) \mid a_2 \in \varGamma , \delta (q_1,a_1) = (q_2,b,L)\} &{}\cup \\ &{}&{}\{{\textsf {f}} (q_1, xs ,\underline{a_1},a_2( ys )) \rightarrow {\textsf {f}} (q_2,b( xs ),\underline{a_2}, ys ) \mid a_2 \in \varGamma , \delta (q_1,a_1) = (q_2,b,R)\}. \end{array} \end{aligned}$$

\({\mathcal {R}} _{\mathcal {M}} \) is a linear TRS where all terms are basic. Lemma 56 shows that mortality of \({\mathcal {M}} \) is equivalent to termination of \({\mathcal {R}} _{\mathcal {M}} \) on possibly infinite basic terms.

Lemma 56

(Mortality of turing machines and rewriting) A Turing machine \({\mathcal {M}} \) is immortal iff there is a possibly infinite basic term that starts an infinite rewrite sequence with \({\mathcal {R}} _{\mathcal {M}} \).

Proof

We define the following functions \(\mathsf {word}\) and \(\mathsf {word}^{-1}\) to convert infinite words over \(\varGamma \) to possibly infinite basic terms and vice versa.

$$\begin{aligned} \mathsf {word}(a \, . \, w) = a(\mathsf {word}(w)) \qquad \qquad \mathsf {word}^{-1}(t) = {\left\{ \begin{array}{ll} a \, . \, \mathsf {word}^{-1}(t') &{} \text {if } t = a(t')\\ \_^\omega &{} \text {otherwise} \end{array}\right. } \end{aligned}$$

For each configuration \((q,w,a,w')\) let \(\mathsf {term}(q,w,a,w') = {\textsf {f}} (q,\mathsf {word}(w),\underline{a},\mathsf {word}(w'))\).

For the “only if” direction, it suffices to show that \((q_1,w_1,a_1,w'_1) \rightarrow _{\mathcal {M}} (q_2,w_2, a_2, w'_2)\) implies \(\mathsf {term}(q_1,w_1,a_1,w'_1) \rightarrow _{{\mathcal {R}} _{\mathcal {M}}} \mathsf {term}(q_2,w_2,a_2,w'_2)\). We regard the case where \(\delta (q_1,a_1) = (q_2, b, L)\) (the case \(\delta (q_1,a_1) = (q_2, b, R)\) works analogously). Then \(w_1 = a_2 \,.\, w_2\) and \(w_2' = b \,.\, w_1'\). Thus, \(\mathsf {term}(q_1,w_1,a_1,w'_1) = {\textsf {f}} (q_1, a_2(\mathsf {word}(w_2)), \underline{a_1}, \mathsf {word}(w_1')) \rightarrow _{\mathcal {M}} {\textsf {f}} (q_2,\mathsf {word}(w_2),\underline{a_2},b(\mathsf {word}(w_1'))) = \mathsf {term}(q_2,w_2,a_2,w'_2)\), as desired.

For the “if” direction, it suffices to show that if \(t_1\) is a possibly infinite basic term with \(t_1 \rightarrow _{{\mathcal {R}} _{\mathcal {M}}} t_2\), then \( conf _1 \rightarrow _{\mathcal {M}} conf _2\) with \( conf _i = (t_i|_1, \mathsf {word}^{-1}(t_i|_2), \mathsf {char}(t_i|_3), \mathsf {word}^{-1}(t_i|_4))\) for both \(i\in \{1,2\}\), where \(\mathsf {char}(\underline{a}) = a\) . Clearly, we have \(t_i|_1 \in Q\) and \(t_i|_3 \in \{\underline{a} \mid a \in \varGamma \}\). We regard the case where the rule of \({\mathcal {R}} _{\mathcal {M}} \) used for the rewrite step corresponds to a shift to the left (the right shift works analogously). Then we have \(t_1 = {\textsf {f}} (q_1,a_2(s),\underline{a_1},s')\) and \(t_2 = {\textsf {f}} (q_2,s,\underline{a_2},b(s'))\) for \(a_1,a_2,b \in \varGamma \), some possibly infinite constructor terms \(s, s'\), and \(q_1,q_2 \in Q\). Moreover, by construction we have \(\delta (q_1,a_1) = (q_2,b,L)\). Hence, \( conf _1 = (q_1, a_2 \, . \, \mathsf {word}^{-1}(s), a_1, \mathsf {word}^{-1}(s')) \rightarrow _{\mathcal {M}} (q_2, \mathsf {word}^{-1}(s), a_2, b \, . \, \mathsf {word}^{-1}(s')) = conf _2\). \(\square \)

Theorem 39

(Undecidability and incompleteness of loop detection for linear bounds) For the class of linear TRSs where \(\ell , r \in {\mathcal {T}} _B\) for all rewrite rules \(\ell \rightarrow r\), it is not semi-decidable if \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\) holds. Hence for this class, loop detection is not complete for the inference of linear lower bounds.

Proof

For any Turing machine \({\mathcal {M}} \) we have the following:

$$\begin{aligned} \begin{array}{rl@{\;\;\;}l} &{}{\mathcal {M}} \text { is immortal}&{}\\ \text {iff} &{} \rightarrow _{{\mathcal {R}} _{\mathcal {M}}}\text { does not terminate on possibly infinite basic terms} &{}\text {(by Lemma 56)}\\ \text {iff} &{} {\rightsquigarrow } _{{\mathcal {R}} _{\mathcal {M}}}\text { does not terminate on basic terms } f(x_1,\ldots ,x_k) &{}\text {(by Lemma 55)}\\ \hbox { iff} &{} \text {}\ \mathrm {rc}_{{\mathcal {R}} _{\mathcal {M}}}(n) \in \varOmega (n)&{}\text {(by Lemma 53)} \end{array} \end{aligned}$$

Note that for linear TRSs \({\mathcal {R}} \) where the terms in all rules are basic, it is obviously semi-decidable if \({\rightsquigarrow } _{{\mathcal {R}} _{\mathcal {M}}}\) terminates on basic terms of the form \(f(x_1,\ldots ,x_k)\). Thus, a semi-decision procedure for \(\mathrm {rc}_{{\mathcal {R}} _{\mathcal {M}}}(n) \in \varOmega (n)\) would result in a decision procedure for mortality of Turing machines. However, mortality of Turing machines is known to be undecidable [20]. Thus, \(\mathrm {rc}_{\mathcal {R}} (n) \in \varOmega (n)\) cannot be semi-decidable for the class of linear TRSs \({\mathcal {R}} \) where \(\ell , r \in {\mathcal {T}} _B\) holds for all rewrite rules \(\ell \rightarrow r\).

Note that the existence of decreasing loops is semi-decidable, since one can recursively enumerate all possible rewrite sequences \(\ell \rightarrow ^+_{\mathcal {R}} C[r]\) and since it is decidable whether an actual rewrite sequence is a decreasing loop. This implies that loop detection by decreasing loops cannot be complete for linear lower bounds of linear TRSs where the terms in all rules are basic. \(\square \)

Theorem 46

(Linear lower bounds for \(\mathrm {irc}\) by loop detection) If a TRS \({\mathcal {R}} \) has an innermost decreasing loop, then we have \(\mathrm {irc}_{{\mathcal {R}}}(n) \in \varOmega (n)\).

Proof

Let \(\theta = [x_i / \ell |_{\xi _i} \mid 1 \le i \le m]\) be the pumping substitution of the innermost decreasing loop. We show that for all \(n \in \mathbb {N}\) and any substitution \(\delta \) where \(\overline{\ell }\,\theta ^n\,\delta \) is innermost terminating, we have \(\overline{\ell }\,\theta ^n\,\delta \; \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^+_{\mathcal {R}} \circ \unrhd \; \overline{\ell }\,\theta ^{n-1}\,\delta '\) for a substitution \(\delta '\). Thus, these rewrite steps can be repeated n times. In the following, let \(\overline{\delta }\) be a substitution such that for all \(x \in {\mathcal {V}} (\overline{\ell }\,\theta ^n)\), we have \(x\, \delta \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}} ^* x\, \overline{\delta }\) and \(x\, \overline{\delta }\) is in normal form. Then we obtain

$$\begin{aligned} \overline{\ell }\,\theta ^n\,\delta&\overset{{}_{\mathsf {i}}{}\,}{\rightarrow } ^*_{\mathcal {R}} \overline{\ell }\,\theta ^n\,\overline{\delta } = \ell \,\theta ^{n-1}\,\overline{\delta } \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}} ^+ C[r]\,\theta ^{n-1}\,\overline{\delta }\\&\unrhd r\,\theta ^{n-1}\,\overline{\delta } = \overline{\ell }\,\sigma \,\theta ^{n-1}\,\overline{\delta } \mathop {=}\limits ^{(\star )} \overline{\ell }\,\theta ^{n-1} \, (\sigma \, \theta ^{n-1})|_{{\text {dom}} (\sigma )} \,\overline{\delta } = \overline{\ell }\,\theta ^{n-1}\, \delta ' \end{aligned}$$

for the substitution \(\delta ' = (\sigma \,\theta ^{n-1})|_{{\text {dom}} (\sigma )} \, \overline{\delta }\). The rewrite sequence \(\ell \,\theta ^{n-1}\,\overline{\delta } \; \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}} ^+ \; C[r]\,\theta ^{n-1}\,\overline{\delta }\) is indeed an innermost reduction. To see this, recall that \(\overline{\delta }\) only instantiates variables by normal forms. Moreover, \(\theta \) has no defined symbols in its range, since \(\ell \) is basic. For this reason, \(\theta ^{n-1}\,\overline{\delta }\) also instantiates all variables by normal forms, i.e., no rewrite step is possible for the terms in the range of \(\theta ^{n-1}\,\overline{\delta }\). Moreover, the subterms of the redexes in the reduction \(\ell \, \overset{{}_{\mathsf {no}}{}\,}{\rightarrow } _{\mathcal {R}} ^+ \, C[r]\) do not unify with left-hand sides of rules. Hence, these subterms remain in normal form if one instantiates them with \(\theta ^{n-1}\,\overline{\delta }\). This implies \(\ell \,\theta ^{n-1}\,\overline{\delta } \; \overset{{}_{\mathsf {i}}{}\,}{\rightarrow } _{\mathcal {R}} ^+ \; C[r]\,\theta ^{n-1}\,\overline{\delta }\). The step marked with \((\star )\) holds because \(\sigma \) does not instantiate variables that occur in the domain or the range of \(\theta \), as in the proof of Theorem 31.

Note that for any \(n \in \mathbb {N} \), the term \(\overline{\ell }\, \theta ^n\) is basic, since the range of \(\theta \) only contains constructor terms \(\ell |_{\xi _i}\) (since \(\xi _i\) cannot be the root position due to the requirement \(r \notin {\mathcal {V}} \)). Hence, if \(\overline{\ell }\, \theta ^n\) is not innermost terminating for some \(n \in \mathbb {N} \), then we obtain \(\mathrm {irc}_{\mathcal {R}} (n) \in \varOmega (\omega )\), and therefore also \(\mathrm {irc}_{\mathcal {R}} (n) \in \varOmega (n)\). Otherwise, by the observations above, for each \(n \in \mathbb {N} \) there is an innermost rewrite sequence of length \(n\) starting with \(\overline{\ell }\, \theta ^n\). As in the proof of Theorem 31, \(\theta \) does not duplicate variables and thus, \(|\overline{\ell }\,\theta ^n| \in \mathcal {O}(n)\). Hence, we obtain \(\mathrm {irc}_{\mathcal {R}} (n) \in \varOmega (n)\). \(\square \)

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Frohn, F., Giesl, J., Hensel, J. et al. Lower Bounds for Runtime Complexity of Term Rewriting. J Autom Reasoning 59, 121–163 (2017). https://doi.org/10.1007/s10817-016-9397-x

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s10817-016-9397-x

Keywords

Navigation