Termination of Cycle Rewriting by Transformation and Matrix Interpretation

. We present techniques to prove termination of cycle rewriting, that is, string rewriting on cycles, which are strings in which the start and end are connected. Our main technique is to transform cycle rewriting into string rewriting and then apply state of the art techniques to prove termination of the string rewrite system. We present three such transformations, and prove for all of them that they are sound and complete. In this way not only termination of string rewriting of the transformed system implies termination of the original cycle rewrite system, a similar conclusion can be drawn for non-termination. Apart from this transformational approach, we present a uniform framework of matrix interpretations, covering most of the earlier approaches to automatically proving termination of cycle rewriting. All our techniques serve both for proving termination and relative termination. We present several experiments showing the power of our techniques.


Introduction
Cycles can be seen as strings of which the left end is connected to the right end, by which the string has no left end or right end any more.In Fig. 1 a pictorial representation of two such cycles is shown.
String rewriting can not only be applied on strings, but also on cycles.Applying string rewriting on cycles, i.e. replacing a substring of a cycle by another substring, is briefly called cycle rewriting.For instance, applying the string rewrite rule aaa → ababa to the cycle in Fig. 1 (a) results in the cycle shown Fig. 1 (b).
Rewriting behavior is strongly influenced by allowing cycles, for instance, in string rewriting the single rule ab → ba is terminating, but in cycle rewriting it is not, since the string ab represents the same cycle as ba.In many areas cycle rewriting is more natural than string rewriting.For instance, the problem of 5 dining philosophers can be expressed as a cycle F T F T F T F T F T where F denotes a fork, and T denotes a thinking philosopher.Writing L for a philosopher who has picked up her left fork, but not her right fork, and E for an eating philosopher, a classical (deadlocking) modeling of the dining philosophers problem (for arbitrary many philosophers) can be expressed by the cycle rewrite system consisting of the rules T F → L, F L → E, E → F T F .As a cycle rewrite system this is clearly not terminating.
Also from the viewpoint of graph transformation, cycle rewriting is very natural.For instance, in [3] it was shown that if all rules of a graph transformation system are string rewrite rules, termination of the transformation system coincides with termination of the cycle rewrite system, and not with termination of the string rewrite system.Developing techniques to prove cycle termination also helps to understand and develop new techniques for proving termination of graph transformation systems (see e.g.[2]).
So both string rewriting and cycle rewriting provide natural semantics for string rewrite systems, also called semi-Thue systems.Historically, string rewriting got a lot of attention as being a particular case of term rewriting, while cycle rewriting hardly got any attention until recently.In 2015 automated proving of cycle termination became a new category in the Termination Competition [11,21].In 2015 two tools participated, and in 2016 three tools participated in the category.
In [28] a first investigation of termination of cycle rewriting was made.Some techniques were presented to prove cycle termination, implemented in a tool torpacyc.Further a transformation φ was given such that for every string rewriting system (SRS) R, string termination of R holds if and only if cycle termination of φ(R) holds.As a consequence, cycle termination is undecidable.
However, for making use of the strong power of current tools for proving termination of string rewriting in order to prove cycle termination, a transformation the other way around is needed: transformations ψ such that for every SRS R, cycle termination of R holds if and only if string termination of ψ(R) holds.The 'if' direction in this 'if and only if' is called 'sound', the 'only if' is called complete.This implies a way to prove cycle termination of an SRS R: apply a tool for proving termination of string rewriting to ψ(R) for a sound transformation ψ.Conversely, a way to prove cycle non-termination of R is to prove nontermination of ψ(R) for a complete transformation ψ.The main topic of this paper is to investigate such transformations, and to exploit them to prove termination of cycle rewriting, or non-termination, or relative (non-)termination.Here relative termination deals with two rewrite systems: relative termination means that every infinite reduction of the union of them contains only finitely many steps of one of them.In detail we give fully worked-out proofs of soundness and completeness for three approaches to transform cycle termination into string termination (called split, rotate, and shift), and also for relative termination.
Using transformations to exploit the power of tools for termination of term rewriting to prove a modified property was used before in [13,12].However, there the typical observation was that the complete transformations were complicated, and for non-trivial examples, termination of ψ(R) could not be proved by the tools, while for much simpler sound (but incomplete) transformations ψ, termination of ψ(R) could often be proved by the tools.In our current setting this is different: one of our introduced transformations, the transformation split, for which we prove that it is sound and complete, we show that for several systems R for which all approaches from [28] fail, cycle termination of R can be concluded from an automatic termination proof of split(R) generated by AProVE [10,1] or T T T 2 [17,24].
It can be shown that if strings of size n exist admitting cycle reductions in which for every rule the number of applications of that rule is more than linear in n, then all techniques from [28] fail to prove cycle termination.Nevertheless, in quite simple examples this may occur while cycle termination holds.As an example consider the following.
A number of people are in a circle, and each of them carries a number, represented in binary notation with a bounded number of bits.Each of them may increase his/her number by one, as long as it fits in the bounded number of bits.Apart from that, every person may increase the number of bits of the number of its right neighbor by two.In order to avoid trivial non-termination, the latter is only allowed if the leading bit of the number is 0, and the new leading bit is put to 1, and the other to 0, by which effectively one extra bit is added.We will prove that this process will always terminate by giving an SRS in which all of the above steps can be described by a number of cycle rewrite steps, and prove cycle termination.In order to do so we write P for person, and 0 and 1 for the bits of the binary number.For carry handling we introduce an extra symbol c of which the meaning is a 1 with a carry.Assume for every person its number is stored left from it.So if the number ends in 0, by adding one this last bit 0 is replaced by 1, expressed by the rule 0P → 1P .In case the number ends in 1, a carry should be created, since c represents a 1 with a carry this is expressed by the rule 1P → cP .Next the carry should be processed.In case it is preceded by 0, this 0 should be replaced by 1, while the c is replaced by 0; this is expressed by the rule 0c → 10.In case it is preceded by 1, a new carry should be created while again the old carry is replaced by 0; this is expressed by the rule 1c → c0.In this way adding one to any number in binary notation can be expressed by a number of rewrite steps, as long as no overflow occurs.Finally, we have to add a rule to extend the bit size of the number of the right neighbor: the leading bit should be 0, while it is replaced by 100: adding two extra bits of which the leading one is 1 and the other is 0. This is expressed by the rule P 0 → P 100.Summarizing: we have to prove cycle termination of the SRS consisting of the five rules 0P → 1P, 1P → cP, 0c → 10, 1c → c0, P 0 → P 100.This is fundamentally impossible by the techniques presented in [28]: by one of the techniques the last rule can be removed, but starting in 0 n P a reduction can be made in which all of the remaining four rules are applied an exponential number of times, by which the techniques from [28] fail.
In this paper we give two ways to automatically prove that cycle termination holds for the above example R: T T T 2 succeeds in proving termination of split(R), and the other is a variant of matrix interpretations for which we show that it proves cycle termination.The latter is another main topic of this paper: we give a self-contained uniform presentation of trace-decreasing matrix interpretations for cycle termination that covers the tropical and arctic variant from [28] and the natural variant from [18], now also serving for relative termination.In this way we cover all current known techniques for proving cycle termination except for match bounds ( [28]).
The paper is organized as follows.Section 2 recalls the basics of cycle rewriting and introduces relative cycle termination.The main section Section 3 first adapts type introduction [26] for string rewriting and relative termination (Theorem 3.3), and then the three transformations split, rotate, and shift are presented and soundness and completeness of all of them is proved (Theorems 3.13, 3.30, and 3.46).Also adapted transformations for relative cycle transformation are presented and their soundness and completeness is shown (Theorems 3.18, 3.32, and 3.48).In Section 4 trace-decreasing matrix interpretations are presented, and we show how they can be used to prove cycle termination (Theorem 4.1) and relative cycle termination (Theorem 4.2) for the three instances of natural, tropical and arctic matrix interpretations.In Section 5 experiments on implementations of our techniques are reported.We conclude in Section 6.
Compared to our paper [18], this paper contains full proofs, extends all the termination techniques to relative termination, and presents a framework for matrix interpretations which covers and extends the previous approaches presented in [28,18].

