Proving Looping and Non-Looping Non-Termination by Finite Automata
PProving Looping and Non-LoopingNon-Termination by Finite Automata ∗ Jörg Endrullis and Hans Zantema [email protected] [email protected]
Abstract
A new technique is presented to prove non-termination of term rewriting. The basic idea is tofind a non-empty regular language of terms that is closed under rewriting and does not containnormal forms. It is automated by representing the language by a tree automaton with a fixednumber of states, and expressing the mentioned requirements in a SAT formula. Satisfiability of this formula implies non-termination. Our approach succeeds for many examples where all earlier techniques fail, for instance for the S -rule from combinatory logic. D.1.1, D.3.1, F.4.1, F.4.2, I.1.1, I.1.3
Keywords and phrases non-termination, finite automata, regular languages
A basic approach for proving that a term rewriting system (TRS) is non-terminating is toprove that it admits a loop , that is, a reduction of the shape t → + C [ tσ ], see [27]. Indeed,such a loop gives rise to an infinite reduction t → + C [ tσ ] → + C [( C [ tσ ]) σ ] → · · · in which inevery step t is replaced by C [ tσ ]. In trying to prove non-termination, several tools ([1, 2])search for a loop. An extension from [7], implemented in [1] goes a step further: it searches forreductions of the shape tσ n µ → + C [ tσ f ( n ) µτ ] for every n for a linear increasing function f ,and some extensions. All of these patterns are chosen to be extended to an infinite reductionin an obvious way, hence proving non-termination. However, many non-terminating TRSsexist not admitting an infinite reduction of this regular shape, or the technique from [7] failsto find it.A crucial example is the S -rule a ( a ( a ( S, x ) , y ) , z ) → a ( a ( x, z ) , a ( y, z )), one of the buildingblocks of Combinatory Logic. Although being only one single rule, and having nice propertieslike orthogonality, non-termination of this system is a hard issue. Infinite reductions areknown, but are of a complicated shape, see [32]. So developing a general technique that canprove non-termination of the S -rule automatically is a great challenge. In this paper wesucceed in presenting such a technique, and we describe a SAT-based approach by whichnon-termination of many TRSs, including the S -rule, is proved fully automatically. ∗ This is an extended version of the paper [23] published at RTA 2015. This extension includes trans-formation for strengthening the presented non-termination techniques (see Remarks 8 and 9), a detaileddescription of the SAT encoding of the improved technique in Section 5 (see Remark 39) and a remarkon the completeness of the method with respect to loops (see Remark 40). a r X i v : . [ c s . L O ] M a y Proving Looping and Non-Looping Non-Termination by Finite Automata
The underlying idea is quite simple: non-termination immediately follows from theexistence of a non-empty set of terms that is closed under rewriting and does not containnormal forms. Our approach is to find such a set being the language accepted by a finite treeautomaton, and find this tree automaton from the satisfying assignment of a SAT formuladescribing the above requirements. Hence the goal is to describe the requirements, namelynon-emptiness, closed under rewriting, and not containing normal forms, in a SAT formula.We want to stress that having quick methods for proving non-termination of term rewritingalso may be fruitful for proving termination. In a typical search for a termination proof, likeusing the dependency pair framework, the original problem is transformed in several waysto other termination problems that not all need to be terminating. Being able to quicklyrecognize non-termination of some of them makes a further search for termination proofsredundant, which may speed up the overall search for a termination proof.We note that, like termination, non-termination is an undecidable property. However,while termination is Π -complete, non-termination is Σ -complete [11, 10].The paper is organized as follows. In Section 2 we present our basic approach in thesetting of abstract reduction systems on a set T , in which the language is just a subset of T .Surprisingly, being not weakly normalizing corresponds to (strongly) closed under rewriting,and being not strongly normalizing corresponds to weakly closed under rewriting. In Section3 we give preliminaries on tree automata and show how string automata can be seen as aninstance of tree automata. In Section 4 we present our basic methods, starting by how therequirements are expressed in SAT, and next how this is used to disprove weak normalizationand strong normalization. In Section 5 we strengthen our approach by labeling the states ofthe tree automata by sets of rewrite rules and exploiting this in the method. In Section 6 wepresent experimental results of our implementation. We conclude in Section 7. Related Work
The paper [27] introduces the notion of loops and investigates necessary conditions for theexistence of them. The work [35] employs SAT solvers to find loops, [36] uses forward closuresto find loops efficiently, and [34] introduces ‘compressed loops’ to find certain forms of verylong loops. Non-termination beyond loops has been investigated in [30] and [7]. There thebasic idea is the search for a particular generalization of loops, like a term t and substitutions σ, τ such that for every n there exist C, µ such that tσ n τ rewrites to C [ tσ f ( n ) τ µ ], for someascending linear function f . Although the S -rule admits such reductions, these techniquesfail to find them. For other examples for which not even reductions exist of the shape studiedin [30] and [7], we will be able to prove non-termination fully automatically.Our approach can be summarized as searching for non-termination proofs based onregular (tree) automata. Regular (tree) automata have been fruitfully applied to a widerage of properties of term rewriting systems: for proving termination [26, 21, 28], infinitarynormalization [12], liveness [29], and for analyzing reachability and deciding the existenceof common reducts [24, 13]. Local termination on regular languages, has been investigatedin [9]. An abstract reduction system (ARS) is a binary relation → on a set T . We write → + for thetransitive closure, and → ∗ for the reflexive, transitive closure of → .Let → be an ARS on T . The ARS → is called terminating or strongly normalizing ( SN )if no infinite sequence t , t , t , . . . ∈ T exists such that t i → t i +1 for all i ≥
0. A normal . Endrullis and H. Zantema 3 form with respect to → is an element t ∈ T such that no u ∈ T exists satisfying t → u . Theset of all normal forms with respect to → is denoted by NF ( → ). The ARS → is called weaklynormalizing ( WN ) if for every t ∈ T a normal form u ∈ T exists such that t → ∗ u . (cid:73) Definition 1.
A set L ⊆ T is called closed under → if for all t ∈ L and all u ∈ T satisfying t → u it holds u ∈ L , and weakly closed under → if for all t ∈ L \ NF ( → ) there exists u ∈ L such that t → u .It is straightforward from these definitions that if L is closed under → , then L is weaklyclosed under → as well. The following theorems relate these notions to SN and WN . (cid:73) Theorem 2.
An ARS → on T is not SN if and only if a non-empty L ⊆ T exists suchthat L ∩ NF ( → ) = ∅ and L is weakly closed under → + . Proof. If → is not SN then an infinite sequence t , t , t , . . . ∈ T exists such that t i → t i +1 for all i ≥
0. Then L = { t i | i ≥ } satisfies the required properties.Conversely, assume L satisfies the given properties. Since L is non-empty we can choose t ∈ L , and using the other properties for i = 0 , , , , . . . we can choose t i +1 ∈ L such that t i → + t i +1 , proving that → is not SN . (cid:74)(cid:73) Theorem 3.
An ARS → on T is not WN if and only if a non-empty L ⊆ T exists suchthat L ∩ NF ( → ) = ∅ and L is closed under → . Proof. If → is not WN then t ∈ T exists such that L ∩ NF ( → ) = ∅ for L = { u ∈ T | t → ∗ u } .Then L satisfies the required properties.Conversely, assume L satisfies the given properties. Since L is non-empty we can choose t ∈ L . Assume that → is WN , then t → t → · · · → t n exists such that t n ∈ NF ( → ). Since L is closed under → we obtain t i ∈ L for i = 1 , , . . . , n , contradicting L ∩ NF ( → ) = ∅ . (cid:74) A variant of Theorem 2, where → + is replaced by → , has been observed in [5]. To thebest knowledge of the authors, Theorem 3 has not been observed in the literature. (cid:73) Definition 4. A (non-deterministic finite) tree automaton A over a signature Σ is a tuple A = h Q, Σ , F, δ i where( i ) Q is a finite set of states ,( ii ) F ⊆ Q is a set of accepting states , and( iii ) δ a set of rewrite rules, called transition rules , of the shape f ( q , . . . , q n ) (cid:32) q where n is the arity of f ∈ Σ and q , . . . , q n , q ∈ Q . We write (cid:32) for the rewrite relationgenerated by the rules δ .Note that we use (cid:32) to distinguish automata transitions from term rewriting → with respectto some TRS R . (cid:73) Definition 5.
The language L ( A ) accepted by A is the set L ( A ) = { t | t ∈ T (Σ , ∅ ) , q ∈ F, t (cid:32) ∗ q } of ground terms that rewrite to a final state. Proving Looping and Non-Looping Non-Termination by Finite Automata
The kind of tree automata considered here is called bottom up in the literature. Sometimesin the definition of bottom-up tree automaton the right hand side q in the rule has argumentsand the acceptance criterion is rewriting to a term with a final state as root. However, whentree automata are only used for defining (term) languages as is the case in this paper, thesedefinitions coincide.Tree automata can be seen as a generalization of string automata as follows. For a stringautomaton (= NFA) S define the tree automaton A bytaking the same sets of states and accepting states, andtaking as signature the same signature in which all symbols are unary, extended by asingle constant ε , andtaking as transition rules ε (cid:32) q for q being the initial state of S , and for every transition q a → q in S the rule a ( q ) (cid:32) q .Form this definition it is immediate that a string a a · · · a n is accepted by S if and only if a n ( a n − ( · · · ( a ( ε )) · · · )) is accepted by A . Here we assume that S reads the string from leftto right (otherwise there is no need to reverse the order of the letters). (cid:73) Example 6.
To define a tree automaton accepting the language b a ∗ ( L | R ) a ∗ b , that is,all words that start with b , end with b , contain one L or R and otherwise only a , we start byits corresponding string automaton The above construction yields the treeautomaton A LR = h Q, Σ , F, δ i whereΣ = { b, L, R, a, ε } in which b, L, R, a are unary and ε is a constant, Q = { , , , } , F = { } and δ consists ofthe rules ε (cid:32) a (1) (cid:32) b (0) (cid:32) R (1) (cid:32) L (1) (cid:32) a (2) (cid:32) b (2) (cid:32) (cid:73) Example 7.
The following is a tree automaton for the signature Σ = { a, S } where a isbinary and S is a constant. Let A S = h Q, Σ , F, δ i where Q = { , , , , } , F = { } and S (cid:32) a (0 , (cid:32) a (1 , (cid:32) a (2 , (cid:32) a (3 , (cid:32) a (0 , (cid:32) a (2 , (cid:32) a (3 , (cid:32) a (0 , (cid:32) a symbol andwriting uvw = ( uv ) w . We show that this automaton accepts the term SSS ( SSS )( SSS ( SSS )):
SSS ( SSS )( SSS ( SSS )) (cid:32) (cid:32) (cid:32) (cid:32) (cid:32) ∈ F the term is accepted by the automaton.This automaton has been found automatically by our tool, and its language is closelyrelated to the QQQ -criterion of Waldmann [32, 3]. Roughly speaking, the language recognizedby this automaton can be described as follows:state 0 accepts only the term S ,state 1 accepts only the term SS ,state 2 corresponds to terms that contain at least one occurrence of SSS ,state 3 corresponds to terms that contain at least two occurrence of
SSS , andstate 4 accepts terms
M N for which both M and N contain two occurrences of SSS . . Endrullis and H. Zantema 5 In this section, we are concerned with automating the abstract non-termination methodsfrom Section 2. To this end, we use finite tree automata giving rise to regular tree languages.We first develop methods for disproving weak normalization and then for disproving strongnormalization.The applicability of the non-termination techniques described in the remainder of thispaper can be improved by two simple transformations of term rewrite systems R . The firsttransformation concerns the introduction of a fresh constant in Σ (see Remark 8) and thesecond transformation describes the elimination of collapsing rules in R (Remark 9). Bothtransformation do not affect (weak) normalisation of R . (cid:73) Remark 8 (Adding fresh constants) . Let R be a TRS over a signature Σ. If we are interestedin non-termination of R on arbitrary terms (including non-ground terms), then, without lossof generality, we can extend the signature Σ with a fresh constant c (a symbol of arity 0).Since the fresh constant can be thought of as a variable, this transformation neither affectsweak nor strong normalisation of R . Moreover, by adding a constant, we can reduce strongnormalisation of R to strong normalisation of R on all ground terms. The reason is that, ifthe signature contains at least one constant symbol, then both properties coincide.Note that adding a single fresh constant does not not suffice for weak normalisation.The addition of multiple fresh constants might be needed to make weak normalisation of R coincide with weak normalisation of R on ground terms.In this paper, we are interested in disproving (weakly) normalisation. The automatatechniques we employ in this paper actually yield the the stronger property that R is not(weakly) normalising on ground terms. Therefore we tacitly assume that the signature isextended with a fresh constant (if it does not already contain one). (cid:73) Remark 9 (Elimination of collapsing rules) . Let R be a TRS over a signature Σ. For thetechniques in the remainder by first eliminating collapsing rules, that is, rules of the form ‘ → x with x ∈ X . Assume that the TRS R contains a collapsing rule ‘ → x . For every f ∈ Σ we define the substitution σ f : X → T (Σ , X ) by σ f ( x ) = f ( x , . . . , x f ) ) for freshvariables x , . . . , x f ) and σ f ( y ) = y for all y = x . We define R = ( R \ { ‘ → x } ) ∪ { ‘σ f → xσ f | f ∈ Σ } Then R and R induce the same rewrite relation on ground terms. Hence R is (weakly)ground normalizing if and only if R is.Moreover, R is strongly normalising if and only if R is. This can be seen as follows. The‘if’-direction follows immediately from → R ⊆ → R . For the ‘only if’-direction assume that R admits an infinite rewrite sequence t → R t → R t → R · · · . Let f ∈ Σ and let x , . . . , x f ) be fresh variables. Define a substitution σ by σ ( x ) = f ( x , . . . , x f ) ) for all x ∈ X . Then t σ → R t σ → R t σ → R · · · is an infinite rewrite sequence in R . In this section, we collect decision procedures for the main properties of tree automata thatwe employ for proving non-termination, and we describe how we encode these procedures asBoolean satisfiability problems (SAT). (cid:73)
Remark 10 (SAT encoding of tree automata) . We encode the search for a tree automaton A = h Q, Σ , F, δ i over a signature Σ as a satisfiability problem as follows. We pick the number Proving Looping and Non-Looping Non-Termination by Finite Automata of states n ∈ N the automaton should have; the set of states is Q = { s , . . . , s n } . While theset of states Q is fix, we represent the final states F ⊆ Q by n fresh Boolean variables v F,s , v F,s , v F,s , . . . , v F,s n and, for every f ∈ Σ, we represent the transition relation δ by fresh variables v f,q ,...,q f ) ,q for every q , . . . , q f ) , q ∈ Q For the moment, there are no constraints (formulas) and the interpretation of these variablescan be chosen freely. The intention is that v F,s i is true if and only if s i is a final state, and v f,q ,...,q f ) ,q is true if and only if f ( q , . . . , q f ) ) (cid:32) q is a transition rule in δ . (cid:73) Definition 11.
A state q ∈ Q of a tree automaton A = h Q, Σ , F, δ i is called reachable ifthere exists a ground term t ∈ T (Σ , ∅ ) such that t (cid:32) ∗ q .We assume, without loss of generality, that all states are reachable. Note that requiringthat all states are reachable is not a restriction since we can always replace unreachablestates by ‘copies’ of reachable states. We guarantee reachability as follows. (cid:73) Lemma 12.
Let A = h Q, Σ , F, δ i be a tree automaton. Then all states of A are reachableif and only if there exists a total well-founded order < on the states Q such that for every q ∈ Q there exists f ∈ Σ and states q < q , q < q , . . . , q f ) < q with f ( q , . . . , q f ) ) (cid:32) q . Proof.
The reachable states are the smallest set Q ⊆ Q that is closed under δ , that is, q ∈ Q whenever f ( q , . . . , q f ) ) (cid:32) q for some f ∈ Σ and states q , . . . , q f ) ∈ Q .For the ‘if’-part, assume that there was a non-reachable state. Let q ∈ Q be the smallestnon-reachable state with respect to the order < . By assumption there exist f ∈ Σ and states q < q , q < q , . . . , q f ) < q with f ( q , . . . , q f ) ) (cid:32) q . By choice of q it follows that allstates q , q , . . . , q f ) are reachable, and hence q is reachable, contradicting the assumption.For the ‘only if’-part, assume that all states are reachable. Then Q is the result of stepwiseclosing ∅ under δ . There exists a sequence of states ∅ = Q ⊆ Q ⊆ . . . ⊆ Q | Q | = Q suchthat for every 0 ≤ i < | Q | we have Q i +1 = Q i ∪ { q i } for some q i ∈ Q \ Q i such that there are f i ∈ Σ and states q i, , . . . , q i, f i ) ∈ Q i with f i ( q i, , . . . , q i, f ) ) (cid:32) q i . The order < inducedby q < q < . . . < q | Q |− is a total order on the states with the desired property. (cid:74)(cid:73) Remark 13 (SAT encoding of reachability of all states) . We extend the encoding of treeautomata as described in Remark 10. We want to guarantee that all states are reachable byemploying Lemma 12. However, instead of encoding an arbitrary well-founded relation, wemake use of the fact that the names of states are irrelevant. Hence, without loss of generality(modulo renaming of states), we may assume that s < s < . . . < s n . We then encode thecondition of Lemma 12 by formulas _ f ∈ Σ , q Let A = h Q, Σ , F, δ i be a tree automaton such that all states are reachable.Then L ( A ) = ∅ if and only if F = ∅ . . Endrullis and H. Zantema 7 (cid:73) Remark 15 (SAT encoding of L ( A ) = ∅ ) . In a setting where all states are reachable, theencoding of L ( A ) = ∅ as satisfiability problem trivializes to: W q ∈ Q v F,q .The following lemma gives a simple criterion for closure under rewriting. (cid:73) Lemma 16 (Genet [25, Proposition 12]) . Let A = h Q, Σ , F, δ i be a tree automaton and R a left-linear term rewriting system. Then L ( A ) is closed under rewriting with respect to R iffor every ‘ → r ∈ R , α : X → Q and q ∈ Q we have ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A q . Note that left-linearity of R is crucial for the Lemma 16 since A can be a non-deterministicautomaton. If R would contain non-left-linear rules ‘ → r then we would need to checkset-assignments α : X → ℘ ( Q ) instead α : X → Q . That is, we would need to take intoaccount, that a non-deterministic automaton can interpret the same term by different states.For terms t , we use Var ( t ) to denote the set of variables occurring in t . (cid:73) Remark 17 (SAT encoding of closure under rewriting) . We encode the conditions of Lemma 16.Let the automaton A be encoded as in Remark 10. Let U be the set of all non-variablesubterms of left-hand sides and right-hand sides of rules in R . For every t ∈ U , assignment α : Var ( t ) → Q and q ∈ Q we introduce a fresh variable v t,α,q with the intended meaning: v t,α,q is true ⇐⇒ tα (cid:32) ∗ q .We ensure this meaning by the following formulas: for terms t = f ( t , . . . , t n ) ∈ Uv t,α,q ←→ _ q ,...,q n ∈ Q (cid:0) v t ,α ,q ∧ . . . ∧ v t n ,α n ,q n ∧ v f,q ,...,q n ,q (cid:1) where α i is the restriction of α to the domain Var ( t i ). For variables x ∈ U , we stipulate v x,α,q ⇐⇒ α ( x ) = q ; note that we can immediately evaluate and fill in these truth values.Finally, we encode ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A q by formulas v ‘,α,q → v r,α,q for every ‘ → r ∈ R , α : Var ( ‘ ) → Q and q ∈ Q .The following modification of Lemma 16 gives a simple criterion for weak closure underrewriting. The requirement rα (cid:32) ∗ A q of Lemma 16 is weakened to tα (cid:32) ∗ A q for some reduct t the left-hand side ‘ . (cid:73) Lemma 18. Let A = h Q, Σ , F, δ i be a tree automaton and R a left-linear term rewritingsystem. Then L ( A ) is weakly closed under rewriting with respect to R if for every ‘ → r ∈ R , α : X → Q and q ∈ Q we have ‘α (cid:32) ∗ A q = ⇒ tα (cid:32) ∗ A q for some term t such that ‘ → + R t . Proof. Let s ∈ L ( A ) \ NF ( → R ). Then s = C [ ‘σ ] for a context C , rewrite rule ‘ → r ∈ R and substitution σ : X → T (Σ , ∅ ). Since s ∈ L ( A ) there exists q ∈ Q such that ‘σ (cid:32) ∗ q and C [ q ] (cid:32) ∗ q with q ∈ F . By left-linearity ‘ does not contain duplicated occurrences ofvariables. As a consequence, there exists α : X → Q such that σ ( x ) (cid:32) ∗ α ( x ) and ‘α (cid:32) ∗ q .By the assumptions of the lemma, a term t exists such that ‘ → + R t and tα (cid:32) ∗ q . Hence tσ (cid:32) ∗ q and C [ tσ ] (cid:32) ∗ C [ q ] (cid:32) ∗ q . Thus C [ tσ ] ∈ L ( A ). Since s = C [ ‘σ ] → + R C [ tσ ], thisproves that L ( A ) is weakly closed under rewriting with respect to R . (cid:74)(cid:73) Remark 19 (SAT encoding of Lemma 18) . The conditions of Lemma 18 can be encodedsimilar to Lemma 16 (described in Remark 17). In Lemma 18 the condition rα (cid:32) ∗ A q isweakened to: tα (cid:32) ∗ A q for some reduct t the left-hand side ‘ . We can pick a finite set ofreducts U ⊆ { t | ‘ → + t } of the left-hand side ‘ , and encode the disjunction W t ∈ U tα (cid:32) ∗ A q as a Boolean satisfiability problem. Note that U = ∅ since r ∈ U . Proving Looping and Non-Looping Non-Termination by Finite Automata Next, we want to guarantee that the language L ( A ) contains no normal forms, in otherwords, that every term in the language contains a redex. For left-linear term rewritingsystems R , we can reduce this problem to language inclusion L ( A ) ⊆ L ( B ) where B is atree automaton that accepts the language of reducible terms. If R is a left-linear rewritesystem, then the set of ground terms containing redex occurrences is a regular tree language.A deterministic automaton B for this language can be constructed using the overlap-closureof subterms of left-hand sides, see further [15, 16]. Here, we do not repeat the construction,but state the lemma that we will employ: (cid:73) Lemma 20. Let { ‘ , . . . , ‘ n } be a set of linear terms over Σ . Then we can construct adeterministic and complete automaton B = h Q, Σ , F, δ i and sets F ‘ , . . . , F ‘ n ⊆ Q such thatfor every term t ∈ T (Σ , ∅ ) and i ∈ { , . . . , n } we have: t (cid:32) ∗ q with q ∈ F ‘ i if and only if t is an instance of ‘ i . Note that by choosing F = F ‘ ∪ . . . ∪ F ‘ n we obtain: t (cid:32) ∗ q with q ∈ F if and only if t isan instance ‘ i for some i ∈ { , . . . , n } . (cid:73) Example 21. The following tree automaton B S = h Q, Σ , F, δ i accepts the language ofground terms that contain a redex occurrence with respect to the S -rule a ( a ( a ( S, x ) , y ) , z ) → a ( a ( x, z ) , a ( y, z )). Here Q = { , , , } , Σ = { a, S } , F = { } and S (cid:32) a (0 , q ) (cid:32) a (1 , q ) (cid:32) a (2 , q ) (cid:32) a (3 , q ) (cid:32) a ( q , (cid:32) q ∈ { , , } and q ∈ { , , , } .Since the automaton B S is deterministic and complete, we can obtain an automaton B S = h Q, Σ , F , δ i that accepts the complement of the language (the language of groundnormal forms) by taking the complement F = { , , } of the set of final states.The following is crucial for feasibility of our approach. Deciding language inclusion of non-deterministic automata is known to be EXPTIME complete, see [31]. However, to guaranteethat a language contains no normal forms, it suffices to check whether two non-deterministicautomata have a non-empty intersection. This property can be decided in polynomial timeby constructing the product automaton and considering the reachable states. (cid:73) Definition 22. The product A × B of tree automata A = h Q, Σ , F, δ i and B = h Q , Σ , F , δ i is the tree automaton C = h Q × Q , Σ , F × F , γ i where the transition relation γ is given by f ( ( q , p ) , . . . , ( q n , p n ) ) (cid:32) γ ( q , p ) ⇐⇒ f ( q , . . . , q n ) (cid:32) δ q ∧ f ( p , . . . , p n ) (cid:32) δ p for every f ∈ Σ of arity n and states q , . . . , q n , q ∈ Q and p , . . . , p n , p ∈ Q . (cid:73) Lemma 23. Let A = h Q, Σ , F, δ i and B = h Q , Σ , F , δ i be tree automata. Then we have L ( A ) ∩ L ( B ) = ∅ if and only if in A × B no state in F × F is reachable. Proof. Let A × B = h Q × Q , Σ , ∅ , γ i . For the ‘if’-part, assume that L ( A ) ∩ L ( B ) = ∅ . Let t ∈ L ( A ) ∩ L ( B ). Then t (cid:32) ∗ δ q for some q ∈ F and t (cid:32) ∗ δ q for some q ∈ F . But then t (cid:32) ∗ γ ( q, q ) and hence ( q, q ) ∈ F × F is reachable in A × B ; this contradicts the assumption.For the ‘only if’-part, assume, for a contradiction, that t (cid:32) ∗ γ ( q, q ) in A × B with q ∈ F and q ∈ F . Then this directly translates to t (cid:32) ∗ δ q in A and t (cid:32) ∗ δ q in B . Hence t ∈ L ( A )and t ∈ L ( B ), contradicting L ( A ) ∩ L ( B ) = ∅ . (cid:74) We can use Lemma 23 to check that the language L ( A ) of an automaton A does notcontain normal forms. To this end, we only need an automaton B that accepts all groundnormal forms. Then L ( A ) contains no normal forms if L ( A ) ∩ L ( B ) = ∅ . . Endrullis and H. Zantema 9 (cid:73) Example 24. The reachable states of the product A S × B S of the automata A S fromExample 7 and B S from Example 21 are (0 , , (1 , , (2 , , (2 , , (3 , , (3 , , (2 , , (4 , q, q ) such that q is accepting in A S is (4 , 3) and 3 is not an accepting stateof B S . The conditions of Lemma 23 are fulfilled and hence L ( A S ) ∩ L ( B S ) = ∅ . Recall that B S accepts all ground normal forms, and thus every term accepted by A S contains a redex. (cid:73) Remark 25 (SAT encoding of empty intersection) . Let A = h Q, Σ , F, δ i and B = h Q , Σ , F , δ i be tree automata. Let A × B = h Q × Q , Σ , ∅ , γ i .First, note that reachability of all states in the automata A and B does not imply thatall states in the product automaton A × B are reachable. As a consequence, we have to‘compute’ the set of reachable states using Boolean satisfiability problems. For this purpose,we reformulate Lemma 23 in the following equivalent way: . . . , then L ( A ) ∩ L ( B ) = ∅ ifand only if there exists a set of states P ⊆ Q × Q such that(i) P is closed under transitions in A × B , that is, q ∈ P whenever f ( q , . . . , q n ) (cid:32) γ q forsome q , . . . , q n ∈ P , and(ii) for all ( q, q ) ∈ P it holds that q ∈ F implies q F .Note that this statement is equivalent to Lemma 23. Item (i) guarantees that P containsall reachable states, and hence (ii) is required for at least the reachable states. Thus theconditions imply those of Lemma 23. On the other hand, we can take P to be precisely theset of reachable states, and then the conditions are exactly those of Lemma 23.The idea is that the reformulated statement has a much more efficient encoding as Booleansatisfiability problem. We only need to encode the closure of P under transitions, but thereis no longer the need for encoding the property that P is the smallest such set (which is astatement of second-order logic).Assume that we have a SAT encoding of the automata A and B as in Remark 10; wewrite v A,... for the variables encoding A , and v B,... for the variables encoding B . To representthe set P , we introduce variables p ( q,q ) for every ( q, q ) ∈ Q × Q and the properties aretranslated into the following formulas:(i) for every f ∈ Σ with arity n and ( q , q ) , . . . , ( q n , q n ) , ( q, q ) ∈ Q × Q :( v A,f,q ,...,q n ,q ∧ v B,f,q ,...,q n ,q ∧ p ( q ,q ) ∧ p ( q ,q ) ∧ . . . ∧ p ( q n ,q n ) ) → p ( q,q ) (ii) for every ( q, q ) ∈ Q × Q : ( p ( q,q ) ∧ v A,F,q ) → ¬ v B,F ,q .Each of these formulas simplifies to a single clause (a disjunction of literals).We remark that we will employ this translation for the case that B consists of the setof terms containing redex occurrences with respect to a given rewrite system R . Then B is known and fixed before the translation to a satisfiability problem. As a consequence, weknow the truth values of v B,f,q ,...,q n ,q and v B,F ,q in the formulas above, and can immediateskip the generation of formulas that are trivially true (the large majority in case (i)). (cid:73) Remark 26 (Complexity of the SAT encoding) . While the encoding is efficient for stringrewriting systems, it suffers from an ‘encoding explosion’ for term rewriting systems con-taining symbols of higher arity. The problem arises from the SAT encoding of the recursivecomputation of the interpretation of terms (described in Remark 17). The computation of theinterpretation of a term f ( t , . . . , t n ) containing m variables needs O ( | Q | m + n +1 ) clauses: m for the quantification over the variable assignments, n for the possible states of t , . . . , t n and1 for the possible result states. To some extend, this problem can be overcome by ‘uncurrying’ the system, that is, for every symbol f of arity n > f , . . . , f n − of arity 2 and then replace all occurrences of f ( t , . . . , t n ) by f n − ( . . . f ( f ( t , t ) , t ) . . . , t n ).This transformation helps to bring the complexity down to O ( | Q | m +3 ). Nevertheless, forexample for the S-rule, which only contains binary symbols, we still need | Q | clauses. Wenote that after the uncurrying transformation, an automaton with more states may be neededto generate ‘the same’ language. We are now ready to use Theorem 3 in combination with tree automata for automaticallydisproving weak normalization. The language L in the theorem is described by a non-deterministic tree automaton. In the previous section, we have seen how the relevantproperties of tree automata can be checked. Here, we summarize the procedure: (cid:73) Technique 27. Let R be a left-linear TRS. We search for a tree automaton A = h Q, Σ , F, δ i such that L ( A ) fulfills the properties of Theorem 3:( i ) We guarantee L ( A ) ∩ NF ( → ) = ∅ by the following steps:We employ Lemma 20 to construct a deterministic, complete automaton B = h Q, Σ , F, δ i that accepts the set of terms containing redex occurrences with respect to R .Then the automaton B = h Q, Q \ Σ , F, δ i accepts all ground normal forms.We use Lemma 23 to check that L ( A ) ∩ L ( B ) = ∅ (thus L ( A ) ⊆ L ( B )).( ii ) We guarantee that L ( A ) is closed under → by Lemma 16.( iii ) We use Lemma 14 to ensure that L ( A ) = ∅ .These conditions can be encoded as satisfiability problems as described in Remarks 10, 13,25, 15 and 17. This enables us to utilize SAT solvers to search for suitable automata A . (cid:73) Remark 28. We note the combination of Technique 27 with Remark 9 is complete withrespect to disproving weak normalization on regular languages: if there exists a regularlanguage L fulfilling the conditions of Theorem 3, then weak normalization can be disprovedusing Technique 27 after eliminating collapsing rules as in Remark 9.This can be seen as follows. In the work [8, 9] a generalized method for ensuring closureof the language of automata under rewriting has been proposed. Thereby the condition ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A q of Lemma 16 is weakened to ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A p for some p ≥ q . (1)Here ≤ is a quasi-order on the states Q and the automaton must be monotonic with respectto this order, see Definition 35. The monotonicity guarantees that the language of theautomaton is closed under rewriting.In [24] it has been shown that this monotonicity property is strong enough to characterizeand decide the closure of the regular languages under rewriting. In particular, the languageof a deterministic tree automaton is closed under rewriting if and only if there exists such amonotonic quasi-order on the states.Let R be a TRS such that there exists a regular language that satisfies the conditions ofTheorem 3. Then there exists a deterministic, complete automaton A accepting this languageand a quasi-order ≤ on the states satisfying (1) and monotonicity. Let R be obtained from R by eliminating collapsing rules as described in Remark 9. We obtain a non-deterministicautomaton A that fulfils the requirements of Technique 27 for R by closing the transitionrelation of A under ≤ : we add f ( q , . . . , q n ) (cid:32) q whenever q ≤ p and f ( q , . . . , q n ) (cid:32) p . As . Endrullis and H. Zantema 11 a consequence of monotonicity and using induction over the term structure, we obtain for allterms t ∈ T (Σ , X ) with t 6∈ X and α : X → Q that( ? ) t (cid:32) ∗ A q if and only if t (cid:32) ∗ A p for some p with q ≤ p .As a consequence of ( ? ) and monotonicity we have L ( A ) = L ( A ) (roughly speaking, if q ≤ p ,then q accepts a subsets of the language of p ). Thus L ( A ) ∩ NF ( → ) = ∅ and L ( A ) = ∅ areguaranteed. Finally, we show that Lemma 16 is applicable for R and A . Let ‘ → r ∈ R , α : X → Q and q ∈ Q such that ‘α (cid:32) ∗ A q . Then by ( ? ) we get ‘α (cid:32) ∗ A q for some q ∈ Q with q ≤ q . By (1) we have that rα (cid:32) ∗ A q for some q ∈ Q with q ≤ q . Again by ( ? ) weobtain that rα (cid:32) ∗ A q . Hence the conditions of Technique 27 are fulfilled for R and A . (cid:73) Example 29. We consider the following string rewriting system: aL → La Ra → aR bL → bR Rb → Lab This rewrite system is neither strongly nor weakly normalizing, but does not admit loopingreductions, that is, reductions of the form s → + ‘sr . An example of an infinite reduction is: bLb → bRb → bLab → bRab → baRb → baLab → bLaab → bRaab → · · · It is easy to check that the automaton A LR from Example 6 fulfills the requirements ofTechnique 27. Hence, the system is not weakly normalizing. (cid:73) Example 30. We consider the S -rule from combinatory logic: a ( a ( a ( S , x ) , y ) , z ) → a ( a ( x, z ) , a ( y, z ))For the S -rule it is known that there are no reductions t → ∗ C [ t ] for ground terms t , see [32].For open terms t the existence of reductions t → ∗ C [ tσ ] is open.It is straightforward to verify that the automaton A S from Example 7 fulfills the require-ments of Technique 27, and hence the S -rule, and in particular the term SSS ( SSS )( SSS ( SSS )),are not weakly normalizing. (cid:73) Example 31. The δ -rule (known as Owl in Combinatory Logic) is even simpler: δxy → y ( xy ) , or equivalently a ( a ( δ, x ) , y ) → a ( y, a ( x, y )) . As shown in [4], this rule does not admit loops, , and the techniques in [7] fail for this system.The Technique 27 can be applied to automatically disprove weak-normalization for this rule.Our tool finds a tree automaton that has 3 states and accepts the language of all groundterms with two occurrences of δδ . In fact, this is precisely the language of non-terminatingground δ -terms, see further [4].In all examples until now infinite reductions exist of the regular shape based on tσ n τ rewriting to a term having tσ f ( n ) τ µ as a sub-term, for every n , for some term t andsubstitutions σ, τ, µ and an ascending linear function f . For instance, the S rule (Example30) admits an infinite reduction implied by tσ n τ rewriting to a super-term of tσ n +1 τ , for t = a ( x, x ), σ ( x ) = Ax , τ ( x ) = SA ( SAA ), for A = SSS . (cid:73) Example 32. The following example does not have an infinite reduction of this regularshape, neither of the more general patterns from [30] and [7]. aL → La Raa → aaaR bL → bRa Rb → Lb Rab → Lab. In this system bRa n b rewrites to bRa f ( n ) b for f defined by f (2 n ) = 3 n + 1 and f (2 n + 1) =3 n + 2 for all n . This obviously yields an infinite reduction, but f is not linear, by which thisexample is outside the scope of [30] and [7]. In our approach a proof of non-termination andeven non-weak-normalization is extremely simple: ba ∗ ( L | R ) a ∗ b is non-empty, closed underrewriting and does not contain normal forms. For disproving strong normalization based on Theorem 2, the only difference with Technique 27is that checking that L is closed under → by Lemma 16 has to be replaced by checking that L is weakly closed under → by Lemma 18. The technique is applicable to string and termrewriting systems, and can be automated as described in Technique 27 and Remark 19. (cid:73) Example 33. Let us consider the rewrite system aaL → Laa Ra → aR bL → bR Rb → Lab Rb → aLb This system is non-looping and non-terminating. However, in contrast to Example 29, thissystem is weakly normalizing, since by always choosing the fourth rule the last rule is neverused, and the first four rules are terminating. Hence the Technique 27 is not applicable forthis TRS. However, the following pattern extends to an infinite reduction bRa n b → n ba n Rb → ba n Lab → n bLa n +1 b → bRa n +1 b → n +1 ba n +1 Rb → ba n +2 Lb → n +1 bLa n +2 b → bRa n +2 b. Instead of finding this pattern explicitly,non-termination is also concluded fromchecking that b ( aa ) ∗ ( L | R | aR ) a ∗ b describes a language satisfying all condi-tions from Theorem 2. A correspondingautomaton is given on the right.The conditions of Theorem 2 are now checked as follows. Non-emptiness follows from theexistence of a path from state 0 to state 4. Every path from 0 to 4 either contains one ofthe patterns aaL , Ra , bL or Rb , so it remains to show weakly closedness under rewriting byLemma 18. In the setting of string automata this means that for every left hand side ‘ andevery ‘ -path from a state p to a state q we should find a u -path from p to q for a string u such that ‘ rewrites to u in one or more steps. For ‘ = aaL the only path is from 1 to 2, forwhich there is also an Laa path. For ‘ = Ra there is a path from 1 to 2, for which there isalso an aR path via 3. The only other option for ‘ = Ra is a path from 3 to 2, for whichthere is also an aR path via 1. For ‘ = bL the only path is from 0 to 2, for which there isalso a bR path. Finally, for ‘ = Rb there is a path from 1 to 4, for which there is also an Lab path and a path from 3 to 4, for which there is also an aLb path, by which all conditionshave been verified. Note that for the Rb -path from 1 to 4 it is essential to use the 4th rule,while for the Rb -path from 3 to 4 it is essential to use the last rule.This example can also be treated by the technique introduced in the following section. . Endrullis and H. Zantema 13 In this section, we improve the method for proving non-termination. The methods introducedso far are not able to handle the following example. (cid:73) Example 34. We consider the following string rewriting system: zL → Lz Rz → zR zLL → zLR RRz → LzRz This rewrite system is weakly normalizing but not strongly normalizing. The non-terminationcriteria introduced in the previous sections are not applicable for this system. Let us considerthe first steps of an infinite reduction: zLLzzRz → zLRzzRz → zLzRzRz → zLzzRRz → zLzzLzRz → zLzLzzRz → zLLzzzRz → . . . Note the underlined occurrences of zLL . Due to the rule zLL → zLR , the word zL is themarker for ‘turning’ on the left; However, this marker zL is itself a redex. To obtain aninfinite reduction, this marker must not be reduced.The idea for proving non-termination of systems like Example 34 is to let the automatondetermine which redex to contract. To this end, we introduce a ‘redex selection’ function ξ : Q → P ( R )that maps states of the automaton to sets of rules that may be contracted at the correspondingposition in the term. The idea is that a redex ‘σ in a term C [ ‘σ ] with respect to a rule ‘ → r is allowed to be contracted if ‘σ (cid:32) ∗ q with ‘ → r ∈ ξ ( q ). In this way, the automatondetermines what redexes are to be contracted. Then the automaton only needs to fulfill theproperty ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A q for the selected rules : ‘ → r ∈ ξ ( q ) ∧ ‘α (cid:32) ∗ A q = ⇒ rα (cid:32) ∗ A q for every rule ‘ → r ∈ R , state q ∈ Q and α : X → Q . Moreover, as proposed in [8, 9, 24], weweaken the requirement rα (cid:32) ∗ A q to rα (cid:32) ∗ A p for some p ≥ q . Here ≤ is a quasi-order on thestates and the automaton must be monotonic with respect to this order (see Definition 35).The monotonicity guarantees that the language of the automaton is closed under rewriting.For the present paper, this closure property holds only for the rules selected by ξ . (cid:73) Definition 35 (Monotonicity) . A tree automaton A = h Q, Σ , F, δ i is monotonic withrespect to a quasi-order ≤ on the states Q if the following properties hold:( i ) For all f ∈ Σ with arity n and states a ≤ b , a ≤ b , . . . , a n ≤ b n , it holds f ( a , . . . , a n ) (cid:32) A q = ⇒ f ( b , . . . , b n ) (cid:32) A p for some p ∈ Q with q ≤ p ( ii ) Whenever q ∈ F and q ≤ p , then p ∈ F .The following lemma is immediate by induction on the size of the context. (cid:73) Lemma 36. Let A = h Q, Σ , F, δ i be a tree automaton that is monotonic with respect to aquasi-order ≤ on the states Q . Let a, b ∈ Q with a ≤ b . Then for all ground contexts C wehave that C [ a ] (cid:32) a with a ∈ Q implies that C [ b ] (cid:32) b for some b ∈ Q with a ≤ b . (cid:73) Definition 37 (Runs) . Let A = h Q, Σ , F, δ i be a tree automaton and t ∈ T (Σ , ∅ ). A run of A on t is a function ρ : Pos ( t ) → Q such that for every p ∈ Pos ( t ) and t ( p ) = f ∈ Σ thereis a rule f ( ρ ( p , . . . , ρ ( pn )) (cid:32) ρ ( p ) in δ . The run ρ is accepting if ρ ( ε ) ∈ F .Note that there is a direct correspondence between runs on t and rewrite sequences t (cid:32) ∗ q .We are now ready to state the generalized theorem for disproving strong normalization. (cid:73) Theorem 38. Let R be a left-linear TRS. Let A = h Q, Σ , F, δ i be a tree automaton with L ( A ) = ∅ , ≤ a quasi-order on the states Q , and ξ : Q → P ( R ) a function, called redexselection function . Assume that the following properties hold:(a) The automaton A is monotonic with respect to ≤ .(b) For every state q ∈ Q , rule ‘ → r ∈ R and α : X → Q it holds that: ‘α (cid:32) ∗ A q ∧ ‘ → r ∈ ξ ( q ) = ⇒ ( ∃ p ∈ Q. q ≤ p ∧ rα (cid:32) ∗ A p ) ∨ ( ∃ r (cid:69) r. ∃ q ∈ F. r α (cid:32) ∗ A q ) (c) For every term t ∈ T (Σ , ∅ ) and accepting run ρ on t there is a position p such that t | p isan instance of the left-hand side of a rule ‘ → r ∈ ξ ( ρ ( p )) .Then R is not strongly normalizing. Proof. Assume that the conditions of the theorem are fulfilled. To disprove strong normaliz-ation of → it suffices to disprove strong normalization of → ◦ (cid:68) where (cid:68) is the (non-strict)sub-term relation. We show that L ( A ) and → ◦ (cid:68) fulfill the requirements of Theorem 2.Let t ∈ L ( A ). Then there exists an accepting run ρ of A on t . By item (c) there exists aposition p ∈ Pos ( t ) and a rule ‘ → r ∈ ξ ( ρ ( p )) such that t | p is an instance of ‘ . Then t | p = ‘σ for some substitution σ . By left-linearity, we can define α : Var ( ‘ ) → Q by α ( x ) = ρ ( pp )whenever ‘ | p ∈ X . Then ‘α (cid:32) ∗ ρ ( p ) and we distinguish cases according to item (b): There exists q ∈ Q with ρ ( p ) ≤ q and rα (cid:32) ∗ q . We know that t [ ‘σ ] p = t (cid:32) ∗ ρ ( ε ) anddefine t = t [ rσ ] p . Note that t → t and t → ◦ (cid:68) t . We have t (cid:32) t [ ρ ( p )] (cid:32) ρ ( ε ) and ρ ( p ) ≤ q . By Lemma 36 we have t [ q ] (cid:32) q for some q ≥ ρ ( ε ) and by monotonicity q ∈ F .Hence t = t [ rσ ] p (cid:32) t [ q ] (cid:32) ∗ q . Thus t ∈ L ( A ) and t → ◦ (cid:68) t . There exist r (cid:69) r and q ∈ F such that r α (cid:32) ∗ q . Then r σ (cid:32) ∗ q and hence r σ ∈ L ( A ).Moreover, t → ◦ (cid:68) r σ .This shows that L ( A ) contains no normal forms and is weakly closed under → ◦ (cid:68) . ByTheorem 2, → ◦ (cid:68) is not strongly normalizing and hence → is not strongly normalizing. (cid:74)(cid:73) Remark 39 (SAT encoding of the conditions of Theorem 38) . To encode the conditions ofTheorem 38 as a Boolean satisfiability problem we proceed as follows. For every q, q ∈ Q ,we introduce a fresh variable v ≤ ,q,q with the intended meaning: v ≤ ,q,q is true ⇐⇒ q ≤ q ,and for every q ∈ Q and ‘ → r ∈ R a fresh variable v ξ,q,‘ → r with the intended meaning: v ξ,q,‘ → r is true ⇐⇒ ‘ → r ∈ ξ ( q ) .The conditions (a), (b) and (c) of Theorem 38 can be encoded as follows: . Endrullis and H. Zantema 15 (a) For condition (a) we proceed as follows. We ensure that ≤ is a quasi-order using thefollowing formulas v ≤ ,q,q for every q ∈ Q (reflexivity) v ≤ ,q ,q ∧ v ≤ ,q ,q → v ≤ ,q ,q for every q , q , q ∈ Q (transitivity)For monotonicity of the automaton with respect to ≤ we introduce fresh variables m f,q ,...,q f ) ,q,q and formulas m f,q ,...,q f ) ,q,q → v ≤ ,q,q ∧ v f,q ,...,q f ) ,q for every f ∈ Σ and q , . . . , q f ) , q, q ∈ Q . Then monotonicity translates to formulas v F,q ∧ v ≤ ,q,q → v F,q for every q, q ∈ Q , and v f,q ,...,q f ) ,q ∧ v ≤ ,q i ,q i → _ q ∈ Q m f,q ,...,q i − ,q i ,q i +1 ,...,q f ) ,q,q for every q , . . . , q f ) , q ∈ Q , i ∈ { , . . . , f ) } and q i ∈ Q .(b) For condition (b) we adapt Remark 17. For every t ∈ U , assignment α : Var ( t ) → Q and q ∈ Q , we have fresh variables v t,α,q with the intended meaning: v t,α,q is true ⇐⇒ tα (cid:32) ∗ q .with the corresponding formulas (ensuring the intended meaning) as in Remark 17. Forevery ‘ → r ∈ R , α : Var ( ‘ ) → Q and q, q ∈ Q , we introduce a fresh variable m r,α,q,q and formula m r,α,q,q → v ≤ ,q,q ∧ v r,α,q . Likewise, for every ‘ → r ∈ R , r (cid:69) r , α : Var ( r ) → Q and q ∈ Q , we add a fresh variable m F,r ,α,q and formula m F,r ,α,q → v F,q ∧ v r,α,q Then condition (b) translates to v ‘,α,q ∧ v ξ,q,‘ → r → (cid:0) _ q ∈ Q m r,α,q,q (cid:1) ∨ (cid:0) _ r (cid:69) r, q ∈ Q m F,r ,α,q (cid:1) for every ‘ → r ∈ R , α : Var ( ‘ ) → Q and q ∈ Q .(c) For condition (c) we extend Remark 25, as follows. Let ‘ , . . . , ‘ n be the left-hand sidesof rules in R . Let B be the automaton and F ‘ , . . . , F ‘ n the sets of states obtained fromLemma 20. We construct the product automaton A × B , and then we compute thosestates that are reachable without passing states ( q, q ) for which there exists ‘ → r ∈ ξ ( q )such that q ∈ F ‘ (that is, the rule ‘ → r is selected by A and B confirms that the termis an instance of ‘ ). We adapt the encoding of Remark 25 as follows: (i) for every f ∈ Σ with arity n and ( q , q ) , . . . , ( q n , q n ) , ( q, q ) ∈ Q × Q : (cid:0) v A,f,q ,...,q n ,q ∧ v B,f,q ,...,q n ,q ∧ p ( q ,q ) ∧ p ( q ,q ) ∧ . . . ∧ p ( q n ,q n ) ∧ ^ ‘ → r ∈ R, q ∈ F ‘ ¬ v ξ,q,‘ → r (cid:1) → p ( q,q ) (ii) for every ( q, q ) ∈ Q × Q : p ( q,q ) → ¬ v A,F,q .In (i), due to the added condition, we do not consider all reachable states ( q, q ) but onlythose for which there exists no rule ‘ → r ∈ R that is applicable at the root of the currentsubterm ( q ∈ F ‘ ) and that is activated ( v ξ,q,‘ → r ). The formulas in (ii) guarantee that nostate ( q, q ), that is reachable in this sense, is accepted by A . (cid:73) Remark 40 (Incompleteness with respect to Loops) . We note there exist (left-linear) TRSssystems that admit loops but cannot be proven non-terminating using Theorem 38. Forexample, consider the following rewrite system: a → b f ( a, b ) → g ( a ) g ( x ) → f ( x, x )This system admits the loop g ( a ) → f ( a, a ) → f ( a, b ) → g ( a ). However, it is not possible toprove non-termination of this system by Theorem 38. We sketch the argument. Assume thatthere was a tree automaton A fulfilling the conditions of the theorem. Then the automatonadmits the rewrite step g ( a ) → f ( a, a ). Since both a ’s in f ( a, a ) are copies of the a in g ( a ),the automaton ‘interprets’ both occurrences of a as the same state. Now, to obtain an infiniterewrite sequence, the rule a → b must be activated for the right a in f ( a, a ). However, thenthis rule is also activated for the left a , but contracting the left a leads to a normal form. We have implemented the improved method for disproving strong normalization (Theorem 38)presented in this paper. For the purpose of evaluating our techniques, the tool applies onlythe methods presented in this paper, and no other non-termination method like loop checks.The SAT solver employed for the evaluation results in this section is MiniSat [6]. Our toolcan be downloaded from http://joerg.endrullis.de/non-termination/ .Our tool can automatically prove non-termination of all examples in this paper, includingthe S-rule and the δ -rule. The following table shows the size of the automata that are foundby the tool as witnesses for non-termination for the examples in our paper: Example 29 30 31 32 33 34Number of states 4 5 3 4 5 6 Each of these automata has been found within less than a second on a dual core laptop.We have also evaluated our methods on the database used in [7], consisting of 58 non-terminating term rewriting systems that do not admit loops. The tool AProVE recognizes 44systems as non-terminating; an impressive 76%. An extension of AProVE with our methodwould increase the recognition by 8.5% to 84.5%. In other words, our method succeeds on36% (that is 5 systems) of the remaining 14 systems for which AProVE did not find a proof.These 5 systems are: nonloop/TRS/emmes/ex3_4.trsnonloop/TRS/own/challenge_fab.trs . Endrullis and H. Zantema 17 nonloop/TRS/own/downfrom.trsnonloop/TRS/own/ex_payet.trsnonloop/TRS/own/isList-List.trs In total, our tool succeeds for 26 of the 58 non-looping examples from [7]. The resultssuggest that our method and that of [7] are complementary and should be combined formaximum strength. The paper [7] explicitly mentions that the following example is beyondtheir techniques (this example is not part of the database above): f (true , true , x, s( y )) → f ( isNat ( x ) , isNat ( y ) , s( x ) , double (s( y ))) isNat (0) → true isNat (s( x )) → isNat ( x ) double (0) → double (s( x )) → s(s( double ( x )))Our non-termination techniques can handle this system: the tool finds an automaton with 6states within 3 seconds (using the transformation from Remark 26).Finally, we have evaluated the tool on the termination problem database (TPDB). Wehave run our tool on all string and term rewriting systems (of the standard categories) thatremained unsolved during the last full run of all tools in December 2013. For string rewriting,our tool was able to disprove termination for 13, and for term rewriting, for 8 systems ofthe unsolved systems. This corresponds to an increase of strength of 11.5% (114 + 13) forstring rewriting and of 3% (274 + 8) for term rewriting. Let us mention that many of the 13string rewriting systems actually admit loops, but very complicated ones, that are not foundby the standard tools. These loops have been found in previous competitions by the toolsMatchbox [33] and Knocked for Loops [37]. In this paper, we have employed regular languages for proving non-termination. Instead ofsearching for an infinite reduction explicitly we search for a regular language with propertiesfrom which non-termination easily follows. After encoding these properties in a propositionalformula, the actual search is done by a SAT solver. In some examples, like Example 32,a very simple corresponding regular language is quickly found by our approach, while theactual infinite reductions have a non-linear pattern being beyond earlier approaches.For future work, it is interesting to investigate whether this approach can be extended tocontext-free (tree) languages; such an approach could potentially also generalize [7]. Thequestion is whether there are efficient criteria to check the conditions of Theorem 2. Forexample, consider the following string rewriting system: bB → Bb bcd → BcD Dd → dDaX → abb BX → Xb bcd → XcY Y D → dY Y e → dde This system admits for every n > a b n c d n e → ∗ a B n − bcd D n − e → ∗ a B n − XcY D n − e → ∗ a b n +1 c d n +1 e As a description of this pattern needs a context-free language, it is unlikely that a regularlanguage exists that fulfills the requirements of Theorem 2. As described in Remark 26, the SAT encoding of (non-deterministic) automata is notefficient for symbols of higher arity. We think that these problems can be overcome by moreefficient encodings of automata. For example, the uncurrying transformation mentionedin Remark 26 can be seen as a restriction of the shape of the automata (the transition iscomputed argument by argument) instead of a transformation on the system. It would beinteresting to investigate what other restrictions would lead to a more efficient representationof automata as Boolean satisfiability problems. Results in this direction can be of interest invarious areas where automata are applied.We think that it is also interesting to investigate whether the characterization of strongand weak normalization (Theorems 2 and 3) can be adapted to the setting of infinitaryrewriting [20, 22, 14] with infinite terms and ordinal-length reductions; the interestingproperties then are infinitary strong and weak normalization.Finally, we note that equality of streams [17, 18, 38, 19] (infinite sequences of symbols)can be rendered as a non-termination problem (a comparison program running indefinitelyif the streams are equal, and terminating as soon as a difference is found). It remains tobe investigated whether non-termination techniques can be employed fruitfully for provingstream equality. References Homepage of AProVE, 2015. http://aprove.informatik.rwth-aachen.de . Homepage of TTT2, 2015. http://cl-informatik.uibk.ac.at/software/ttt2/ . H.P. Barendregt, J. Endrullis, J.W. Klop, and J. Waldmann. Dance of the Starlings. 2015.To be published on arXiv.org. H.P. Barendregt, J. Endrullis, J.W. Klop, and J. Waldmann. Songs of the Starling and theOwl. 2015. To be published on arXiv.org. B. Cook. Priciples of program termination. http://research.microsoft.com/en-us/um/cambridge/projects/terminator/principles.pdf . N. Eén and A. Biere. Effective Preprocessing in SAT through Variable and Clause Elimina-tion. In Proc. Conf. on Theory and Applications of Satisfiability Testing (SAT ’05) , volume3569 of LNCS , pages 61–75. Springer, 2005. F. Emmes, T. Enger, and J. Giesl. Proving Non-looping Non-termination Automatically.In International Joint Conference on Automated Reasoning (IJCAR 2012) , volume 7364 of LNCS , pages 225–240. Springer, 2012. J. Endrullis, R. C. de Vrijer, and J. Waldmann. Local Termination. In Proc. Conf. on Re-writing Techniques and Applications (RTA) , volume 5595 of LNCS , pages 270–284. Springer,2009. J. Endrullis, R.C. de Vrijer, and J. Waldmann. Local Termination: Theory and Practice. Logical Methods in Computer Science , 6(3), 2010. J. Endrullis, H. Geuvers, J. G. Simonsen, and H. Zantema. Levels of Undecidability inRewriting. Information and Computation , 209(2):227–245, 2011. J. Endrullis, H. Geuvers, and H. Zantema. Degrees of Undecidability in Term Rewriting.In Proc. Int. Workshop on Computer Science Logic (CSL 2009) , volume 5771 of LNCS ,pages 255–270. Springer, 2009. J. Endrullis, C. Grabmayer, D. Hendriks, J.W. Klop, and R.C. de Vrijer. Proving InfinitaryNormalization. In Postproc. Int. Workshop on Types for Proofs and Programs (TYPES2008) , volume 5497 of LNCS , pages 64–82. Springer, 2009. J. Endrullis, C. Grabmayer, J.W. Klop, and V. van Oostrom. On Equal µ -Terms. Theor- etical Computer Science , 412(28):3175–3202, 2011. . Endrullis and H. Zantema 19 J. Endrullis, H. Hvid Hansen, D. Hendriks, A. Polonsky, and A. Silva. A CoinductiveFramework for Infinitary Rewriting and Equational Reasoning. In Proc. Conf. on RewritingTechniques and Applications (RTA 2015) , Leibniz International Proceedings in Informatics.Schloss Dagstuhl, 2015. J. Endrullis and D. Hendriks. Transforming Outermost into Context-Sensitive Rewriting. Logical Methods in Computer Science , 6(2), 2010. J. Endrullis and D. Hendriks. Lazy Productivity via Termination. Theoretical ComputerScience , 412(28):3203–3225, 2011. J. Endrullis, D. Hendriks, and R. Bakhshi. On the Complexity of Equivalence of Spe-cifications of Infinite Objects. In ACM SIGPLAN International Conference on FunctionalProgramming (ICFP 2012) , pages 153–164. ACM, 2012. J. Endrullis, D. Hendriks, R. Bakhshi, and G. Roşu. On the complexity of stream equality. Journal of Functional Programming , 24(2–3):166–217, 2014. J. Endrullis, D. Hendriks, and M. Bodin. Circular Coinduction in Coq Using Bisimulation-Up-To Techniques. In Proc. Conf. on Interactive Theorem Proving (ITP) , volume 7998 of LNCS , pages 354–369. Springer, 2013. J. Endrullis, D. Hendriks, and J.W. Klop. Highlights in Infinitary Rewriting and LambdaCalculus. Theoretical Computer Science , 464:48–71, 2012. J. Endrullis, D. Hofbauer, and J. Waldmann. Decomposing Terminating Rewrite Relations. In Proc. Workshop on Termination (WST ’06) , pages 39–43, 2006. J. Endrullis and A. Polonsky. Infinitary Rewriting Coinductively. In Proc. Types forProofs and Programs (TYPES 2012) , volume 19 of Leibniz International Proceedings inInformatics , pages 16–27. Schloss Dagstuhl, 2013. J. Endrullis and H. Zantema. Proving Non-Termination by Finite Automata. In Proc. Conf.on Rewriting Techniques and Applications (RTA 2015) , Leibniz International Proceedingsin Informatics. Schloss Dagstuhl, 2015. B. Felgenhauer and R. Thiemann. Reachability Analysis with State-Compatible Automata.In LATA , volume 8370 of LNCS , pages 347–359. Springer, 2014. T. Genet. Decidable Approximations of Sets of Descendants and Sets of Normal Forms. In Proc. Conf. on Rewriting Techniques and Applications (RTA ’98) , volume 1379 of LNCS ,pages 151–165. Springer, 1998. A. Geser, D. Hofbauer, J. Waldmann, and H. Zantema. On tree automata that certify ter-mination of left-linear term rewriting systems. Information and Computation , 205(4):512–534, 2007. A. Geser and H. Zantema. Non-looping String Rewriting. RAIRO Theoretical Informaticsand Applications , 33(3):279–302, 1999. M. Korp and A. Middeldorp. Match-bounds revisited. Information and Computation ,207(11):1259–1283, 2009. M. Mousazadeh, B. T. Ladani, and H. Zantema. Liveness verification in trss using treeautomata and termination analysis. Computing and Informatics , 29(3):407–426, 2010. M. Oppelt. Automatische Erkennung von Ableitungsmustern in nichtterminierenden Wort-ersetzungssystemen. Technical report, HTWK Leipzig, Germany, 2008. Diploma Thesis. Helmut Seidl. Deciding equivalence of finite tree automata. In STACS 89 , volume 349 of LNCS , pages 480–492. Springer, 1989. J. Waldmann. The Combinator S. Information and Computation , 159(1–2):2–21, 2000. J. Waldmann. Matchbox: A Tool for Match-Bounded String Rewriting. In Proc. Conf.on Rewriting Techniques and Applications (RTA ’04) , volume 3091 of LNCS , pages 85–94.Springer, 2004. J. Waldmann. Compressed loops (draft), 2012. H. Zankl and A. Middeldorp. Nontermination of String Rewriting using SAT, 2007. H. Zankl, C. Sternagel, D. Hofbauer, and A. Middeldorp. Finding and certifying loops. In Proc. Conf. on Theory and Practice of Computer Science (SOFSEM 2010) , volume 5901of LNCS , pages 755–766. Springer, 2010. H. Zankl, C. Sternagel, D. Hofbauer, and A. Middeldorp. Finding and certifying loops. In SOFSEM 2010: Theory and Practice of Computer Science , volume 5901 of LNCS , pages755–766. Springer, 2010. H. Zantema and J. Endrullis. Proving Equality of Streams Automatically. In