Preliminaries
In this section we briefly recall the required notions for string and cycle rewriting.
A signature Σ is a finite alphabet of symbols.With Σ * we denote the set of strings over Σ.With ε we denote the empty string and for u, v ∈ Σ * , we write uv for the concatenation of the strings u and v.With |u| we denote the length of string u ∈ Σ * and for a ∈ Σ and n ∈ IN, a n denotes n replications of symbol a, i.e. a 0 = ε and a i = aa i−1 for i > 0.
Given a binary relation →, we write → i for i steps, → ≤i for at most i steps, → <i for at most i − 1 steps, → * for the reflexive-transitive closure of →, and → + for the transitive closure of →.For binary relations → 1 and → 2 , we write → 1 .→ 2 for the composition of → 1 and → 2 , i.e. a → 1 .→ 2 c iff there exists a b s.t. a → 1 b and b → 2 c.

String Rewriting
sometimes also a reduction or a derivation).For an SRS R, the rewrite relation → R is called non-terminating if there exists a string w ∈ Σ * and an infinite rewrite sequence ) we also say R is string terminating (string non-terminating, resp.).

Cycle Rewriting.
We recall the notion of cycle rewriting from [28].A string can be viewed as a cycle, i.e. the last symbol of the string is connected to the first symbol.To represent cycles by strings, we define the equivalence relation ∼ as follows: With [u] we denote the equivalence class of string u w.r.t.∼.
The cycle rewrite relation The cycle rewrite relation •→ R is called non-terminating iff there exists a string w ∈ Σ * and an infinite sequence ) we also say that R is cycle terminating (cycle non-terminating, resp.).
We recall some known facts about cycle rewriting.
Proposition 2.1 (see [28]).Let Σ be a signature, R be an SRS, and u, v ∈ Σ * . ( (5) For every SRS R there exists a transformed SRS φ(R) s.t. the following three properties are equivalent: For an SRS R, the last property implies that termination of → R can be proved by proving termination of the translated cycle rewrite relation •→ φ(R) .In [28] it was used to show that termination of cycle rewriting is undecidable and for further results on derivational complexity for cycle rewriting.

2.3.
Relative Termination.We will also consider relative termination of cycle and string rewrite systems.Hence, in this section we recall the definition of relative termination of string rewrite systems (see e.g.[9]) and introduce relative cycle termination.
Let S ⊆ R be string rewrite systems over an alphabet Σ.If the string rewrite relation → S is terminating relative to the string rewrite relation → R then we say S is string terminating relative to R. If the cycle rewrite relation •→ S is terminating relative to the cycle rewrite relation •→ R then we say S is cycle terminating relative to R.
For S ⊆ R, we sometimes call R \ S the weak rules and S the strict rules.We often write rules in R \ S as ℓ →= r and rules in S as ℓ → r.
Note that for all SRSs R and S the identities hold, which we will sometimes use.
Since every string rewrite step, is also a cycle rewrite step (on the equivalence class w.r.t.∼), any infinite string rewrite sequence giving evidence for string non-termination, also gives evidence for cycle non-termination.Thus we have: Corollary 2.3.If S is cycle terminating relative to R, then S is also string terminating relative to R.
However, as for usual termination, relative cycle termination is different from relative string termination: Example 2.4.Let S = {ab → ca} and R = S ∪ {c →= b}.Then S is string terminating relative to R (which is easy to prove), while S is not cycle terminating relative to R, since the infinite (looping The following proposition provides several characterizations for relative termination.We formulate it in a general form (for all binary relations).Even though its proof is quite standard, we include it for the sake of completeness.
Proposition 2.5.Let → 1 ⊆→ 2 be binary relations on a set O. The following five propositions are equivalent: (1) The relation Proof.We show the claim by a chain of implications: 2 is non-terminating, then the infinite rewrite sequence consisting of infinitely many → * 2 .→ 1 .→ * 2 -steps contains infinitely many → 1 -steps.For SRSs S ⊆ R , the previous proposition can be instantiated with → 1 := → S and → 2 := → R to derive characterizations of relative string termination, and with → 1 := •→ S and → 2 := •→ R to derive characterizations of relative cycle termination.

Transforming Cycle Termination into String Termination
The criteria given in Proposition 2.1 and the involved transformation φ, which transforms string rewriting into cycle rewriting, provide a method to prove string termination by proving cycle termination.However, it does not provide a method to prove termination of the cycle rewrite relation •→ R by proving termination of the string rewrite relations → R or → φ(R) .Hence, in this section we develop transformations ψ s.t.termination of → ψ(R) implies termination of •→ R .We call such a transformation ψ sound.However, there are "useless" sound transformations, for instance, transformations where ψ(R) is always nonterminating.So at least one wants to find sound transformations which permit to prove termination of non-trivial cycle rewrite relations.However, a better transformation should fulfill the stronger property that → ψ(R) is terminating if and only if •→ R is terminating.If termination of •→ R implies termination of → ψ(R) , then we say ψ is complete.For instance, for a complete transformation, non-termination proofs of → ψ(R) also imply non-termination of •→ R .Hence, our goal is to find sound and complete transformations ψ.
Besides such transformations, we will consider transformations ψ rel (S, R) = (S ′ , R ′ ) which are sound and complete for relative termination, i.e. transformations which transform (S, R) with S ⊆ R , such that cycle termination of S relative to R holds, if and only if S ′ is string terminating relative to R ′ .
We will introduce and discuss three transformations split, rotate, and shift where the most important one is the transformation split, since it has the following properties: The transformation is sound and complete, and as our experimental results show, it behaves well in practice when proving termination of cycle rewriting.The other two transformations rotate and shift are also sound and complete, but rather complex and -as our experimental results show -they do not behave as well as the transformation split in practice.We include all three transformations in this paper to document some different approaches to transform cycle rewriting into string rewriting.We also consider variations of the three transformations for relative termination.We show that all three variations are sound and complete transformations for relative termination.
Since our completeness proofs, use type introduction [26], we recall this technique in Section 3.1 focused on typed string rewriting only, and prove a (novel) theorem that type introduction is correct for relative string termination.In the remaining sections 3.2, 3.3, and 3.4 we successively introduce and treat the three transformations.

Type Introduction.
The technique of type introduction was presented in [26], for termination of term rewriting.Here we are only interested in string rewriting (being the special case of term rewriting having only unary symbols), but for our purpose need to extend this result to relative termination.
An signature Σ is typed if there is a set T of types (also called sorts), and every a ∈ Σ has a source type τ 1 ∈ T and a target type τ 2 ∈ T, notation a : For a non-empty string w ∈ Σ + its target target(w) is defined to be the target of its first element; its source source(w) is defined to be the source of its last element.A non-empty string w ∈ Σ + is called well-typed if either it is in Σ, or it is of the shape au for a ∈ Σ and u ∈ Σ + is well-typed, and source(a) = target(u).
An SRS is called well-typed if for every rule ℓ → r we either have • r = ε and source(ℓ) = target(ℓ), or • r = ε and source(ℓ) = source(r) and target(ℓ) = target(r).The following lemma is straightforward.Lemma 3.1.If R is a well-typed SRS over Σ and w → R w ′ for w ∈ Σ + being well-typed, then w ′ is well-typed too.
So in an infinite reduction with respect to a well-typed SRS, all strings are well-typed if and only if the initial string is well-typed.
For a well-typed SRS R, we say that R is string terminating in the typed setting if there does not exist an infinite → R -reduction consisting of well-typed strings.
For well-typed SRSs S ⊆ R we say that S is string terminating relative to R in the typed setting if every infinite → R -reduction consisting of well-typed strings contains only finitely many → S -steps.
The main theorem, to be exploited several times in this paper, states that this notion of relative termination in the typed setting is equivalent to the notion of relative termination in the general setting without typing requirements.
In order to prove this theorem we need a notion of decomposition of (possibly untyped) strings and a lemma stating some key properties of this decomposition.We denote a string consisting of n strings u 1 , . . ., u n by [u 1 , . . ., u n ].The decomposition Dec(u) of a string u ∈ Σ + is such a string of strings and is defined as follows: • Dec(a) = [a], • if u ∈ Σ + and Dec(u) = [u 1 , . . ., u n ], then -Dec(au) = [au 1 , . . ., u n ] if source(a) = target(u 1 ), and -Dec(au) = [a, u 1 , . . ., u n ] if source(a) = target(u 1 ).By construction for any u ∈ Σ + with Dec(u) = [u 1 , . . ., u n ] we have the following properties: • u i is well-typed for i = 1, . . ., n; • if v is a well-typed substring of u, then it also a substring of u i for some i = 1, . . ., n; As we consider well-typed SRSs only, with non-empty left hand sides, every rewrite step applied on such u applies to one of the corresponding u i .In case of a collapsing rule, that is, a rule with empty right hand side, it may be the case that a type clash is removed, decreasing the length |Dec(u)| of Dec(u).For instance, for a : Now we are prepared for the main theorem.The way it is used is as follows: for proving (relative) termination, try to find a typing such that the SRS is well-typed.Then according to the theorem the infinite reduction for which a contradiction has to be derived, may be assumed to be well-typed.Theorem 3.3.Let S ⊆ R be well-typed SRSs with non-empty left hand sides.Then S is string terminating relative to R if and only if S is string terminating relative to R in the typed setting.
Proof.The 'only if'-part is trivial.For the 'if'-part assume we have an infinite R-reduction well-typed; we have to prove it contains only finitely many S-steps.According to the first claim of Lemma 3.2 there exist n, N such |Dec(u i )| = |Dec(u i+1 )| = n for all i ≥ N .Write Dec(u i ) = [u i1 , . . ., u in ] for i ≥ N .According to the second part of Lemma 3.2 for every j = 1, . . ., n we have either u ij = u i+1,j or u ij → R u i+1,j for i ≥ N .If u ij → R u i+1,j occurs infinitely often this yields a well-type infinite R-reduction, containing only finitely many S-steps since S is terminating relative to R in the typed setting.
If u ij → R u i+1,j occurs finitely often, it also contains only finitely many S-steps.As the number of S-steps in the finite part u 1 → * R u N is finite too, we conclude that the total number of S-steps in the original reduction is finite.
By instantiating the previous theorem with S = R we obtain correctness of type introduction for string termination: Corollary 3.4.Let R be a well-typed SRS.Then R is string terminating if and only if R is string terminating in the typed setting.
3.2.The Transformation Split.The idea of the transformation split is to perform a single cycle rewrite step [u] •→ R [v] which uses rule (ℓ → r) ∈ R, by either applying a string rewrite step u → R v or by splitting the rule (ℓ → r) into two rules (ℓ p → r p ) and (ℓ s → r s ), where ℓ = ℓ p ℓ s and r = r p r s .Then a cycle rewrite step can be simulated by a prefix and a subsequent suffix rewrite step: first apply rule ℓ s → r s to a prefix of u and then apply rule ℓ p → r p to a suffix of the obtained string.
We consider the cases for u 2 : (1) If u i = ε (for i = 1 or i = 2), then u = ℓw and u ֒→ R rw by a prefix string rewrite step.
a proper prefix of ℓ, then there exist ℓ p , ℓ s with ℓ = ℓ p ℓ s s.t.u 2 = ℓ p and ℓ s is a non-empty prefix of u 1 , i.e. u 1 = ℓ s w and u = u 1 u 2 = ℓ s wℓ p ֒→ {ℓs→rs} r s wℓ p ֒→ {ℓp→rp} r s wr p ∼ rw if r p r s = r.The three cases show that a cycle rewrite step [u] •→ {ℓ→r} [v] can either be performed by applying a string rewrite step u → {ℓ→r} v ′ where v ′ ∼ v (cases 1 and 2) or in case 3 by splitting ℓ → r into two rules ℓ p → r p and ℓ s → r s such that u ֒→ {ℓs→rs} u ′ replaces a prefix of u by r s and u ′ ֒→ {ℓp→rp} v ′ replaces a suffix of u ′ by r p s.t.v ′ ∼ v.For splitting a rule (ℓ → r) into rules ℓ p → r p and ℓ s → r s , we may choose any decomposition of r for r p and r s (s.t.r = r p r s ).In the following, we will work with r p = r and r s = ε.
The above cases for cycle rewriting show that a sound transformation of the cycle rewrite relation •→ R into a string rewrite relation is the SRS which consists of all rules of R and all pairs of rules ℓ s → ε and ℓ p → r for all (ℓ → r) ∈ R and all ℓ p , ℓ s with |ℓ p | > 0, |ℓ s | > 0, and ℓ = ℓ p ℓ s .However, this transformation does not ensure that the rules evolved by splitting are used as prefix and suffix rewrite steps only.Indeed, the transformation in this form is useless for nearly all cases, since whenever the right-hand side r of a rule (ℓ → r) ∈ R contains a symbol a ∈ Σ which is the first or the last symbol in ℓ, then the transformed SRS is non-terminating.For instance, for R = {aa → aba} the cycle rewrite relation •→ R is terminating, while the rule a → aba (which would be generated by splitting the left-hand side of the rule) leads to non-termination of the string rewrite relation.Note that this also holds if we choose any other decomposition of the right-hand side.Hence, in our transformation we introduce additional symbols to ensure: • ℓ s → ε can only be applied to a prefix of the string.
• ℓ p → r can only be applied to a suffix of the string.
• If ℓ s → ε is applied to a prefix, then also ℓ p → r must be applied, in a synchronized manner (i.e.no other rule ℓ ′ B → ε or ℓ ′ A → r ′ can be applied in between).In detail, we will prepend the fresh symbol B to the beginning of the string, and append the fresh symbol E to the end of the string.These symbols guarantee, that prefix rewrite steps ℓu ֒→ (ℓ→r) ru can be expressed with usual string rewrite rules by replacing the left hand side ℓ with Bℓ and analogous for suffix rewrite steps uℓ ֒→ (ℓ→r) ur by replacing the left hand side ℓ with ℓE.
Let (ℓ i → r i ) be the i th rule of the SRS which is split into two rules ℓ s → ε and ℓ p → r i , where ℓ p ℓ s = ℓ i .After applying the rule ℓ s → ε to a prefix of the string, the symbol B will be replaced by the two fresh symbols W (for "wait") and R i,j where i represents the i th rule and j means that ℓ i has been split after j symbols (i.e.|ℓ p | = j).The fresh symbol L is used to signal that the suffix has been rewritten by rule ℓ p → r.Finally, we use a copy of the alphabet, to ensure completeness of the transformation: for an alphabet Σ, we denote by Σ a fresh copy of Σ, i.e.Σ = {a | a ∈ Σ}.For a word w ∈ Σ * with w ∈ Σ * , we denote the word w where every symbol a is replaced by a. Analogously, for a word w ∈ Σ * with w ∈ Σ, we denote w where every symbol a is replaced by the symbol a.
Definition 3.6 (The transformation split).Let R = {ℓ 1 → r 1 , . . ., ℓ n → r n } be an SRS over alphabet Σ.Let Σ be a fresh copy of Σ and let B, E, W, R i,j , L be fresh symbols (fresh for Σ ∪ Σ).The SRS split(R) over alphabet Σ ∪ Σ ∪ {B, E, L, W} ∪ n i=1 {R i,j | 1 ≤ j < |ℓ i |} consists of the following string rewrite rules: We describe the intended use of the rules and the extra symbols.The symbols B and E mark the start and the end of the string, i.e. for a cycle [u] the SRS split(R) rewrites BuE.
The rule (splitA) covers the case that also u → R w holds.Now assume that for w ′ ∼ w we have u ֒→ {ℓs→ε} v ֒→ {ℓp→r} w ′ (where (ℓ p ℓ s → r) ∈ R).Rule (splitE) performs the prefix rewrite step and replaces B by W to ensure that no other such a rule can be applied.Additionally, the symbol R i,j corresponding to the rule and its splitting is added to ensure that only the right suffix rewrite step is applicable.Rule (splitD) moves the symbol R i,j to right and rule (splitF) performs the suffix rewrite step.Rules (splitB) and (splitC) are used to finish the simulation of the cycle rewrite step by using the symbol L to restore the original alphabet and to finally replace WL by B.
Example 3.7.For R 1 = {aa → aba} the transformed string rewrite system split(R 1 ) is: For instance, the cycle rewrite step [aba] •→ R 1 [baba] is simulated in the transformed system by the following sequence of string rewrite steps (where the redex is highlighted by a gray background): As a further example, for the system R 2 = {abc → cbacba, aa → a}, the transformed string rewrite system split(R 2 ) is: Termination of split(R 1 ) and split(R 2 ) can be proved by AProVE and T T T 2 .
3.2.1.Completeness of Split.We use type introduction for string rewriting (see Section 3.1) and use the set of types T := {A, A, K, T } and type the symbols used by split(R) as follows: First one can verify that split(R) is a typed SRS, i.e. the left hand sides and right hand sides are well-typed with the same type: (splitA) rewrites strings of type A → A, (splitB) and (splitD) rewrite strings of type A → A, (splitC) and (splitE) rewrite strings of type A → T , and (splitF) rewrites strings of type K → A. Thus split(R) is a typed SRS.Lemma 3.9.If a typed string w of type τ 1 → τ 2 with τ 1 , τ 2 ∈ T admits an infinite reduction w.r.t.split(R), then there exists a typed string w ′ of type K → T , which admits an infinite reduction w.r.t.split(R).
Proof.Assume that w is of type τ 1 → τ 2 = K → T .Note that τ 1 = T and τ 2 = K, since no well-typed, non-empty strings of these types exist.
We prepend and append symbols to w, resulting in a string uwv s.t.uwv is well-typed with type Inspecting the typing of the symbols shows: Lemma 3.10.Any well-typed string of type K → T is of one of the following forms: • BuE where u ∈ Σ * , • WwLuE where w ∈ Σ * and u ∈ Σ * , or • WwR i,j uE where w ∈ Σ * and u ∈ Σ * .
We define a mapping from well-typed strings of type K → T into untyped strings over Σ as follows: Definition 3.11.For a string w : K → T , the string Φ(w) ∈ Σ * is defined according to the cases of Lemma 3.10: Lemma 3.12.Let w be a well-typed string of type K → T and w We inspect the cases of Lemma 3.10 for w: It remains to show that the constructed sequence is infinite.One can observe that the infinite → split(R) -sequence starting with w must have infinitely many applications of rule (splitF), since every sequence of Remark 3.14.Note that simulating a cycle rewrite step w •→ R w ′ requires O(|w|) → split(R)steps.Thus the derivation height of split(R) (i.e. the length of a maximal string rewrite sequence for BwE) is asymptotically the square of the derivation height of R (i.e. the length of a maximal cycle rewrite sequence for w).Note also that the same arguments and properties apply to the two other transformations, shift and rotate, which will be presented later.
3.2.2.Relative Termination.We discuss how the transformation split can be adapted to show relative termination of cycle rewriting.With splitA(•) (and splitF (•), resp.)we denote the rules which are generated by the transformation split(•) according to rule (splitA) (and (splitF), resp.).The idea of using the transformation split for relative termination, is to transform S ⊆ R into split(R) where, only the rules corresponding to splitA(S) and splitF (S) become strict rules, while all other rules are weak rules in the transformed system.
Definition 3.15.Let S ⊆ R be SRSs over alphabet Σ.The transformation split rel is defined as follows: The termination provers AProVE and T T T 2 automatically show that S ′ is string terminating relative to R ′ .Since -as we show belowsplit rel is sound for relative termination, we can conclude that S is cycle terminating relative to R.
As another example, consider S = {aa → aba} and R = S ∪ {ab →= ba}, and let split rel (S, R) = (S ′ , R ′ ).Both provers show that S ′ is not terminating relative to R ′ .Since the transformation is also complete for relative termination, we can conclude that S is not cycle terminating relative to R, which can also be verified by the following counter-example: For S ⊆ R and split rel (S, R) = (S ′ , R ′ ), we will show that S is cycle terminating relative to R if, and only if S ′ is string terminating relative to R ′ .
First note that for every SRS R and every cycle rewrite step, where v j ∼ v ′ j for j = 1, 2 and the → split(R) -sequence contains exactly one application of rule splitA(R) or splitF (R) (see Proposition 3.8 and inspect the construction of split).
Proposition 3.17.The transformation split rel is sound for relative termination.
Proof.Let Σ A be an alphabet, S ⊆ R be SRSs over Σ A , and split rel (S, R) = (S ′ , R ′ ).Assume that S is not cycle terminating relative to R. Then there exists an infinite reduction The sequence u ′ i → + split(S) w i+1 uses exactly once the rule splitA(S) or the rule splitF (S).Thus we have For proving completeness, we again use the typed variant of the string rewrite system.Theorem 3.18.The transformation split rel is sound and complete for relative termination.
Proof.Soundness was proved in Proposition 3.17.For completeness, let S ⊆ R, split rel (S, R) = (S ′ , R ′ ) and assume that a string w 1 of type K → T has an infinite reduction of the form . .(which is sufficient due to Theorem 3.3 and Proposition 2.5).
We first consider the first reductions of the form Now, for the reduction sequences )] for all i = 1, 2, . ... Hence, S is not cycle terminating relative to R.

The Transformation Shift.
We first present the general ideas of the transformation shift before giving its definition.We write for the relation which moves the first element of a string to the end, i.e. au ua for every a ∈ Σ and u ∈ Σ * .Clearly, u ∼ v if and only if u <|u| v.
For a string rewrite system R, we define len(R) as the size of the largest left-hand side of the rules in R, i.e. len(R) = max (ℓ→r)∈R |ℓ|.
The approach of the transformation shift is to shift at most len(R) − 1 symbols from the left end to the right end and then to apply a string rewrite step (i.e. this the relation <len(R) .→ R ).The approach of transformation shift is to simulate the cycle rewrite step, by first shifting symbols from the left end to the right end of the string until abc becomes a substring, and then applying a string rewrite step, i.e. bcdda <len(R) .→ R ddbbbb, since bcdda cddab ddabc → R ddbbbb.
The following lemma obviously holds: Lemma 3.20.Let R be an SRS over an alphabet Σ and u, v Moreover, we can restrict the number of -steps before a rewrite step: Using the previous lemmas, we are able to prove the following proposition: and by the second part of the lemma, we can always move more than len(R) -steps to the right, and thus we derive an infinite sequence w 1 • and thus w 1 admits an infinite reduction of the required form.
For an SRS R, the SRS shift(R) encodes the relation <len (R) .→ R where extra symbols are used to separate the steps, and copies of the alphabet underlying R are used to ensure completeness of the transformation.
For the remainder of the section, we fix an SRS R over alphabet Σ A = {a 1 , . . ., a n }.Let us write Σ B , Σ C for fresh copies of the alphabet Σ A .We use the following notation to switch between the alphabets: for X, Y ∈ {A, B, C} and w ∈ Σ X we write w Y to denote the copy of w in the alphabet Y where every symbol is translated from alphabet X to alphabet Y .Definition 3.22 (The transformation shift).Let R be an SRS over alphabet Σ A and let N = max(0, len(R)−1).The SRS shift(R) over the alphabet Σ A ∪Σ B ∪Σ C ∪{B, E, W, V, M, L, R, D} (where B, E, W, V, M, L, R, D are fresh for Σ A ∪ Σ B ∪ Σ C ) consists of the following rules: The rules (shiftA) -(shiftE) encode the relation <len(R) , i.e. for uv ∈ Σ * A with |u| < len(R), the string BuvE is rewritten into WVvuE by these five rules.The sequence of symbols M generated by rule (shiftA) denotes the potential of moving at most len(R) − 1 symbols.The rules (shiftB) and (shiftC) either remove one from the potential or start the moving of one symbol.The rule (shiftD) performs the movement of a single symbol until it reaches the end of the string and rule (shiftE) finishes the movement.
The remaining rewrite rules perform a single string rewrite step, i.e. for a rule (ℓ → r) ∈ R the string WVw 1 ℓw 2 E is rewritten to Bw 1 rw 2 E by rules (shiftF) -(shiftJ).
Example 3.23.For R 1 = {aa → aba}, the transformed string rewrite system shift(R 1 ) is: The cycle rewrite step [aba] •→ R 1 [baba] is simulated in the transformed system as follows: Together with Proposition 3.21, the following lemma implies soundness of the transformation shift.
Then the following rewrite sequence using shift(R) can be constructed: We prove completeness by using type introduction.Let us write Σ Proof.Let w be a well-typed string of type τ 1 → τ 2 = K → T where τ 1 , τ 2 ∈ T s.t.w admits an infinite reduction w.r.t.→ shift(R) .We prepend and append symbols to w constructing a string w ′ = uwv of type K → T as follows: The string u is the empty string if τ 2 = T and otherwise for any τ 2 ∈ {K, AB, M, C} there is a sequence of type τ 2 → T , which is used for u: The string v is the empty string if τ 1 = K and otherwise for any τ 1 ∈ {AB, M, C, T } there is a sequence of type K → τ 1 , which is used for v: Clearly, the infinite reduction for w can be used to construct an infinite reduction for uwv.
By checking all possible cases, the following lemma can be verified: A is defined according to the cases of Lemma 3.26 as follows: Lemma 3.28.Let u be a well-typed string of type Proof.We go through the cases of Lemma 3.26 and inspect all applicable rewrite rules: Proof.Suppose that u : K → T admits an infinite → shift(R) -reduction.Applying Lemma 3.28 shows that it is possible to construct an infinite reduction of •→ * R -steps starting with [u].Since applications of rule (shiftH) are translated into •→ R steps, it remains to show that the given infinite reduction of u has infinitely many applications of rule (shiftH).Therefore we show that the rewrite system consisting of all rules of shift(R) except for rule (shiftH) is terminating.Let us denote this system by shift \{(shiftH)} (R), i.
Theorem 3.30.The transformation shift is sound and complete.Theorem 3.32.The transformation shift rel is sound and complete for relative termination.
Proof.Let Σ A be an alphabet, S ⊆ R be SRSs over Σ A , and shift rel (S, R) = (S ′ , R ′ ).For proving soundness of shift rel , assume that S is not cycle terminating relative to R. Using the same arguments as in Proposition 3.21 there exists an infinite reduction such that w i ( <len(R) .→ R ) * .<len(S) v i → S w i+1 for i = 1, 2, . ... By Lemma 3.24 we have for all i = 1, 2, . ..: For proving completeness, we assume that S ′ is not string terminating relative to R ′ .We use typed string rewriting and apply Theorem 3.3 and Lemma 3.25.Thus there exists a typed string w 0 : K → T s.t. for all i = 0, 1, 2, . . . the reduction sequence w i+1 exists.Typing of w i , Lemma 3.26, and applicability of → S ′ show that w i and w ′ i must be of the forms ] which shows that S is not cycle terminating relative to R.

3.4.
The Transformation rotate.We first present the idea of the transformation rotate.The transformation is closely related to the definition of •→: The idea is to first rotate the string and then to apply a prefix rewrite step (i.e. both steps can be expressed by the relation ∼ .֒→ R ).The transformation rotate simulates the cycle rewrite step, by first rotating the string (using ∼) until abc becomes a prefix, and then applies a prefix rewrite step.I.e., we have bcdda ∼ .֒→ R bbbbdd, since bcdda ∼ abcdd ֒→ R bbbbdd.It would be possible to use shifts to perform the rotation, i.e. bcdda * .֒→ R bbbbdd, since bcdda cddab ddabc dabcd abcdd ֒→ R bbbbdd.However, our transformation rotate will implement ∼ by moving symbols from right to left.
The following lemma obviously holds: Lemma 3.34.Let R be an SRS over an alphabet Σ and u, v and thus v 0 admits an infinite reduction of the required form.
For an SRS R, the SRS rotate(R) will encode the relation ∼ .֒→ R where extra symbols are used to separate the steps, and copies of the alphabet underlying R are used to ensure completeness of the transformations.We first introduce the transformation rotate(R) and then explain the ideas of the transformation in detail.
Again for the rest of the section, we fix an SRS R over alphabet Σ A = {a 1 , . . ., a n }, write Σ B , Σ C , Σ D , Σ E for fresh copies of the alphabet Σ A , and use w Y to switch between the alphabets (see Section 3.3).E, W, R, G, O, C, L, S, F, f}  (where B, E, W, R, G, O, C, L, S, F, and f

Definition 3.36 (The transformation rotate). Let R be an SRS over alphabet Σ A . The SRS rotate(R) over the alphabet Σ
for all e ∈ Σ E (rotM) We describe the intended use of the rewrite rules, where we ignore the copies of the alphabet in our explanations.The goal is that for any string w ∈ Σ * A , the string BwE is rewritten to BuE, where w ∼ .֒→ R u.The prefix rewrite step is performed by the last rule (rotO).All other rules perform the rotation ∼ s.t.BwE is rewritten into WvE where w ∼ v.This is done by moving a suffix of the string in front of the string.The first rewrite rule (rotA) covers the case that w is empty.Otherwise, if w = a 1 . . .a n , then first choose a position to cut the string into w 1 w 2 (the goal is then to form the string w 2 w 1 ).The symbol G is used for the non-deterministic selection of the position.Rule (rotB) starts the rotate phase and the guessing, rule (rotC) shifts the G-marker and rule (rotD) stops the guessing.Rule (rotE) covers the case that w 2 = ε and no rotation will be performed.After stopping the guessing, every symbol of w 2 is moved in front of w 1 , resulting in w 2 w 1 .A typical situation is a k+1 . . .a m a 1 . . .a k a m+1 . . .a n and now the symbol a m+1 must be moved in between a m and a 1 .To keep track of the position of a 1 , the symbol C (inserted in front of a 1 ) marks the original beginning, and to keep track of the position of a k , the symbol S (inserted after a k ) marks this position.The symbol L guards the movement of a m+1 (by rule (rotF)).When arriving at the right place (rule (rotG)), the symbol R is used to walk along the string (rule (rotH)) to find the next symbol which has to be moved (rule (rotI)).If all symbols are moved, rule (rotJ) is applied to start the clean-up phase.There the symbols F and f are used to remove the markers and to replace the copied symbols of the alphabet with the original ones (rules (rotK) -(rotN)).
In the following, we denote with rot(Σ A ) the string rewrite system consisting of the rules (rotA) -(rotN) from Definition 3.36 (excluding the rule (rotO)).
Example 3.37.For the system R = {aaa → ababa} and Σ A = {a, b}, the transformed string rewrite system is rotate(R) = rot(Σ A ) ∪ {Waaa → Bababa}.The cycle rewrite step [abbaa] •→ R 1 [abababb] is simulated in the system rotate(R) by rewriting BabbaaE into BabababbE as follows: . .a n for some n ≥ 1 and v = a k . . .a n a 1 . . .a k−1 then there are two cases: If k = 1 (i.e.u = v) then the following rewrite sequence for BuE exists: then the following rewrite sequence for BuE exists:  ).If w is not of type K → T , then we can prepend and append symbols to w constructing a string uwv of type K → T , since for any type τ ∈ {A, B, C, D, E, K, T } there are the following sequences of type τ → T where τ = T (used for u) and of type K → τ where τ = K (used for v), where c ∈ Σ C : Clearly, the infinite reduction for w can be used to construct an infinite reduction for uwv.
Typing of all strings, Lemma 3.43 and the definition of the rules (rotO) imply that the steps Since this holds for all i = 1, 2, . .., and since Φ R (v j ) is a singleton for all v j , we can construct the infinite sequence u We show soundness and completeness: Theorem 3.48.The transformation rotate rel is sound and complete for relative termination.
Proof.Let S ⊆ R and rotate rel (S, R) = (S ′ , R ′ ).Soundness of the transformation rotate implies (see proof of Theorem 3.46) that Since rotate(S) ⊆ R ′ , this also shows: For proving soundness of rotate rel , let us assume that S is not cycle terminating relative to R.
Then there exists an infinite derivation [ . .and thus S ′ is not string terminating relative to R ′ .
For proving completeness of rotate rel , we again use the types introduced in Section 3.4.1.Let us assume that S ′ is not string terminating relative to R ′ .By Theorem 3.3 and Lemma 3.40 there exists a well-typed string w 0 : K → T s.t. for all i = 0, 1, 2 . . . the derivation w i → S ′ .→ * R ′ w i+1 exists.Each such derivation can be written as where m i ≥ 0. Starting with w 0,0,i and appending the sequence w m i ,1,i → * rot(Σ A ) w 0,0,i+1 this can be formulated as follows: There exists a derivation w 0,0,i → rotO(S) w 0,1,i w 0,0,i+1 for all i = 0, 1, . . .where m i ≥ 0. Typing of the strings and the cases in Lemma 3.41 show that Φ R (w k,l,i ) is a singleton {u k,l,i } for all i and k = 0, . . ., m i , l = 0, 1. Due to applicability of rule (rotO), we also have u 0,0,i → S u 0,1,i and u k,0,i → R u k,1,i for k = 1, . . ., m i .Lemma 3.43 implies that u k,0,i ∼ u k−1,1,i for k = 1, . . ., m i + 1.Thus, we have ]. Since this holds for all i = 0, 1, . .., we have shown that S is not cycle terminating relative to R.

Trace Decreasing Matrix Interpretations
In this section we present a variant of matrix interpretations suitable for proving cycle termination.The basics of matrix interpretations for string and term rewriting were presented in [14,15,7,16].The special case of tropical and arctic matrix interpretations for cycle rewriting was presented in [28], in the setting of type graphs.Natural matrix interpretations for cycle rewriting were presented in [18], inspired by an approach proposed by Johannes Waldmann.Here we present a self-contained uniform framework covering all these cases as we show by subsequently instantiating the framework for three semi-rings.At the end of the section we discuss and illustrate the approach by examples and also discuss some limitations.

4.1.
A Uniform Framework for Matrix Interpretations.Fix a commutative semiring, that is, a set X, a zero element 0 ∈ X, a unit element 1 ∈ X, and two operations +, × that are commutative and associative, and satisfying for all x, y, z ∈ X.Further we assume a well-founded order > on X.
Next we fix a dimension d > 0 and choose M to be a set of d × d matrices over X. Multiplication of matrices is defined as usual, now using + and × from the semi-ring as basic operations on elements: for all i, j = 1, . . ., d, where extends the operation +.Note that in the following we only require matrix multiplication and no addition.Thus we assume that M is closed under multiplication and contains the identity matrix.
For a d × d matrix A over X, its trace tr(A) is defined to be d i=1 A ii : the sum of its diagonal.
On M we assume relations >, ≥ satisfying for all A, B, C ∈ M .Note the overloading of > and ≥: when applied on matrices it refers to the relations >, ≥ we assume on M , when applied to elements of X it refers to the well-founded order on X, where x ≥ y ⇐⇒ x > y ∨ x = y.
• •→ S ′ is terminating relative to •→ R ′ , and we have to prove that it contains finitely many •→ S -steps.As in the proof of Theorem 4.1 we have tr( u i ) > tr( u i+1 ) for applications of rules (ℓ → r) ∈ (R \ ((R ′ \ S) ∪ S ′ )) and tr( u i ) ≥ tr( u i+1 ) for applications of remaining rules.Since > is well-founded on X, there are only finitely many steps of the former type, so after a finite initial part the infinite reduction only consists of ((R ′ \S)∪S ′ )-steps.But then applying that •→ S ′ is terminating relative to •→ R ′ , these remaining ((R ′ \ S) ∪ S ′ )steps only contain finitely many S ′ -steps.All other steps are (R ′ \ S)-steps and thus do not contain S-steps.Hence in total there are only finitely many •→ S -steps.Indeed Theorem 4.1 is an instance of Theorem 4.2 if S ′ = ∅ and R ′ = R \ S. A typical way to apply Theorem 4.2 to prove cycle termination of any SRS S relative to R is very similar to the typical way to apply Theorem 4.1: remove the rules for which '>' is obtained, both from S and R.
In order to apply Theorem 4.1 or Theorem 4.2 we need an instance of a semi-ring X, a set M of matrices over X and relations >, ≥ on M such that all assumed properties holds.We give three such instances: the tropical, arctic and natural matrix interpretations, all depending on dimension d.For all these three instances the search for applying Theorem 4.1 has been implemented in our tool torpacyc by transforming the requirements to SMT format and calling the external SMT solver Yices [5,25].The same has been done in our tool tdmi, also covering Theorem 4.2.
A nice point is that we do not need to try separately for which rules we require ℓ ≥ r and for which rules ℓ > r , but we just specify in the SMT formula that the latter occurs at least once and the former for all other rules.4.2.Natural Matrix Interpretations.In natural matrix interpretations we have X = IN, and 0, 1, +, ×, > have their usual meaning.We define M to consist of all d × d matrices A satisfying A 11 > 0. On M we define the relations > and ≥ by For M with these relations the required properties (4.1), (4.2), (4.3), and (4.4) are all easily checked.Hence this yields a way to prove (relative) cycle termination by Theorem 4.1.As an example we consider the single rule aa → aba and choose proving cycle termination by Theorem 4.1.
The original versions of matrix interpretations in [14,7] are not suitable for proving cycle termination since they succeed in proving termination of ab → ba for which cycle termination does not hold.Even more, the same holds for the original killer example for the method of matrix interpretations was aa → bc, bb → ac, cc → ab, for which cycle termination does not hold due to Main differences are our conditions (4.3) and (4.4) on the trace of the matrices and that in our setting the interpretation of symbols is multiplication by a matrix, while in [14,7] it combines such a matrix multiplication by adding a vector.4.3.Tropical Matrix Interpretations.In tropical matrix interpretations we choose the semi-ring X = IN ∪ {∞}, with min being the semi-ring addition and the normal addition being the semi-ring multiplication, both extended to X by defining min(∞, x) = min(x, ∞) = x and ∞ + x = x + ∞ = ∞ for all x ∈ IN ∪ {∞}.Now ∞ acts as the semi-ring zero and 0 acts as the semi-ring unit; it is easily checked that all semi-ring requirements hold.This semi-ring is called the tropical semi-ring after its study by the Brazilian mathematician Imre Simon [19].Over this semiring multiplication of matrices becomes (AB) i,j = min({A i,k + B k,j | k = 1, . . ., d}), so being quite different from the usual matrix operations.On this semi-ring we define the well-founded order > to be the extension on > on IN defined by So in this semi-ring the zero element is not the smallest but the largest element.
We define M to consist of all d × d matrices A satisfying A 11 = ∞.On M we define the relation > by and the relation ≥ by For M with these relations the required properties (4.1), (4.2), (4.3), and (4.4) are all easily checked; note that for every A ∈ M we have tr(A) = min i A ii = ∞ since A 11 = ∞.For these requirements it is essential that we defined A > B by A ij > B ij on all positions and not only at 1,1, since from a > b we cannot conclude min(a, c) > min(b, c), but from a > b ∧ c > d we can conclude min(a, c) > min(b, d).
As an example we again consider the single rule aa → aba and choose by using the tropical matrix multiplication yielding On this semi-ring we define the well-founded order > to be the extension on > on IN: So in this semi-ring the zero element is the smallest element, just like in the natural semiring.
We define M to consist of all d × d matrices A satisfying A 11 = −∞.On M we define the relation > by and the relation ≥ by For M with these relations all required properties hold, again providing a method for proving (relative) cycle termination by Theorem 4.1.Cycle termination of our example aa → aba can also be proved by arctic matrix interpretation, now by choosing

4.5.
Examples and Bounds on Reduction Lengths.As an example of combining various versions of matrix interpretations we consider the system from the introduction: 0P → 1P, 1P → cP, 0c → 10, 1c → c0, P 0 → P 100 for which the following proof is found fully automatically by torpacyc.
First the following tropical matrix interpretation is found: In this interpretation for the first four rules we have ℓ ≥ r and for the last rule we have ℓ > r .So by Theorem 4.1 the last rule may be removed, and torpacyc continues with the remaining four rules.
Next the following natural matrix interpretation is found: For these interpretations we obtain 0P > 1P , 1P > cP , 0c ≥ 10 and 1c ≥ c0 , hence by Theorem 4.1 it suffices to prove cycle termination of 0c → 10, 1c → c0, for which torpacyc finds a simple counting argument.These simple counting arguments can be seen as the instance of tropical matrix interpretations of dimension d = 1, not using ∞: Also the transformational approach successfully proves cycle termination of φ(R 2 ): T T T 2 proves string termination of split(φ(R 2 )).Interestingly, we did not find a termination proof of split(φ(R 2 )) using AProVE.

Tools and Experimental Results
In this section we first explain which tools and which benchmark sets were used to evaluate the techniques presented in this paper.Thereafter we summarize and analyze the obtained results.
5.1.Tools for Proving Cycle Termination.We implemented several tools for proving cycle termination and cycle non-termination, which will be explained in this section.
The command line tool cycsrs is mainly a wrapper which allows to call different other tools and termination provers.It also allows to call the different tools in succession on a given termination problem and to distribute the time limit among the tools.The tool participated in the category on cycle rewriting in the Termination Competition 2015 [21] and in the Termination and Complexity Competition 2016 [22].
For the transformational approaches, cycsrs is able to perform the transformations split, rotate, or shift for a given input problem and then it calls the termination provers AProVE or T T T 2 to prove string termination of the transformed problem.Analogously, cycsrs can apply transformations split rel , rotate rel , and shift rel , to enable the proof of relative cycle termination by showing relative string termination.
For the search for matrix interpretations described in Section 4, we implemented two tools: The prover torpacyc searches for matrix interpretations by using the SMT-solver yices targeting the logic of unquantified linear integer arithmetic with uninterpreted sort and function symbols.
The tool tdmi uses a similar approach, applying yices to find matrix interpretations, but targets the logic of quantifier-free formulas over the theory of fixed-size bit vectors (similarly as proposed in [4]).Moreover, tdmi is able to prove relative termination.Another difference is that torpacyc checks for match bound proofs, see [28].Match bound proofs can be seen as proofs by tropical matrix interpretation, but with dimensions of often more than 100, being far beyond the dimension that is feasible for direct search for tropical matrix interpretations, typically being 3.
For proving non-termination, one technique is to prove string non-termination of the cycle rewrite problem by using a termination prover like AProVE or T T T 2 (which is correct due to Proposition 2.1).Another technique is to apply one of the transformations and then proving string non-termination of the transformed problem (which is correct since the transformations are complete).Additionally, we implemented a tool cycnt which performs a brute-force search for cycle non-termination.
The automatic transformation and the prover can also be used online via a web interface available via http://www.ki.informatik.uni-frankfurt.de/research/cycsrs/where also the tools and experimental data can be found.

Benchmark Sets and Test Environment.
A problem for doing experiments is that no real appropriate test set for cycle rewriting is available.We played around with several examples like the ones in this paper, but we also wanted to test larger scale experiments.For proving cycle termination, we use the SRS Standard-branch of the Termination Problem Data Base [23] (TPDB), which is a benchmark set for proving termination of string rewrite systems, but it was also used as problem set in the cycle rewriting category of the Termination Competition 2015 and slightly extended by some new problems in 2016.This set contains 1315 termination problems.
For relative cycle termination, we use the SRS Relative-branch of the Termination Problem Data Base, which is a benchmark set containing 205 relative string termination problems.
In [18] we also tested some of the techniques on 50000 randomly generated string rewrite systems.We excluded them in the new tests, since most of the problems where either trivially cycle terminating or could easily be proved to be cycle non-terminating.A further difference to the benchmarks presented in [18] is the test environment: the current benchmarks where all performed on StarExec [20] -a cross community logic solving servicewhich made it possible to rapidly run the tests and thus also to perform tests with higher time-outs.1 summarizes the obtained results for running several techniques to prove cycle termination on the SRS Standardbranch of the TPDB.The first column lists the different techniques, thereafter there are two main columns: the first one lists the results where a time limit of 60 secs.was used, and the second main column lists the result for a time limit of 300 secs.There are three kinds of results: YES means that cycle termination has been proved, NO means that cycle non-termination has been proved (and thus cycle termination was disproved), and MAYBE means that no result was obtained.

Experimental Results on Cycle Termination. Table
The rows of Table 1 consist of five main parts.
• The first part consists of the results for the transformational approach, where each of the three transformations split, rotate, and shift was applied to the input problem and thereafter either AProVE or T T T 2 was applied to the transformed system.We also list the numbers for combining the results of the two solvers (in the rows named "any"), which sometimes shows that the termination techniques perform differently on the same problems.• The second part contains the summarized results of applying the two tools torpacyc and tdmi to the problems.Both tools try to prove cycle termination by searching for matrix interpretations.Note that both tools are unable to show cycle nontermination.Again the row named with "any" combines the results of both techniques.• The third part shows the result of applying the brute-force search for cycle nontermination, using our tool cycnt, and the results of applying AProVE and T T T 2 to prove string non-termination of the input problem (which implies cycle termination).We also list the numbers for combining the three techniques to prove cycle nontermination (listed in the row named "any").to first run torpacyc (with 25% of the time limit), then tdmi (14 %), then the back-end prover (9 %) and cycnt (10 %) to prove cycle non-termination, and finally to apply the transformation split together with a subsequent call of the back-end prover to show (non-)termination of the transformed system (42 %).• The last row of the table combines all results of the previous rows (where the YESand NO-results are summed up per problem).An overall observation is that our techniques were able to obtain a result for about the half of the problems, while the other half of the problems seem to be too hard to be proved by the techniques.This is not really surprising since the test set contains already 'hard' instances for proving string termination: In the Termination Competition 2015 the winning prover AProVE solved 832 out of the 1325 string termination problems (with a time limit of 300 secs.).
Considering cycle termination, we were now able to solve 643 problems with a time limit of 60 secs.(by combining all of our techniques), while in [18] only 399 problems were solved in the same time limit and on the same problem set (but on a different environment, not on

SRS Relative
Time limit 60 secs.StarExec).This increase in the number of solved problems mainly comes from adding the tool cycnt to search for cycle non-termination.The results for checking non-termination also show that in the benchmark set many problems seem to cycle non-terminating, while they are string terminating.We expected this, since a substantial part of the problems may contain a renaming of the rule ab → ba.
A further observation is that increasing the time limit allows to solve more problems, where the increase on proving cycle non-termination is rather small, while for cycle termination the increase is noticeable.
Comparing the three transformations, the transformation split leads to much better results than the other two transformations, which holds for termination and for non-termination proofs.
For proving cycle termination, problem specific methods (i.e.torpacyc and tdmi) seem to perform a little bit better than the transformational method using split.
Comparing the back-end prover, there is surprisingly no clear winner: AProVE seems to perform better for short time limits and for proving non-termination, while T T T 2 seems to perform better for longer time limits.5.4.Relative Cycle Termination.Table 2 summarizes the results on applying different techniques to the 205 problems in the SRS Relative-branch of the TPDB.Again, the tests were run with a time limit of 60 secs.and with a time limit of 300 secs.Since torpacyc is not able to prove relative termination, there are no tests using torpacyc.
One observation of the results is that again the transformation split rel leads to better results than the other transformations.A further observation is that the problem specific methods (the matrix interpretations to prove relative cycle termination and cycnt to disprove cycle termination) perform slightly better than the transformational approach.
Finally, the number of solved problems is quite small compared to the number of problems.One reason may be that the benchmark set contains only few small rewrite systems, and many large problems.Large problems are disadvantageous for the transformational approach, since the transformations (especially the transformation split) increases the size of the problem.

Proving Cycle Termination by Relative String Termination.
To prove cycle termination of a string rewrite system S, we can use all the techniques for proving relative cycle termination by using all rules of S as strict rules (and thus there are no weak rules).This usually does not lead to an improvement by applying automated termination tools, since the problem of showing S being terminating relative to S is equal to showing that S is terminating.However, for the transformational approaches the setting is different.Let ψ be one of the sound and complete transformations and ψ rel its variant for relative cycle termination.Since for an SRS S, the transformation ψ rel (S, S) results in (S ′ , R ′ ) where this inclusion is strict, i.e. S ′ ⊂ R ′ , it makes sense to analyse whether transforming S into (S ′ , R ′ ) and subsequently proving that S ′ is string terminating relative to R ′ enables further (non-)termination proofs compared to trying to prove string termination of ψ(S).
For each problem in SRS Standard-branch of the TPDB we applied each combination of a transformation and the two termination provers AProVE and T T T 2 .Table 3 summarizes the results of this analysis, where we used a time limit of 300 secs.The numbers of proved, disproved, and open problems are listed: first for the usual approach to prove string termination of ψ(S), secondly for proving relative string termination of ψ rel (S, S), and as a third row the combined results are shown (in the rows labeled with "any").
The results show that indeed also the technique using relative string termination as target of the transformation works for several problems.However, they lead to new cycle (non-)termination proofs in very rare cases.

Conclusions
We presented techniques to prove termination and relative termination for cycle rewriting.The main approach is to apply a sound and complete transformation from cycle into string rewriting.We presented and analyzed three such transformations, both for termination and relative termination.Apart from that we provided a framework covering several variants of matrix interpretations serving for proving (relative) cycle termination.Our implementations and the corresponding experimental results show that both techniques are useful in the sense that they apply for several examples for which the earlier techniques failed.
Together with the sound and complete transformation φ in the reverse direction from [28], the existence of a sound and complete transformation like split implies that the problems of cycle termination and string termination of SRSs are equivalent in a strong sense.

SRS Standard
AProVE T T T 2 For instance, it implies that they are in the same level of the arithmetic hierarchy, which is Π 0 2 -complete along the lines of [6].Alternatively, Π 0 2 -completeness of cycle termination can be concluded from the sound and complete transformation φ combined with the observation that cycle termination is in Π 0 2 .For future research, there is a need for more sophisticated techniques to prove cycle non-termination, since we conjecture that e.g.several open problems in the benchmark sets are cycle non-terminating, but our tools are not able to find a corresponding proof.A promising non-termination technique may follow the ideas of [8], some first steps in this direction have been worked out in [27].
For a fair comparison of tools for (non-)termination of cycle rewriting, a set of benchmarks is needed with more focus on cycle rewriting, rather than the current set in which nearly all systems are copied from benchmarks for string rewriting.

Figure 1 :
Figure 1: Illustration of Cycles and Cycle Rewriting we have baabab → R baaab for R = {b → ε}, while Dec(baabab) = [b, aa, b, a, b] has length 5 and Dec(baaab) = [b, aaa, b] has length 3.In all other cases the rewriting of u takes place in one of the elements of Dec(u), while all other elements remain unchanged.These observations are summarized in the following lemma.Lemma 3.2.Let R be a well-typed SRS with non-empty left hand sides and u → R v. Then • |Dec(u)| ≥ |Dec(v)|, and • if |Dec(u)| = |Dec(v)|, then there exists i ∈ {1, . . ., n} such that u i → R v i , and u j = v j for j = i, where Dec(u) = [u 1 , . . ., u n ] and Dec(v) = [v 1 , . . ., v n ].

a n a 1 . . .a k− 1 E 3 . 4 . 1 .
Theorem 3.39.The transformation rotate is sound.Proof.Proposition 3.38 and the construction of rotate(R) show that whenever u ∼ v ֒→ R w then also BuE → * rotate(R) BwE.Now Proposition 3.35 implies soundness.Completeness of Rotate.We write Σ A for the extension of alphabet Σ A by the fresh symbols B,E,W,R,G,O,C,L,S,F,f, and by four copiesΣ B , Σ C , Σ D , Σ E of the alphabet Σ A .For proving completeness of the transformation rotate, we use type introduction.Let T := {K, A, B, C, D, E, T } and let the symbols in Σ A be typed as follows:a : A → A for all a ∈ Σ A b : B → B for all b ∈ Σ B c : B → C for all c ∈ Σ C d : D → D for all d ∈ Σ D e : E → E for all e ∈ Σ E E : K → A S : A → B L : C → D R : B → D C : D → E G, F : A → D B, W : A → T O : E → T f : A → EOne can verify that with definition R is indeed a typed SRS: rule (rotA) rewrites strings of type K → T , rules (rotB), (rotN), and (rotO) rewrite strings of type A → T , rules (rotC), (rotD), (rotI), and (rotK) rewrite strings of type A → D, rules (rotE) and (rotJ) rewrite strings of type K → D, rules (rotF) and (rotH) rewrite strings of type B → D, rule (rotG) rewrites strings of type B → E, and rules (rotL) and (rotM) rewrite strings of type A → E.
then rules (rotH), (rotI), and (rotJ) may be applied.If rule (rotH) is applied then with w B = bw ′ B we have w ′ = Ow E Cw D b D Rw ′ B Sw A E, and since Φ(w) = Φ(w ′ ), the claim holds.If rule (rotI) is applied, then w B = ε and with w A = aw ′ A we have w ′ = Ow E Cw D L a C Sw ′ A E, and since Φ(w) = Φ(w ′ ), the claim holds.If rule (rotJ) is applied, then w A = w B = ε and w ′ = Ow E Cw D FE and since Φ(w) = Φ(w ′ ), the claim holds.(3) If w = Ow E Cw D Fw A E, then rules (rotK) and (rotL) may be applied.If rule (rotK) is applied, then with w D = w ′ D d we have w′ = Ow E Cw ′ D F d A w A E, and since Φ(w) = Φ(w ′ ), the claim holds.If rule (rotL) is applied, then w D = ε, w ′ = Ow E f w A E, and since Φ(w) = {w A w E A }, Φ(w ′ ) = { w E A w A }, and w A w E A ∼ w E A w A ,the claim holds.(4) If w = Ow E Cw D Gw A E, then rules (rotC), (rotD), and (rotE) may be applied.If rule (rotC) is applied, then with w A = av A we have w ′ = Ow E Cw D a D Gv A E, and since Φ(w) ⊇ Φ(w ′ ) = ∅, the claim holds.If rule (rotD) is applied, then with w A = av A we have w ′ = Ow E Cw D L a C Sv A E, and since Φ(w) ⊇ Φ(w ′ ) = ∅, the claim holds.If rule (rotE) is applied, then w A = ε and w ′ = Ow E Cw D FE, and since Φ(w) = Φ(w ′ ), the claim holds.(5) If w = Ow E f w A E, then rules (rotM) and (rotN) may be applied: If rule (rotM) is applied, then with w E = w ′ E e we have w ′ = Ow ′ E f e A w A E, and since Φ(w) = Φ(w ′ ), the claim holds.If rule (rotN) is applied then w E = ε, w ′ = Ww A E, and since Φ(w) = Φ(w ′ ), the claim holds.(6) If w = Bw A E, then rules (rotA) or (rotB) may be applied: If rule (rotA) is applied then Φ(w) = {ε} = Φ(w ′ ) and thus the claim holds.If rule (rotB) is applied, then with w A = aw ′ A we have w ′ = OC a D Gw ′ A , and since Φ(w) = Φ(w ′ ) the claim holds.(7) If w = Ww A E. then no rule is applicable.Lemma 3.44.The SRS rot(Σ A ) is terminating.

Theorem 3 .
46.The transformation rotate is sound and complete.Proof.Soundness is shown in Theorem 3.39, completeness follows by type introduction (Corollary 3.4), Lemma 3.40, and Proposition 3.45.3.4.2.Relative Termination.We provide a variant of the transformation rotate for relative termination: Definition 3.47.Let S ⊆ R be SRSs over an alphabet Σ A .The transformation rotate rel is defined as:

proving cycle termination by Theorem 4. 1 . 4 . 4 .
Arctic Matrix Interpretations.In arctic matrix interpretations we choose the semiring X = IN ∪ {−∞}, with max being the semi-ring addition and the normal addition being the semi-ring multiplication, both extended to X by definingmax(−∞, x) = max(x, −∞) = x and − ∞ + x = x + −∞ = −∞ for all x ∈ IN ∪ {−∞}.Now −∞acts as the semi-ring zero and 0 acts as the semi-ring unit; it is easily checked that all semi-ring requirements hold.This semi-ring is called the arctic semi-ring as it is a kind of opposite to the tropical semi-ring.Over this semi-ring multiplication of matrices becomes (AB) i,j = max({A i,k + B k,j | k = 1, . . ., d}), Theorem 3.13 (Soundness and completeness of split).The transformation split is sound and complete, i.e. → split(R) is terminating if, and only if •→ R is terminating.Proof.Soundness is proved in Proposition 3.8.It remains to show completeness.W.l.o.g.we assume that → R is terminating, since otherwise •→ R is obviously non-terminating.Type introduction (Corollary 3.4) and Lemma 3.9 show that it is sufficient to construct a nonterminating cycle rewrite sequence for any well-typed string w of type K → T where w has an infinite → split(R) -reduction.Let w be a well-typed string of type K → T s.t.w admits an infinite reduction w 2x + 1 > λx.x, for rule (shiftC), we have λx.8x+ 9 > λx.8x + 1, for rule (shiftD), we have λx.32x+ 33 > λx.32x + 8, for rule (shiftE), we have λx.56x+ 9 > λx.28x + 8, for rule (shiftF), we have λx.2x+ 2 > λx.2x + 1, for rule (shiftG), we have λx.4x+ 4 > λx.4x, for rule (shiftI), we have λx.2 Thus, by Corollary 3.4 type introduction can be used, i.e. rotate(R) is terminating if, and only if the typed system terminates (and analogously for relative termination, see Theorem 3.3).

•
The fourth part consists of the results for a combination of the termination techniques.Here we use AProVE or T T T 2 , respectively, as back-end prover to show string termination and non-termination.In detail, the command line tool cycsrs is used

Table 1 :
Experimental results for proving cycle (non)-termination on the 1315 problems of the SRS Standard branch of the TPDB

Table 2 :
Time limit 300 secs.YES NO MAYBE YES NO MAYBE Experimental results for proving relative cycle (non)-termination on the 205 problems of the SRS Relative branch of the TPDB

Table 3 :
Time limit 300 secs.YES NO MAYBE YES NO MAYBE Results for proving cycle termination of the 1315 problems in the SRS Standard branch of the TPDB by transformation into string termination problems and relative string termination problems